Skip to content

Commit ac02a9c

Browse files
committed
fix specs?!
1 parent 89508d2 commit ac02a9c

File tree

3 files changed

+46
-37
lines changed

3 files changed

+46
-37
lines changed

spec/system/add_new_comment_spec.rb

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,60 @@
66

77
describe "Add new comment" do
88
context "when React Router", page: :main, js: true, type: :system do
9-
context "with Horizontal Form", form: :horizontal do
9+
context "with Horizontal Form" do
10+
include_examples "with Horizontal Form"
1011
include_examples "New Comment Submission", true
1112
include_examples "Validation errors displaying"
1213
end
1314

14-
context "with Inline Form", form: :inline do
15+
context "with Inline Form" do
16+
include_examples "with Inline Form"
1517
include_examples "New Comment Submission", true
1618
include_examples "Validation errors displaying"
1719
end
1820

19-
context "with Stacked Form", form: :stacked do
21+
context "with Stacked Form" do
22+
include_examples "with Stacked Form"
2023
include_examples "New Comment Submission", true
2124
include_examples "Validation errors displaying"
2225
end
2326
end
2427

2528
context "when React/Redux", page: :react_demo, js: true, type: :system do
26-
context "with Horizontal Form", form: :horizontal do
29+
context "with Horizontal Form" do
30+
include_examples "with Horizontal Form"
2731
include_examples "New Comment Submission", true
2832
include_examples "Validation errors displaying"
2933
end
3034

31-
context "with Inline Form", form: :inline do
35+
context "with Inline Form" do
36+
include_examples "with Inline Form"
3237
include_examples "New Comment Submission", true
3338
include_examples "Validation errors displaying"
3439
end
3540

36-
context "with Stacked Form", form: :stacked do
41+
context "with Stacked Form" do
42+
include_examples "with Stacked Form"
3743
include_examples "New Comment Submission", true
3844
include_examples "Validation errors displaying"
3945
end
4046
end
4147

4248
context "when simple page", page: :simple, js: true, type: :system do
43-
context "with Horizontal Form", form: :horizontal do
49+
context "with Horizontal Form" do
50+
include_examples "with Horizontal Form"
4451
include_examples "New Comment Submission", false
4552
include_examples "Validation errors displaying"
4653
end
4754

48-
context "with Inline Form", form: :inline do
55+
context "with Inline Form" do
56+
include_examples "with Inline Form"
4957
include_examples "New Comment Submission", false
5058
include_examples "Validation errors displaying"
5159
end
5260

53-
context "with the Stacked Form", form: :stacked do
61+
context "with the Stacked Form" do
62+
include_examples "with Stacked Form"
5463
include_examples "New Comment Submission", false
5564
include_examples "Validation errors displaying"
5665
end

spec/system/shared/contexts.rb

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,6 @@
1616
before { visit comments_path }
1717
end
1818

19-
# Forms
20-
shared_context "when Horizontal Form", form: :horizontal do
21-
click_link "Inline Form"
22-
expect(page).to have_css("form.commentForm.form-inline")
23-
24-
click_link "Horizontal Form"
25-
expect(page).to have_css("form.commentForm.form-horizontal")
26-
end
27-
shared_context "when Inline Form", form: :inline do
28-
click_link "Inline Form"
29-
expect(page).to have_css("form.commentForm.form-inline")
30-
end
31-
shared_context "when Stacked Form", form: :stacked do
32-
click_link "Stacked Form"
33-
expect(page).to have_css("form.commentForm.form-stacked")
34-
end
35-
36-
# Form Submission
37-
shared_context "when Form Submitted", form_submitted: true do |name: "Spicoli", text: "dude!"|
38-
fill_in "Your Name", with: name
39-
fill_in "Say something using markdown...", with: text
40-
click_button "Post"
41-
end
42-
43-
shared_context "when Form Submitted with Blank Fields", blank_form_submitted: true do
44-
include_context "Form Submitted", name: "", text: ""
45-
end
46-
4719
# Fixtures
4820
shared_context "when Existing Comment", existing_comment: true do
4921
before { Comment.create(author: "John Doe", text: "Hello there!") }

spec/system/shared/examples.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,31 @@
6363
end
6464
end
6565
end
66+
67+
68+
69+
# Forms
70+
shared_examples "with Inline Form" do
71+
click_link "Inline Form"
72+
expect(page).to have_css("form.commentForm.form-inline")
73+
end
74+
shared_examples "with Stacked Form" do
75+
click_link "Stacked Form"
76+
expect(page).to have_css("form.commentForm.form-stacked")
77+
end
78+
shared_examples "with Horizontal Form" do
79+
include_examples "with Inline Form"
80+
click_link "Horizontal Form"
81+
expect(page).to have_css("form.commentForm.form-horizontal")
82+
end
83+
84+
# Form Submission
85+
shared_examples "when Form Submitted", form_submitted: true do |name: "Spicoli", text: "dude!"|
86+
fill_in "Your Name", with: name
87+
fill_in "Say something using markdown...", with: text
88+
click_button "Post"
89+
end
90+
91+
shared_examples "when Form Submitted with Blank Fields", blank_form_submitted: true do
92+
include_context "Form Submitted", name: "", text: ""
93+
end

0 commit comments

Comments
 (0)