forked from shakacode/react-webpack-rails-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit_comment_spec.rb
39 lines (31 loc) · 1.04 KB
/
edit_comment_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require "rails_helper"
require "system/shared/examples"
require "system/shared/contexts"
feature "Edit a comment", existing_comment: true do
let(:comment) { Comment.first }
context "from classic page", page: :classic do
background { click_link "Edit", match: :first }
context "when edit is submitted" do
let(:edited_name) { "Abraham Lincoln" }
include_context "Form Submitted", name: :edited_name
scenario "comment is updated" do
expect(page).to have_css(".comment", text: :edited_name)
expect(page).to have_success_message
end
end
context "when edit is submitted with blank fields", blank_form_submitted: true do
scenario "comment is not updated" do
expect(page).not_to have_success_message
expect(page).to have_failure_message
expect(page).not_to have_css(".comment", text: "")
end
end
end
end
private
def have_success_message
have_css("#notice", "Comment was successfully created.")
end
def have_failure_message
have_css("#error_explanation")
end