Skip to content

Commit

Permalink
test: system tests for creating rooms and messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jackrosa183 committed Sep 5, 2024
1 parent 3f52106 commit b4df24d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
19 changes: 19 additions & 0 deletions test/system/user_creates_a_message_test.rb
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions test/system/user_creates_new_rooms_test.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b4df24d

Please sign in to comment.