Skip to content

Instantly share code, notes, and snippets.

@jnicklas
Created Nov 11, 2016
Embed
What would you like to do?
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