From 2c8c227493509175fcdbcba3e6a85f8b954a169e Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sat, 15 Jan 2022 12:10:26 -0500 Subject: init --- test/application_system_test_case.rb | 7 +++ test/channels/application_cable/connection_test.rb | 15 +++++++ test/controllers/.keep | 0 test/controllers/machines_controller_test.rb | 50 ++++++++++++++++++++++ test/controllers/players_controller_test.rb | 50 ++++++++++++++++++++++ test/fixtures/files/.keep | 0 test/fixtures/machines.yml | 9 ++++ test/fixtures/players.yml | 11 +++++ test/helpers/.keep | 0 test/integration/.keep | 0 test/mailers/.keep | 0 test/models/.keep | 0 test/models/machine_test.rb | 9 ++++ test/models/player_test.rb | 9 ++++ test/system/.keep | 0 test/system/machines_test.rb | 45 +++++++++++++++++++ test/system/players_test.rb | 47 ++++++++++++++++++++ test/test_helper.rb | 17 ++++++++ 18 files changed, 269 insertions(+) create mode 100644 test/application_system_test_case.rb create mode 100644 test/channels/application_cable/connection_test.rb create mode 100644 test/controllers/.keep create mode 100644 test/controllers/machines_controller_test.rb create mode 100644 test/controllers/players_controller_test.rb create mode 100644 test/fixtures/files/.keep create mode 100644 test/fixtures/machines.yml create mode 100644 test/fixtures/players.yml create mode 100644 test/helpers/.keep create mode 100644 test/integration/.keep create mode 100644 test/mailers/.keep create mode 100644 test/models/.keep create mode 100644 test/models/machine_test.rb create mode 100644 test/models/player_test.rb create mode 100644 test/system/.keep create mode 100644 test/system/machines_test.rb create mode 100644 test/system/players_test.rb create mode 100644 test/test_helper.rb (limited to 'test') diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb new file mode 100644 index 0000000..652febb --- /dev/null +++ b/test/application_system_test_case.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require 'test_helper' + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :chrome, screen_size: [1400, 1400] +end diff --git a/test/channels/application_cable/connection_test.rb b/test/channels/application_cable/connection_test.rb new file mode 100644 index 0000000..4aee9b3 --- /dev/null +++ b/test/channels/application_cable/connection_test.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'test_helper' + +module ApplicationCable + class ConnectionTest < ActionCable::Connection::TestCase + # test "connects with cookies" do + # cookies.signed[:user_id] = 42 + # + # connect + # + # assert_equal connection.user_id, "42" + # end + end +end diff --git a/test/controllers/.keep b/test/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/controllers/machines_controller_test.rb b/test/controllers/machines_controller_test.rb new file mode 100644 index 0000000..61ec204 --- /dev/null +++ b/test/controllers/machines_controller_test.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +require 'test_helper' + +class MachinesControllerTest < ActionDispatch::IntegrationTest + setup do + @machine = machines(:one) + end + + test 'should get index' do + get machines_url + assert_response :success + end + + test 'should get new' do + get new_machine_url + assert_response :success + end + + test 'should create machine' do + assert_difference('Machine.count') do + post machines_url, params: { machine: { edition: @machine.edition, name: @machine.name } } + end + + assert_redirected_to machine_url(Machine.last) + end + + test 'should show machine' do + get machine_url(@machine) + assert_response :success + end + + test 'should get edit' do + get edit_machine_url(@machine) + assert_response :success + end + + test 'should update machine' do + patch machine_url(@machine), params: { machine: { edition: @machine.edition, name: @machine.name } } + assert_redirected_to machine_url(@machine) + end + + test 'should destroy machine' do + assert_difference('Machine.count', -1) do + delete machine_url(@machine) + end + + assert_redirected_to machines_url + end +end diff --git a/test/controllers/players_controller_test.rb b/test/controllers/players_controller_test.rb new file mode 100644 index 0000000..8e446f0 --- /dev/null +++ b/test/controllers/players_controller_test.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +require 'test_helper' + +class PlayersControllerTest < ActionDispatch::IntegrationTest + setup do + @player = players(:one) + end + + test 'should get index' do + get players_url + assert_response :success + end + + test 'should get new' do + get new_player_url + assert_response :success + end + + test 'should create player' do + assert_difference('Player.count') do + post players_url, params: { player: { name: @player.name, paid: @player.paid, strikes: @player.strikes } } + end + + assert_redirected_to player_url(Player.last) + end + + test 'should show player' do + get player_url(@player) + assert_response :success + end + + test 'should get edit' do + get edit_player_url(@player) + assert_response :success + end + + test 'should update player' do + patch player_url(@player), params: { player: { name: @player.name, paid: @player.paid, strikes: @player.strikes } } + assert_redirected_to player_url(@player) + end + + test 'should destroy player' do + assert_difference('Player.count', -1) do + delete player_url(@player) + end + + assert_redirected_to players_url + end +end diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/machines.yml b/test/fixtures/machines.yml new file mode 100644 index 0000000..71f327c --- /dev/null +++ b/test/fixtures/machines.yml @@ -0,0 +1,9 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + edition: MyString + +two: + name: MyString + edition: MyString diff --git a/test/fixtures/players.yml b/test/fixtures/players.yml new file mode 100644 index 0000000..61a7cf6 --- /dev/null +++ b/test/fixtures/players.yml @@ -0,0 +1,11 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + paid: false + strikes: 1 + +two: + name: MyString + paid: false + strikes: 1 diff --git a/test/helpers/.keep b/test/helpers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/integration/.keep b/test/integration/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/mailers/.keep b/test/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/models/.keep b/test/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/models/machine_test.rb b/test/models/machine_test.rb new file mode 100644 index 0000000..c711381 --- /dev/null +++ b/test/models/machine_test.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'test_helper' + +class MachineTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/player_test.rb b/test/models/player_test.rb new file mode 100644 index 0000000..263f09a --- /dev/null +++ b/test/models/player_test.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'test_helper' + +class PlayerTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/system/.keep b/test/system/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/system/machines_test.rb b/test/system/machines_test.rb new file mode 100644 index 0000000..552b188 --- /dev/null +++ b/test/system/machines_test.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require 'application_system_test_case' + +class MachinesTest < ApplicationSystemTestCase + setup do + @machine = machines(:one) + end + + test 'visiting the index' do + visit machines_url + assert_selector 'h1', text: 'Machines' + end + + test 'should create machine' do + visit machines_url + click_on 'New machine' + + fill_in 'Edition', with: @machine.edition + fill_in 'Name', with: @machine.name + click_on 'Create Machine' + + assert_text 'Machine was successfully created' + click_on 'Back' + end + + test 'should update Machine' do + visit machine_url(@machine) + click_on 'Edit this machine', match: :first + + fill_in 'Edition', with: @machine.edition + fill_in 'Name', with: @machine.name + click_on 'Update Machine' + + assert_text 'Machine was successfully updated' + click_on 'Back' + end + + test 'should destroy Machine' do + visit machine_url(@machine) + click_on 'Destroy this machine', match: :first + + assert_text 'Machine was successfully destroyed' + end +end diff --git a/test/system/players_test.rb b/test/system/players_test.rb new file mode 100644 index 0000000..b00910c --- /dev/null +++ b/test/system/players_test.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require 'application_system_test_case' + +class PlayersTest < ApplicationSystemTestCase + setup do + @player = players(:one) + end + + test 'visiting the index' do + visit players_url + assert_selector 'h1', text: 'Players' + end + + test 'should create player' do + visit players_url + click_on 'New player' + + fill_in 'Name', with: @player.name + check 'Paid' if @player.paid + fill_in 'Strikes', with: @player.strikes + click_on 'Create Player' + + assert_text 'Player was successfully created' + click_on 'Back' + end + + test 'should update Player' do + visit player_url(@player) + click_on 'Edit this player', match: :first + + fill_in 'Name', with: @player.name + check 'Paid' if @player.paid + fill_in 'Strikes', with: @player.strikes + click_on 'Update Player' + + assert_text 'Player was successfully updated' + click_on 'Back' + end + + test 'should destroy Player' do + visit player_url(@player) + click_on 'Destroy this player', match: :first + + assert_text 'Player was successfully destroyed' + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..0c92e8e --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +ENV['RAILS_ENV'] ||= 'test' +require_relative '../config/environment' +require 'rails/test_help' + +module ActiveSupport + class TestCase + # Run tests in parallel with specified workers + parallelize(workers: :number_of_processors) + + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + + # Add more helper methods to be used by all tests here... + end +end -- cgit 1.4.1