The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

infocritic (2) [Avatar] Offline
#1
I am working through the 'restricting actions to admins only' section and I cannot figure out factory girl. I *think* I have followed all the steps properly but when I get past listing 7.6 on page 141, I cannot get RSpec to recognize the :user factory. I get the following error:

1) ProjectsController standard users cannot access the new action
Failure/Error: user = Factory(:user)
ArgumentError:
Factory not registered: user
# ./spec/controllers/projects_controller_spec.rb:5:in `block (2 levels) in <top (required)>'
# ./spec/controllers/projects_controller_spec.rb:13:in `block (3 levels) in <top (required)>'

I have googled it and roamed through StackOverflow with no success.

Note that if I change the Gemfile gem from factory_girl to factory_girl_rails, RSpec works, but Cucumber fails. If I leave the gem pointing to factory_girl, my Cucumber steps all pass, but I get this RSpec failure. Any idea what I am doing wrong?

Thanks,
John
jason.prins (4) [Avatar] Offline
#2
Re: Chapter 7.3 Factory Girl Problem
Did you create the new file at spec/support /factories.rb and put this content

[pre] Dir[Rails.root + "factories/*.rb"].each do |file|
require file
end[/pre]

in it?
infocritic (2) [Avatar] Offline
#3
Re: Chapter 7.3 Factory Girl Problem
That did the trick. Thank you. I have no idea how I missed that file. I know I read the instructions in the book.
ryanbigg (423) [Avatar] Offline
#4
Re: Chapter 7.3 Factory Girl Problem
Thanks Jason for answering this!
ntndeva (3) [Avatar] Offline
#5
Re: Chapter 7.3 Factory Girl Problem
I'm questioning if a person might support me out! Actually I desire to watch this particular blog at my personal brand-new iPad, but it doesn't present up correctly, So I used to be asking yourself if an individual can propose me any optimum remedy?Manali Tour | Manali Tour Package