title: Correct way to write rspec/capybara test?
body: <p>I'm new to Ruby and Rails and I'm trying to implement tests the correct way. I'm currently working on having users sign up. I would like the first user to sign up to be an admin and then every user after that to be a regular user.</p>
  
  <p>I'm currently thinking I need to write my test as a feature but I'm wondering if this should actually be a model test.</p>
  
  <p>My current code is right here</p>
  
  <pre class="lang-rb prettyprint-override"><code>require 'spec_helper'
  
  describe "User pages" do
      subject { page }
  
      describe "Sign up page" do
          before { visit signup_path }
  
          it { should have_button('Create!') }
      end
  
      describe "Creating an account" do
          before { visit signup_path }
          let(:submit) { "Create!" }
  
      describe "with invalid information" do
          it "should not create the user account" do
              expect { click_button "Create!"}.not_to change(User, :count)
          end
  
          describe "it should display errors" do
              before { click_button submit }
  
              it { should have_content('Failed signup') }
          end
      end
  
      describe "with valid information" do
          before do
              fill_in "Name", with: "Example User"
              fill_in "Email", with: "user@example.com"
              fill_in "Password", with: "password"
              fill_in "Confirm Password", with: "password"
          end
  
          it "should create the user" do
              expect { click_button submit }.to change(User, :count).by(1)
          end
  
          # User sign in not implemented at this point
          describe "the first user" do
              User.all.count.should == 0
              click_button submit
              User.all.count.should == 1
              @firstUser = User.first
              @firstUser.is_admin?.should == true
  
              describe "the second user" do
                  before do
                      visit signup_path
                      fill_in "Name", with: "Example User2"
                      fill_in "Email", with: "user2@example.com"
                      fill_in "Password", with: "password"
                      fill_in "Confirm Password", with: "password"
                  end
  
                  click_button submit
                  @secondUser = User.all.last
                  @secondUser.is_admin?.should == false
              end
          end
      end
  end
  </code></pre>
  
  <p>end</p>
  
  <p>I'm mostly concerned with the "with valid information" part and would like to clean that up so it fits in with rspec/capybara correctly.</p>