about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/application_system_test_case.rb7
-rw-r--r--test/channels/application_cable/connection_test.rb15
-rw-r--r--test/controllers/.keep0
-rw-r--r--test/controllers/machines_controller_test.rb50
-rw-r--r--test/controllers/players_controller_test.rb50
-rw-r--r--test/fixtures/files/.keep0
-rw-r--r--test/fixtures/machines.yml9
-rw-r--r--test/fixtures/players.yml11
-rw-r--r--test/helpers/.keep0
-rw-r--r--test/integration/.keep0
-rw-r--r--test/mailers/.keep0
-rw-r--r--test/models/.keep0
-rw-r--r--test/models/machine_test.rb9
-rw-r--r--test/models/player_test.rb9
-rw-r--r--test/system/.keep0
-rw-r--r--test/system/machines_test.rb45
-rw-r--r--test/system/players_test.rb47
-rw-r--r--test/test_helper.rb17
18 files changed, 269 insertions, 0 deletions
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
--- /dev/null
+++ b/test/controllers/.keep
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
--- /dev/null
+++ b/test/fixtures/files/.keep
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
--- /dev/null
+++ b/test/helpers/.keep
diff --git a/test/integration/.keep b/test/integration/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/integration/.keep
diff --git a/test/mailers/.keep b/test/mailers/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/mailers/.keep
diff --git a/test/models/.keep b/test/models/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/models/.keep
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
--- /dev/null
+++ b/test/system/.keep
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