Reputation: 1395
I have ran into a quick problem. I am getting a "undefined method `Factory'" for the user_spec page. I believe I have the incorrect syntax for " let(:user) { Factory(:user) }". However I can't come up with one that works.
Failure/Error: let(:user) { Factory(:user) }
NoMethodError:
undefined method `Factory' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007fc7ac31e6a8>
If someone can take a look at my code and help me out that would be appreciated as I am almost done testing for the password reset.
user_spec.rb:
require 'spec_helper'
describe User do
describe "#send_password_reset" do
let(:user) { Factory(:user) }
it "generates a unique password_reset_token each time" do
user.send_password_reset
last_token = user.password_reset_token
user.send_password_reset
user.password_reset_token.should_not eq(last_token)
end
it "saves the time the password reset was sent" do
user.send_password_reset
user.reload.password_reset_sent_at.should be_present
end
it "delivers email to user" do
user.send_password_reset
last_email.to.should include (user.email)
end
end
end
Upvotes: 4
Views: 2738
Reputation: 2469
the Factory Girl method is the following:
let(:user) { FactoryGirl.create(:user) }
Upvotes: 8
Reputation: 115541
Replace Factory
with FactoryGirl
, they changed that to remove ambiguity and to let the useful Factory
namespace available.
Upvotes: 7