forked from shakacode/react-webpack-rails-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontexts.rb
62 lines (55 loc) · 1.7 KB
/
contexts.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require "rails_helper"
# Pages
shared_context "React Router Demo", page: :main do
background { visit root_path }
end
shared_context "React Demo", page: :react_demo do
background { visit no_router_path }
end
shared_context "Simple Page", page: :simple do
background { visit simple_path }
end
shared_context "Classic Page", page: :classic do
background { visit comments_path }
end
# Forms
shared_context "Horizontal Form", form: :horizontal do
background do
# added an extra click on this the non-default link to try to tease out a poltergeist crash
click_link "Inline Form"
expect(page).to have_css("form.commentForm.form-inline")
click_link "Horizontal Form"
expect(page).to have_css("form.commentForm.form-horizontal")
end
end
shared_context "Inline Form", form: :inline do
background do
click_link "Inline Form"
expect(page).to have_css("form.commentForm.form-inline")
end
end
shared_context "Stacked Form", form: :stacked do
background do
click_link "Stacked Form"
expect(page).to have_css("form.commentForm.form-stacked")
end
end
# Form Submission
shared_context "Form Submitted", form_submitted: true do |name: "Spicoli", text: "dude!"|
let(:hint_name) { "Your Name" }
let(:hint_text) { "Say something using markdown..." }
let(:name) { name }
let(:text) { text }
background do
fill_in hint_name, with: name
fill_in hint_text, with: text
click_button "Post"
end
end
shared_context "Form Submitted with Blank Fields", blank_form_submitted: true do
include_context "Form Submitted", name: "", text: ""
end
# Fixtures
shared_context "Existing Comment", existing_comment: true do
before { Comment.create(author: "John Doe", text: "Hello there!") }
end