开发者

rspec failures out of nowhere

Out of no where rspecs started failing with errors like:

ruby 1.8.7, rails 3.06.

~/.rvm/rubies/ree-1.8.7-2011.03/bin/ruby -S bundle exec rspec spec/controllers/gift_cards_controller_spec.rb:30
No DRb server is running. Running in local process instead ...
Run filtered including {:line_number=>30}
F

Failures:

  1) GiftCardsController POST to :create for a logg开发者_StackOverflow社区ed-in User with valid attributes 
     Failure/Error: it { should respond_with(:redirect) }
     NoMethodError:
       undefined method `respond_with' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1::Nested_1::Nested_1:0x11af4324>
     # ./spec/controllers/gift_cards_controller_spec.rb:30

Finished in 0.93776 seconds
1 example, 1 failure


Isn't #repond_with a Shoulda matcher? Make sure that it comes after RSpec in your Gemfile:

group :development, :test do
  gem 'rspec-rails', '2.4.1'
  gem 'shoulda-matchers', '1.0.0.beta1'
end


Having this error after upgrade my old rails app to rails 5.0. then add the following configuration into spec_helper.rb and now its working fine.

Shoulda::Matchers.configure do |config|
   config.integrate do |with|
     with.test_framework :rspec
     with.library :rails
   end
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜