rspec3

How is spec/rails_helper.rb different from spec/spec_helper.rb? Do I need it?

青春壹個敷衍的年華 提交于 2019-11-27 10:42:58
I am doing the Rails Tutorial for the second time. When I enter this rails generate integration_test static_pages I get spec/rails_helper.rb and spec/spec_helper.rb instead of just spec/spec_helper.rb Now when I run my tests, they are longer (more "verbose") and slower than when I did this last time. I am wondering what the difference between the two files is, and if I did something wrong. Also, is there a way to get rid of the rails_helper.rb file without messing everything up? Dave Schweisguth rspec-rails 3 generates spec_helper.rb and rails_helper.rb . spec_helper.rb is for specs which don

Set header in RSpec 3 request

左心房为你撑大大i 提交于 2019-11-27 10:22:19
问题 I'm trying to set the header for some RSpec requests that require authentication. The header is ACCESS_TOKEN . No matter how I attempt to set the header, it never gets set. I know the app works because I can manually test it, I just cant get rspec tests to work. See the full source code & tests for this problem here: https://github.com/lightswitch05/rspec-set-header-example Since authentication is used in most of my request specs, I've created support helper module to retrieve an access token

rspec failing error: expected false to respond to `false?`

≯℡__Kan透↙ 提交于 2019-11-27 02:32:34
问题 I am running this portion of a test: describe Dictionary do before do @d = Dictionary.new end it 'can check whether a given keyword exists' do @d.include?('fish').should be_false end With this code: class Dictionary def initialize @hash = {} end def add(new_entry) new_entry.class == String ? @hash[new_entry] = nil : new_entry.each { |noun, definition| @hash[noun] = definition} end def entries @hash end def keywords @hash.keys end def include?(word) if @hash.has_key?(word) true else false end

expected true to respond to true?

六眼飞鱼酱① 提交于 2019-11-27 01:44:34
问题 I upgraded my rspec-rails to 3.0.1 and now I'm seeing this error on all of my tests Failure/Error: Sidekiq::Status::complete?(json.jid).should be_true expected true to respond to `true?` I can't find the solution nor what I'm missing. 回答1: From rspec 3.0, be_true is renamed to be_truthy and be_false to be_falsey The behavior has not changed. So (nil).should be_falsey (false).should be_falsey will pass, and (anything other than nil or false).should be_truthy will also pass From the changelog 3

How is spec/rails_helper.rb different from spec/spec_helper.rb? Do I need it?

浪子不回头ぞ 提交于 2019-11-26 15:17:41
问题 I am doing the Rails Tutorial for the second time. When I enter this rails generate integration_test static_pages I get spec/rails_helper.rb and spec/spec_helper.rb instead of just spec/spec_helper.rb Now when I run my tests, they are longer (more "verbose") and slower than when I did this last time. I am wondering what the difference between the two files is, and if I did something wrong. Also, is there a way to get rid of the rails_helper.rb file without messing everything up? 回答1: rspec