Skip to content

Instantly share code, notes, and snippets.

@bunnymatic
Last active March 12, 2016 18:37
Show Gist options
  • Save bunnymatic/5eed819e3200a888a6c8 to your computer and use it in GitHub Desktop.
Save bunnymatic/5eed819e3200a888a6c8 to your computer and use it in GitHub Desktop.
module Capybara
class Session
def has_flash?(kind, msg)
within ".alert-#{kind}" do
has_content?(msg)
end
end
end
end
module CapybaraHelpers
def table_row_matching(content)
content_matcher = content.is_a?(String) ? /#{content}/ : content
match = all('table tbody tr').select do |row|
content_matcher =~ row.text
end
raise "Can't find row matching \"#{content}\"" unless match.first
match.first
end
end
RSpec.configure do |config|
config.include CapybaraHelpers, type: :feature
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment