Created
August 11, 2012 19:23
-
-
Save joelmccracken/3326523 to your computer and use it in GitHub Desktop.
This file contains 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
require File.expand_path('./interactions.rb', File.dirname(__FILE__)) | |
module Interactions | |
class EventList < Interaction | |
def event_on_page? artist, venue, date=nil | |
event_on_page_all? [artist, venue, date].reject | |
end | |
def event_on_page_all? all_content | |
with_cuke do | |
on_page = false | |
all('table.event-list tr').each do |tr| | |
index_of_nil = all_content.map do |content| | |
tr.text =~ /#{content}/ | |
end.index(nil) | |
if index_of_nil.nil? | |
on_page = true | |
end | |
end | |
on_page | |
end | |
end | |
end | |
end |
This file contains 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
Then /^I (should|should not) see the following events:$/ do |should_or_should_not, table| | |
should_it_be_there = should_or_should_not == "should" | |
interactor = Interactions::EventList.new(self) | |
table.hashes.each do |row| | |
unless interactor.event_on_page?(row["artist"], row["venue"], row["date"]) == should_it_be_there | |
raise "Wrong results for #{row.inspect}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment