|
| 1 | +require "rails_helper" |
| 2 | + |
| 3 | +# Pages |
| 4 | +shared_context "Main Page", page: :main do |
| 5 | + background { visit root_path } |
| 6 | +end |
| 7 | +shared_context "Simple Page", page: :simple do |
| 8 | + background { visit simple_path } |
| 9 | +end |
| 10 | +shared_context "Classic Page", page: :classic do |
| 11 | + background { visit comments_path } |
| 12 | +end |
| 13 | + |
| 14 | +# Forms |
| 15 | +shared_context "Horizontal Form", form: :horizontal do |
| 16 | + background { click_link "Horizontal Form" } |
| 17 | +end |
| 18 | +shared_context "Inline Form", form: :inline do |
| 19 | + background { click_link "Inline Form" } |
| 20 | +end |
| 21 | +shared_context "Stacked Form", form: :stacked do |
| 22 | + background { click_link "Stacked Form" } |
| 23 | +end |
| 24 | + |
| 25 | +# Form Submission |
| 26 | +shared_context "Form Submitted", form_submitted: true do |name: "Spicoli", text: "dude!"| |
| 27 | + let(:hint_name) { "Your Name" } |
| 28 | + let(:hint_text) { "Say something using markdown..." } |
| 29 | + let(:name) { name } |
| 30 | + let(:text) { text } |
| 31 | + |
| 32 | + background do |
| 33 | + fill_in hint_name, with: name |
| 34 | + fill_in hint_text, with: text |
| 35 | + click_button "Post" |
| 36 | + end |
| 37 | +end |
| 38 | + |
| 39 | +shared_context "Form Submitted with Blank Fields", blank_form_submitted: true do |
| 40 | + include_context "Form Submitted", name: "", text: "" |
| 41 | +end |
| 42 | + |
| 43 | +# Fixtures |
| 44 | +shared_context "Existing Comment", existing_comment: true do |
| 45 | + before { Comment.create(author: "John Doe", text: "Hello there!") } |
| 46 | +end |
0 commit comments