From b4df24dde223a48564017d40b069e045875004df Mon Sep 17 00:00:00 2001 From: Jack Rosa Date: Thu, 5 Sep 2024 16:04:12 -0400 Subject: [PATCH] test: system tests for creating rooms and messages --- config/routes.rb | 2 +- test/system/user_creates_a_message_test.rb | 19 +++++++++++++++++++ test/system/user_creates_new_rooms_test.rb | 12 ++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 test/system/user_creates_a_message_test.rb create mode 100644 test/system/user_creates_new_rooms_test.rb diff --git a/config/routes.rb b/config/routes.rb index ef04aea..cc4b8c0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,5 @@ Rails.application.routes.draw do - resources :rooms, only: [:index, :show, :new, :create] do + resources :rooms, only: [ :index, :show, :new, :create ] do resources :messages, only: :create end root "rooms#index" diff --git a/test/system/user_creates_a_message_test.rb b/test/system/user_creates_a_message_test.rb new file mode 100644 index 0000000..856ff3c --- /dev/null +++ b/test/system/user_creates_a_message_test.rb @@ -0,0 +1,19 @@ +require "application_system_test_case" + +class UserCreatesAMessageTest < ApplicationSystemTestCase + test "User creates a message" do + visit rooms_url + click_button("+") + assert current_path = new_room_path + fill_in("Name", with: "test room") + click_button("Create Room") + assert_selector "div", text: "test room" + click_link("test room") + room = Room.last + assert current_path = room_path(room.id) + fill_in("message[content]", with: "my test message") + click_button("Send") + assert_selector "div", text: "my test message" + assert_selector "div", text: "Sent at:" + end +end diff --git a/test/system/user_creates_new_rooms_test.rb b/test/system/user_creates_new_rooms_test.rb new file mode 100644 index 0000000..4398d87 --- /dev/null +++ b/test/system/user_creates_new_rooms_test.rb @@ -0,0 +1,12 @@ +require "application_system_test_case" + +class UserCreatesNewRoomsTest < ApplicationSystemTestCase + test "creating a new room" do + visit rooms_url + click_button("+") + assert current_path = new_room_path + fill_in("Name", with: "test room") + click_button("Create Room") + assert_selector "div", text: "test room" + end +end