When running my rails 4 rspec suite via rake
everything works correctly but when attempting to run rake simplecov
I get hundreds of failures all w/ a NoMethodError
something like:
1) Answer Validations
Failure/Error: it { should validate_presence_of :text }
NoMethodError:
undefined method `validate_presence_of' for #<RSpec::Core::ExampleGroup::Nested_16::Nested_1:0x007faf9fb5b7c8>
# ./spec/models/answer_spec.rb:12:in `block (3 levels) in <top (required)>'
Any clues as to why this is happening? I should also mention that I'm testing using sqlite3 :memory:
.
The shoulda libraries aren't being included in your simplecov run.
Is simplecov run in a different environment than
:test
perhaps? That may make the shoulda gem not be loaded if it's only in the:test
group in your Gemfile.How are you including simplecov in your spec_helper? Something like this?
As the very first lines of your
spec_helper.rb
?Something like this in your Gemfile?
And executing it like so?
This recipe is working very well for me in many projects. The RCov formatter may not be important depending on your purposes.