Posts:
10
From:
taiwan
Registered:
3/30/12
|
|
|
|
4.1.2 Factory_girl Syntax Depreciated
Posted:
Mar 31, 2012 1:06 PM
|
|
In Rails.root/factories/project_factory.rb
Factory.define :project do |project| project.name 'Ticketee' end
AND
Rails.root/features/step_definitions/project_steps.rb
Given /^there is a project called "([^"]*)"$/ do |name| Factory(:project, :name => name) end
These syntax are DEPRECIATED. PLEASE CHECK:
http://robots.thoughtbot.com/post/19412394597/factory-girl-hits-3-0
I only know the first one should change to
FactoryGirl.create(:project, :name => name)
Anyone knows how to change the second one to fit in 3.0?
Also a small question: what is diff between factory_girl and factory_girl_rails gem.
Thanks!
|
|
Posts:
10
From:
taiwan
Registered:
3/30/12
|
|
|
|
Re: 4.1.2 Factory_girl Syntax Depreciated
Posted:
Mar 31, 2012 1:21 PM
in response to:
take056553
|
|
factory_girl_rails gem provides Rails integration for factory_girl. So why not use factory_girl_rails gem (page 85) instead factory_girl gem.
Confused ... o_O
|
|
Posts:
2
From:
United Kingdom
Registered:
4/1/12
|
|
|
|
Re: 4.1.2 Factory_girl Syntax Depreciated
Posted:
Apr 1, 2012 3:13 AM
in response to:
take056553
|
|
Also would be glad to see the answer to this problem. Otherwise everything is going very well with this great book.
|
|
Posts:
2
From:
United Kingdom
Registered:
4/1/12
|
|
|
|
Re: 4.1.2 Factory_girl Syntax Depreciated
Posted:
Apr 1, 2012 5:16 AM
in response to:
take056553
|
|
Hi I got it working fine now.
I followed robmi advice in http://www.manning-sandbox.com/thread.jspa?threadID=48173&tstart=0
And set just the factory girl gem to the correct version at the time the book was written. I did the next two steps in the book as well and all 4 tests pass.
So in short I did this.
vi Gemfile
insert gem 'factory_girl', '1.3.3' into your test do group.
Run Bundle install and it will revert to the version that works with the book. Then change your code back to what is in the book.
I think it's probably possible to get it working with the new factory girl but you'd have to read the cucumber book and the factory girl source because the man page on github is not designed for those of us starting out with Rails.
Hope that works for you.
I will change it when I get through this whole tutorial but by then I'll hopefully know what I am doing.
|
|
Posts:
10
From:
taiwan
Registered:
3/30/12
|
|
|
|
Re: 4.1.2 Factory_girl Syntax Depreciated
Posted:
Apr 1, 2012 12:20 PM
in response to:
xkcd
|
|
Thanks xkcd!!! Your name reminds me of python comic... Fly......
Thank you for inform the gem version at the time of book written. I didn't revert to the old gem if I have to. Because we've to keep it somehow up-to-date. But being up-to-date is fairly difficult. In Rails there are so many conventions over configurations. Like this gem, factory_girl. I am the first time here, how am I supposed to know the vintage syntax they introduced maybe from version 1.0 or 2.0 o_O...
Thank you for pointing out.
|
|
Posts:
4
From:
Columbus, OH
Registered:
4/14/12
|
|
|
|
Re: 4.1.2 Factory_girl Syntax Depreciated
Posted:
Apr 14, 2012 12:16 PM
in response to:
xkcd
|
|
I got it to work with the new syntax: Gemfile group :test do # gem 'cucumber-rails' # does not make web-steps file # Aslak Hellesoy wrote this under duress - lets Rails 3 in Action work gem 'cucumber-rails-training-wheels' gem 'capybara' gem 'database_cleaner' gem 'factory_girl_rails' end
factories/project_factory.rb FactoryGirl.define do factory :project do name 'Ticketee' end end
rm features/support/factories.rb
And all green.
|
|
Posts:
394
From:
Sydney
Registered:
6/18/10
|
|
|
|
Re: 4.1.2 Factory_girl Syntax Depreciated
Posted:
Apr 14, 2012 12:20 PM
in response to:
tllucero
|
|
Yup, that new syntax will indeed work. We'll be using that in the next version of Rails 3 in Action as well.
|
|
Posts:
1
From:
New York
Registered:
8/20/12
|
|
|
|
Re: 4.1.2 Factory_girl Syntax Depreciated
Posted:
Aug 20, 2012 12:46 AM
in response to:
ryanbigg
|
|
FYI,
I could not get the prior listed syntax to work. When I made the modifications I got an undefined function error from features/project_steps.rb. Even after changing Factory -> FactoryGirl the undefined function error persisted both when I ran bin/cucumber features/viewing_projects.rb and in the rails console. I was able to make the code on page 86 by following the instructions (http://www.manning-sandbox.com/thread.jspa?threadID=51512&tstart=0) by specifying the version of 'factory_girl','1.3.3'. I also had to add 'cucumber-rails' to the test group. Without cucumber-rails I received a:
no such file to load -- cucumber/rails/active_record (LoadError)
The answer appeared to be to reinstall cucumber: (http://railsforum.com/viewtopic.php?id=43492)
rails g cucumber:install
I allowed it to overwrite the path.rb and then the code worked. I would prefer to use as much of the new syntax as possible so I consider this less desirable the suggestion above. Howeve, I think there may still be a few missing steps. Many thanks to authors and other contributors to this forum.
|
|
|
Legend
|
|
Gold: 300
+
pts
|
|
Silver: 100
- 299
pts
|
|
Bronze: 25
- 99
pts
|
|
Manning Author
|
|
Manning Staff
|
|