Skip to content

Commit

Permalink
chore: minor system specs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
palkan committed Mar 22, 2022
1 parent 4914070 commit 8b5cd70
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
24 changes: 8 additions & 16 deletions spec/system/channel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,37 @@

require "system_helper"

describe "/channels/{id}", type: :system do
describe "/channels/{id}" do
let(:channel) { create(:channel) }
let(:message) { "Progress is good. Complexity is a bridge. Simplicity is the destination." }
let(:author) { "DHH" }
let(:new_message) { "hello" }

before do
create(:message, channel: channel, content: message, author: author)
create(:message, channel: channel, content: "Progress is good", author: "DHH")
visit channel_path(id: channel.id)
end

it "has message in channel" do
expect(page).to have_text(message)
expect(page).to have_text(author)
end

it "has form to send new message in channel" do
expect(page).to have_selector "form#new_message"
expect(page).to have_button "Send"
expect(page).to have_text("Progress is good")
expect(page).to have_text("DHH")
end

it "creates a message after form submit" do
within "form#new_message" do
fill_in "message_content", with: new_message
fill_in "message_content", with: "Are you going to RailsConf?"
end

click_button "Send"
visit channel_path(id: channel.id)

expect(page).to have_text(new_message)
expect(page).to have_text("Are you going to RailsConf?")
end

context "change channel" do
let!(:msg) { create(:message, channel: create(:channel)) }
let!(:msg) { create(:message, channel: create(:channel), content: "Another channel's message") }

it "loads all messages in new channel" do
visit root_path
click_link(href: channel_path(id: msg.channel.id))
expect(page).to have_text(msg.content)
expect(page).to have_text("Another channel's message")
end
end
end
2 changes: 1 addition & 1 deletion spec/system/channels_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "system_helper"

describe "/", type: :system do
describe "/" do
let!(:channels) { create_pair(:channel) }

before { visit root_path }
Expand Down

0 comments on commit 8b5cd70

Please sign in to comment.