title: rspec not running because of factorygirl
body: <p>When I run rspec spec/requests/users_spec.rb</p>
  
  <p>I get this:</p>
  
  <pre><code>admin@Administrators-MacBook-Pro:~/Desktop/sample_app$ rspec spec/requests/users_spec.rb
  No DRb server is running. Running in local process instead ...
  Rack::File headers parameter replaces cache_control after Rack 1.5.
  /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/factory_girl-4.1.0/lib/factory_girl/syntax/default.rb:6:in `define': wrong number of arguments (1 for 0) (ArgumentError)
      from /Users/admin/Desktop/sample_app/spec/factories.rb:4:in `&lt;top (required)&gt;'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `block in load'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/factory_girl-4.1.0/lib/factory_girl/find_definitions.rb:16:in `block in find_definitions'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/factory_girl-4.1.0/lib/factory_girl/find_definitions.rb:15:in `each'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/factory_girl-4.1.0/lib/factory_girl/find_definitions.rb:15:in `find_definitions'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/factory_girl_rails-4.1.0/lib/factory_girl_rails/railtie.rb:26:in `block in &lt;class:Railtie&gt;'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:34:in `call'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:42:in `each'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.11/lib/rails/application/finisher.rb:59:in `block in &lt;module:Finisher&gt;'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `block in run_initializers'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
      from /Users/admin/Desktop/sample_app/config/environment.rb:5:in `&lt;top (required)&gt;'
      from /Users/admin/Desktop/sample_app/spec/spec_helper.rb:8:in `require'
      from /Users/admin/Desktop/sample_app/spec/spec_helper.rb:8:in `block in &lt;top (required)&gt;'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/spork-0.9.2/lib/spork.rb:24:in `prefork'
      from /Users/admin/Desktop/sample_app/spec/spec_helper.rb:3:in `&lt;top (required)&gt;'
      from /Users/admin/Desktop/sample_app/spec/requests/users_spec.rb:1:in `require'
      from /Users/admin/Desktop/sample_app/spec/requests/users_spec.rb:1:in `&lt;top (required)&gt;'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `load'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `block in load_spec_files'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `each'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `load_spec_files'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.2/lib/rspec/core/command_line.rb:22:in `run'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.2/lib/rspec/core/runner.rb:77:in `rescue in run'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.2/lib/rspec/core/runner.rb:73:in `run'
      from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.2/lib/rspec/core/runner.rb:17:in `block in autorun'
  </code></pre>
  
  <p>this is factories.rb:</p>
  
  <pre><code># By using the symbol ':user', we get Factory Girl to simulate the User model.
  # we can create a User factory in the tests like this:
  # @user = Factory(:user)
  FactoryGirl.define :user do |user|
      user.name "Pavan Katepalli"
      user.email "email@pavan.com"
      user.password "foobar"
      user.password_confirmation "foobar"
  end
  </code></pre>
  
  <p>this is users_spec:</p>
  
  <pre><code>require 'spec_helper'
  require 'factory_girl_rails'
  
  describe "Users" do
  
    describe "signup" do
  
          describe "failure" do
              it "should not make a new user" do
                  lambda do
                      visit signup_path
                      fill_in "Name",         :with =&gt; ""
                      fill_in "Email",        :with =&gt; ""
                      fill_in "Password",     :with =&gt; ""
                      fill_in "Confirmation", :with =&gt; ""
                      click_button
                      response.should render_template('users/new')
                      response.should have_selector('div#error_explanation')
                  end.should_not change(User, :count)
              end
          end
  
          describe "success" do
        it "should make a new user" do
          lambda do
            visit signup_path
            fill_in "Name",         :with =&gt; "Example User"
            fill_in "Email",        :with =&gt; "user@example.com"
            fill_in "Password",     :with =&gt; "foobar"
            fill_in "Confirmation", :with =&gt; "foobar"
            click_button
            response.should have_selector('div.flash.success',
                                          :content =&gt; "Welcome")
            response.should render_template('users/show')
          end.should change(User, :count).by(1)
        end
      end
  
  
      end
  
  end
  </code></pre>
  
  <p>this is users_controller_spec.rb:</p>
  
  <pre><code>require 'spec_helper'
  require 'factory_girl_rails'
  
  describe UsersController do
  
      render_views
  
      describe "GET 'show'" do
  
          before(:each) do
            @user = FactoryGirl(:user)
          end
  
          it "should be successful" do
            get :show, :id =&gt; @user.id
            response.should be_success
          end
  
          it "should find the right user" do
            get :show, :id =&gt; @user.id
  
            # assigns(:user) returns the 
            # value of the instance variable @user
            assigns(:user).should == @user
          end
  
          it "should have the right title" do
            get :show, :id =&gt; @user.id
            response.should have_selector('title', :content =&gt; @user.name)
          end
  
          it "should have the user's name" do
            get :show, :id =&gt; @user.id
            response.should have_selector('h1', :content =&gt; @user.name)
          end
  
          it "should have a profile image" do
            get :show, :id =&gt; @user.id
            response.should have_selector('h1&gt;img', :class =&gt; "gravatar")
          end
      end
  
      describe "GET 'new'" do
  
          it "should be successful" do
            get :new
            response.should be_success
          end
  
          it "should have the right title" do
            get :new
            response.should have_selector('title', :content =&gt; "Sign up")
          end
      end
  
      describe "POST 'create'" do
  
          describe "failure" do
  
              before(:each) do
                  @attr = { :name =&gt; "", :email =&gt; "", :password =&gt; "",
                        :password_confirmation =&gt; "" }
              end
  
              it "should not create a user" do
                  lambda do
                      post :create, :user =&gt; @attr
                  end.should_not change(User, :count)
              end
  
              it "should have the right title" do
                  post :create, :user =&gt; @attr
                  response.should have_selector('title', :content =&gt; "Sign up")
              end
  
              it "should render the 'new' page" do
                  post :create, :user =&gt; @attr
                  response.should render_template('new')
              end
          end
  
          describe "success" do
  
              before(:each) do
                  @attr = { :name =&gt; "New User", :email =&gt; "user@example.com",
                        :password =&gt; "foobar", :password_confirmation =&gt; "foobar" }
              end
  
              it "should create a user" do
                  lambda do
                      post :create, :user =&gt; @attr
                  end.should change(User, :count).by(1)
              end
  
              it "should redirect to the user show page" do
                  post :create, :user =&gt; @attr
                  response.should redirect_to(user_path(assigns(:user)))
              end
  
              it "should have a welcome message" do
                  post :create, :user =&gt; @attr
                  flash[:success].should =~ /welcome to the sample app/i
              end
  
          end
      end
  
  
  
  end
  </code></pre>