rspec-rails

railties (LoadError) Cannot load such file

一曲冷凌霜 提交于 2020-01-07 02:23:26
问题 I've got a Ruby on Rails app, just added rspec-rails and I tried to run: rails generate rspec:install But received this: /usr/local/bin/rails:23:in `load': cannot load such file -- /usr/share /rubygems-integration/all/gems/railties-4.2.6/bin/rails (LoadError) From my Gemfile... gem 'rspec-rails', '~> 3.5' And I'm running Rails v4.2.5.1 回答1: I've just done sudo gem install rails and now it works. 来源: https://stackoverflow.com/questions/42379882/railties-loaderror-cannot-load-such-file

railties (LoadError) Cannot load such file

若如初见. 提交于 2020-01-07 02:23:19
问题 I've got a Ruby on Rails app, just added rspec-rails and I tried to run: rails generate rspec:install But received this: /usr/local/bin/rails:23:in `load': cannot load such file -- /usr/share /rubygems-integration/all/gems/railties-4.2.6/bin/rails (LoadError) From my Gemfile... gem 'rspec-rails', '~> 3.5' And I'm running Rails v4.2.5.1 回答1: I've just done sudo gem install rails and now it works. 来源: https://stackoverflow.com/questions/42379882/railties-loaderror-cannot-load-such-file

Gem dependency conflict between coffee-rails and rspec-rails

随声附和 提交于 2020-01-06 04:12:04
问题 I'm upgrading an app from rails 3.1.1 to rails 3.2. I had to update version of coffee-rails as well as rspec-rails to their latest versions to work with rails 3.2. However, they both seem to be incompatible with each other. When I run the bunder I get In Gemfile: coffee-rails (~> 3.2.2) ruby depends on actionpack (= 3.2.0) ruby rspec-rails (~> 2.8.1) ruby depends on actionpack (3.0.0) However, on rubygems for rspec-rails, it clearly specifies the dependency to be >= actionpack (3.0.0) Has

Force HTTPS/SSL for all controller/request specs in rspec

送分小仙女□ 提交于 2020-01-05 07:27:13
问题 I'm using RSpec 3.5.0, and would like to enable HTTPS/SSL requests for all my specs. Since I added force_ssl to my ApplicationController , all my specs are failing, since they are redirecting to the secure version of the site instead of rendering, etc. 回答1: The suggestions here don't work under rails 5. If that's part of where you're stuck adding https! to your spec should work. 来源: https://stackoverflow.com/questions/40633069/force-https-ssl-for-all-controller-request-specs-in-rspec

RSpec Rails Login Filter

限于喜欢 提交于 2020-01-04 14:14:33
问题 I recently switched started using rspec-rails(2.6.1) with my Rails(3.0.8) app. I'm used to Test::Unit, and I can't seem to get a filter working for my test methods. I like to keep things as DRY as possible, so I'd like to set up a filter that I can call on any test method that will login as an Authlogic user before the test method is called. I tried accomplishing this by using an RSpec filter in spec_helper.rb: config.before(:each, :login_as_admin => true) do post "/user_sessions/create",

RSpec Rails Login Filter

最后都变了- 提交于 2020-01-04 14:14:19
问题 I recently switched started using rspec-rails(2.6.1) with my Rails(3.0.8) app. I'm used to Test::Unit, and I can't seem to get a filter working for my test methods. I like to keep things as DRY as possible, so I'd like to set up a filter that I can call on any test method that will login as an Authlogic user before the test method is called. I tried accomplishing this by using an RSpec filter in spec_helper.rb: config.before(:each, :login_as_admin => true) do post "/user_sessions/create",

How to resolve RSpec's deprecation warning about the new expect syntax?

六眼飞鱼酱① 提交于 2020-01-03 10:18:29
问题 When I run this RSpec example, it passes but I'm getting a deprecation warning. context "should have valid detail for signup" do it "should give error for invalid confirm password" do find("#usernamesignup").set("Any_name") find("#mobile_number").set("1234567890") find("#emailsignup").set("mymail@yopmail.com") find("#passwordsignup").set("12345678") find("#passwordsignup_confirm").set("") find(".signin").click sleep 2 page.should have_content "Confirm Password Does not Match" end end Here is

Testing a Class inside of a Module with RSpec

Deadly 提交于 2020-01-02 04:34:32
问题 So, I have a module in my ruby code which looks something like this: module MathStuff class Integer def least_factor # implementation code end end end and I have some RSpec tests in which I would like to test that my Integer#least_factor method works as expected. we'll say that the tests are in the same file for simplicity. The tests look something like this: describe MathStuff do describe '#least_factor' do it 'returns the least prime factor' do expect(50.least_factor).to eq 2 end end end

ActionController::UrlGenerationError, No route matches

别等时光非礼了梦想. 提交于 2020-01-02 00:17:52
问题 I've read through every similar question I could find and still can't figure out my problem. # routes.rb Rails.application.routes.draw do resources :lists, only: [:index, :show, :create, :update, :destroy] do resources :items, except: [:new] end end # items_controller.rb (excerpt) class ItemsController < ApplicationController ... def create @list = List.find(params[:list_id]) ... end ... end # items_controller_spec.rb (excerpt) RSpec.describe ItemsController, type: :controller do ... let!(

testing with specs, capybara from railstutorial chapter 3 does not work (have_selector('title', :text => ' | Home'))

三世轮回 提交于 2020-01-01 08:44:45
问题 im working on ruby.railstutorial.org/ruby-on-rails-tutorial-book. Im using rails 3.2.7, spork, rspec, capybara, launchy and some guards :) i have a really weird problem in Chapter 3 with testing: It seems like the tests arent working for what is inside the <head> -Tag. If i put the <title> -tag inside the <body> -tag instead of the head-tag it works fine. Also it works when i put <h1> -tags above the <title> inside <head> -Tags. It is weird, isnt it? Please help me figur out. The example is