Last active
November 3, 2015 00:12
-
-
Save jarrettgreen/6196606fec2acb1ea2be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /features/posts/ | |
Feature: Viewing All Posts | |
Scenario: There is one post to view | |
Given there is a post titled "Hello, World" with the body of "body" | |
And I am on the home page | |
Then I should see the post titled "Hello, World" with the body of "body" | |
Scenario: There are multiple posts to view | |
Given there are "5" Posts | |
And I am on the home page | |
Then I should see "5" posts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# features/step_definitions/posts | |
Given(/^I am on the home page$/) do | |
visit root_path | |
expect(page).to have_css(:h1, text: "Jarrett's Blog") | |
end | |
Given(/^there is a post titled "(.*?)" with the body of "(.*?)"$/) do |post_title, post_body| | |
Post.create(title: post_title, body: post_body) | |
expect(Post.all.count).to eq(1) | |
end | |
Then(/^I should see the post titled "(.*?)" with the body of "(.*?)"$/) do |post_title, post_body| | |
expect(page).to have_css('.post', count: 1) | |
within ".post" do | |
expect(page).to have_css(:h2, text: post_title) | |
expect(page).to have_css(:p, text: post_body) | |
end | |
end | |
Given(/^there are "(.*?)" Posts$/) do |number_of_posts| | |
number_of_posts.to_i.times do | |
Post.create(title: "Hello", body: "hello") | |
end | |
expect(Post.all.count).to eq(number_of_posts.to_i) | |
end | |
Then(/^I should see "(.*?)" posts$/) do |number_of_posts| | |
expect(page).to have_css('.post', count: number_of_posts.to_i) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment