Skip to content

Instantly share code, notes, and snippets.

@jnicklas
Created November 11, 2016 14:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnicklas/fcfa5e480bf47adbcf7abf08577e59cd to your computer and use it in GitHub Desktop.
Save jnicklas/fcfa5e480bf47adbcf7abf08577e59cd to your computer and use it in GitHub Desktop.
describe "My page" do
it "lists the item" do
item = create_item
within item_row(item) do
expect(page).to mention_item(item)
end
end
private
def item_row(item)
find(".test-item-#{item.id}")
end
def mention_item(item)
have_content(item.title)
end
end
Capybara.add_selector :item_row do
css { |item| ".test-item-#{item.id}" }
end
describe "My page" do
it "lists the item" do
item = create_item
within :item_row, item do
expect(page).to mention_item(item)
end
end
private
def mention_item(item)
have_content(item.title)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment