FactoryGirl @attr - 13 Mar 2012

If you’re tired of having to declare @attr in your tests, then FactoryGirl has you covered. Once you have the gem 'factory_girl_rails' installed, you simply needed to add the following line to your spec_helper.rb.

  config.include Factory::Syntax::Methods

You can then setup your tests as such:

it 'should create a user' do
  lambda do
    post :create, user: attributes_for( :user )
  end.should change( User, :count ).by 1