Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Improve Rails5 test support #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ gem 'jbuilder', '~> 2.5'
gem 'bootsnap', '>= 1.1.0', require: false

gem 'sorcery'
gem 'rails-controller-testing'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ GEM
bundler (>= 1.3.0)
railties (= 5.2.2)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.4)
actionpack (>= 5.0.1.x)
actionview (>= 5.0.1.x)
activesupport (>= 5.0.1.x)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
Expand Down Expand Up @@ -220,6 +224,7 @@ DEPENDENCIES
listen (>= 3.0.5, < 3.2)
puma (~> 3.11)
rails (~> 5.2.2)
rails-controller-testing
sass-rails (~> 5.0)
selenium-webdriver
sorcery
Expand Down
10 changes: 5 additions & 5 deletions test/functional/users_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,34 @@ class UsersControllerTest < ActionController::TestCase

test 'should create user' do
assert_difference('User.count') do
post :create, user: { email: 'bla@pitput.com', password: 'gluplup', password_confirmation: 'gluplup' }
post :create, params: { user: { email: 'bla@pitput.com', password: 'gluplup', password_confirmation: 'gluplup' }}
end

assert_redirected_to users_path
end

test 'should show user' do
login_user
get :show, id: @user.to_param
get :show, params: { id: @user.id }
assert_response :success
end

test 'should get edit' do
login_user
get :edit, id: @user.to_param
get :edit, params: { id: @user.id }
assert_response :success
end

test 'should update user' do
login_user
put :update, id: @user.to_param, user: @user.attributes
put :update, params: { id: @user.id, user: @user.attributes }
assert_redirected_to user_path(assigns(:user))
end

test 'should destroy user' do
login_user
assert_difference('User.count', -1) do
delete :destroy, id: @user.to_param
delete :destroy, params: { id: @user.id }
end

assert_redirected_to users_path
Expand Down