Reputation: 1568
I have a problem concerning testing with factorygirl:
First some code:
customesr_spec.rb:
require 'spec_helper'
describe "customers" do
describe "signup" do
#FactoryGirl.find_definitions
user = FactoryGirl.create(:signup_customer)
it "has right data" do
visit signup_path
fill_in :id, :with => 2110001
fill_in :name, :with => "AVK POLSKA Sp. zo.o."
fill_in :email, :with => "[email protected]"
fill_in :email_confirmation, :with => "[email protected]"
click_button "Create account"
page.should have_content("Fireprotection")
end
end
factories.rb
FactoryGirl.define do
factory :signup_customer, class: Customer do
id = 2110001
name = "AVK POLSKA Sp. zo.o."
email = ""
address_1 = "ul. Jakubowska 1"
address_2 = "Pniewy 62-045"
zipcode = 62
city = "Pniewy"
currency = "PLN"
country_id = "PL"
contact_person_id = "AZU"
reset_token = nil
reset_token_init = nil
end
end
This is the error that I get when running that test:
Running tests with args ["--drb", "-f", "progress", "-r", "c:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-rspec-2.1.1/lib/guard/rspec/formatter.rb",
"-f", "Guard::RSpec::Formatter", "--out", "/dev/null", "--failure-exit-code", "2", "spec"]...
<-- take tuple(1); slave.run...
09:17:40 - ERROR - Guard::RSpec failed to achieve its <start>, exception was:
[#73C9383A03A6] DRb::DRbUnknownError: ActiveRecord:: [#73C9383A03A6] c:/Ruby193/lib/ruby/1.9.1/drb/drb.rb:1095:in
method_missing' [#73C9383A03A6] c:/Ruby193/lib/ruby/gems/1.9.1/gems/guard-rspec-2.1.1/lib/guard/rspec/runner.rb:124:in
run_via_drb'
Do I have to put a require somewhere? What am I missing here?
Upvotes: 1
Views: 321
Reputation: 834
Did you init the spork? You should have some Spork.prefork blocks in your code so it know what it can keep in memory for the entire time and what it can reload upon each run. I don't see your rspec files here with the spork blocks defined.
Upvotes: 0
Reputation: 1568
First I have to mention this:
I was using Guard with Rspec and Spork on my windows pc. -> I added Spork to have faster tests once guard and rspec were running.
What I did to solve the problem (with thanks to the freenode #RubyOnRails channel.:
user = FactoryGirl.create(:signup_customer)
#This is wrong! Has to be:
let(:user) {FactoryGirl.create(:signup_customer)}
Upvotes: 1