-
Notifications
You must be signed in to change notification settings - Fork 35
Closed
Description
I've upgraded to Rails 4.1 and had problems running rspec with spring. It threw errors which indicated that shoulda-matchers
gem was not loaded.
Failures:
1) Post should have many :comments
Failure/Error: it { should have_many(:comments) }
NoMethodError:
undefined method `has_many?' for #<Post:0x007ff923bf57d8>
# ./spec/models/post_spec.rb:11:in `block (2 levels) in <top (required)>'
# -e:1:in `<main>'
2) Post
Failure/Error: it { should belong_to(:author) }
NoMethodError:
undefined method `belong_to' for #<RSpec::Core::ExampleGroup::Nested_1:0x007ff92854b298>
# ./spec/models/post_spec.rb:10:in `block (2 levels) in <top (required)>'
# -e:1:in `<main>'
3) Post
Failure/Error: it { should validate_presence_of :title }
NoMethodError:
undefined method `validate_presence_of' for #<RSpec::Core::ExampleGroup::Nested_1:0x007ff9285482c8>
# ./spec/models/post_spec.rb:7:in `block (2 levels) in <top (required)>'
# -e:1:in `<main>'
I've tried changing my Gemfile and got it working by manually requiring the gem in spec_helper.rb.
# Gemfile
group :test do
gem 'shoulda-matchers', require: false
end
# spec/spec_helper.rb
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rails'
require 'webmock/rspec'
require 'email_spec'
# require 'rspec/autorun'
require 'shoulda-matchers'
...
This way the gem is loaded and rspec runs without problems. However I believe this should be fixed somehow. Not sure if this is spring-commands-rspec
, spring
or even rails
related problem.
Metadata
Metadata
Assignees
Labels
No labels