In my spec/models/user_spec.rb I have the next:
require 'spec_helper'
describe User do
before { 5.times { FactoryGirl.create(:sport) } }
before { let(:user) { FactoryGirl.create(:user) } }
...
end
But when running my user_spec.rb I'm getting this error:
Failure/Error: before { let(:user) { FactoryGirl.create(:user) } }
NoMethodError:
undefined method `let' for #<RSpec::Core::ExampleGroup::Nested_1:0x000001043033b0>
Which is weird because my specs have been working until now, and I haven't changed anything...
Here is my gemfile: https://gist.github.com/4690919
Here is my spec_helper.rb: https://gist.github.com/4690935
I'd appreciate any help, thanks
I don't know why it was working before, but you should never have a let
block inside of a before
block. It should be called from within a describe
(or context
) block, like this:
describe User do
let(:user) { FactoryGirl.create(:user) }
before { 5.times { FactoryGirl.create(:sport) } }
....
See the documentation for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With