Sha256: 267b69ea5ebce81812d8cae543b45f97239db9d432afa4f7d17c9e81d4946984

Contents?: true

Size: 1.29 KB

Versions: 4

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'
require 'support/features/feature_helpers'

feature 'create a user with valid attributes' do

  # this doesn't belong as a feature test but it will catch regressions.
  # consider moving to a request spec or... something.
  scenario 'increases number of users' do
    expect { create_user_with_valid_params }.to change { User.count }.by(1)
  end

  scenario 'signs in the user after creation' do
    create_user_with_valid_params
    expect_user_to_be_signed_in
  end

  scenario 'redirects to redirect_url' do
    create_user_with_valid_params
    expect_path_is_redirect_url
  end
end

feature 'visit a protected url, then create user' do
  scenario 'redirects to the protected url after user is created' do
    visit '/welcome'
    create_user_with_valid_params
    expect(current_path).to eq '/welcome'
  end
end

feature 'create user after signed in' do
  scenario 'cannot get to new user page' do
    user = create(:user, email: 'test.user@example.com')
    sign_in_with user.email, user.password
    visit new_users_path
    expect_path_is_redirect_url
  end
end

def create_user_with_valid_params(user_attrs = attributes_for(:user))
  visit new_users_path
  fill_in 'user_email', with: user_attrs[:email]
  fill_in 'user_password', with: user_attrs[:password]
  click_button 'Sign up'
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
authenticate-0.7.1 spec/features/create_user_spec.rb
authenticate-0.7.0 spec/features/create_user_spec.rb
authenticate-0.6.1 spec/features/create_user_spec.rb
authenticate-0.6.0 spec/features/create_user_spec.rb