RSpec/Capybara tests There are three scenarios only for when the sign up validations fail, so is there a better way of representing them rather than having 4 scenarios? I don't want to create a model folder so please don't suggest that.

Is there a better way of representing this RSpec code on Rails using Capybara?

feature 'Login' do
  before do
    FactoryGirl.create(:user)
  end

  scenario "success login", js: true do
    # set_speed(:slow)
    visit root_path
    click_link 'Login'

    fill_in 'email', :with =&gt; 'test@example.com'
    fill_in 'password', :with =&gt; 'password'
    click_button 'Login'

    expect(page).to have_content('Logged in successfully')
  end

  scenario "failed login", js: true do
    # set_speed(:slow)
    visit root_path
    click_link 'Login'

    fill_in 'email', :with =&gt; 'failed@login.com'
    fill_in 'password', :with =&gt; 'something failed'
    click_button 'Login'

    expect(page).to have_content('Invalid login/password combination')
  end
end

feature "Sign Up" do
  scenario "success sign up", js:true do
    visit root_path
    click_link 'Login'
    click_link 'Sign Up'

    fill_in 'user[email]', :with=&gt;'signup@example.com'
    fill_in 'user[password]', :with=&gt; 'password'
    fill_in 'user[password_confirmation]', :with=&gt; 'password'
    click_button 'Create User'
    expect(page).to have_content('User successfully added.')
  end


  scenario "failed sign up/Wrong email format", js:true do
    visit root_path
    click_link 'Login'
    click_link 'Sign Up'  
    fill_in 'user[email]', :with=&gt;'signup.example.com'
    fill_in 'user[password]', :with=&gt; 'password'
    fill_in 'user[password_confirmation]', :with=&gt; 'password'
    click_button 'Create User'
    expect(page).to have_content('is invalid')
  end

  scenario "failed sign up/Short Email address", js:true  do
    visit root_path
    click_link 'Login'
    click_link 'Sign Up'
    fill_in 'user[email]', :with=&gt;'sign'
    fill_in 'user[password]', :with=&gt; 'password'
    fill_in 'user[password_confirmation]', :with=&gt; 'password'
    click_button 'Create User'
    expect(page).to have_content('is too short (minimum is 5 characters)')
  end 

  scenario "failed sign up/Long Email address", js:true  do
    visit root_path
    click_link 'Login'
    click_link 'Sign Up'
    fill_in 'user[email]', :with=&gt;'fillinginwritingwronglongpasswordstogetanerror@gmail.com'
    fill_in 'user[password]', :with=&gt; 'password'
    fill_in 'user[password_confirmation]', :with=&gt; 'password'
    click_button 'Create User'
    expect(page).to have_content('is too long (maximum is 50 characters)')
  end 

end
Some comments:


Rspec expects the concatenation of feature and `scenario to form a human readable text.
AFAIK, the orthodoox structure for specs is to perform the actions in the before block and only assertions in it blocks.
Use before blocks to keep your code DRY.
Personal opinion: in a feature spec, the less app internals you use, the better. So I'd write "/" instead of root_path. 
The user/password info a in the factory, I'd prefer explicit attributes on the creation.


That's how I'd write the Login feature, the same ideas apply for Signup:

feature 'Login' do
  before do
    FactoryGirl.create(:user, :email =&gt; "test@example.com", :password =&gt; "password")
    visit root_path
    click_link 'Login'
  end

  scenario "with valid user/password", js: true do
    before do
      fill_in 'email', :with =&gt; 'test@example.com'
      fill_in 'password', :with =&gt; 'password'
      click_button 'Login'
    end

    it "shows the logged in message" do
      expect(page).to have_content('Logged in successfully')
    end
  end

  scenario "with wrong user/password", js: true do
    before do
      fill_in 'email', :with =&gt; 'failed@login.com'
      fill_in 'password', :with =&gt; 'something failed'
      click_button 'Login'
    end

    it "shows an error message" do
      expect(page).to have_content('Invalid login/password combination')
    end
  end
end