Skip to content

Instantly share code, notes, and snippets.

@jaredatron
Created April 27, 2009 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredatron/102814 to your computer and use it in GitHub Desktop.
Save jaredatron/102814 to your computer and use it in GitHub Desktop.
# I should see that challenge
# I should see a challenge
# I should not see any challenges
# I should see a challenge issued to me by erica
# I should see a challenge called "whatever" issued to me by erica
# I should see that I am participating in that challenge
Then /^I (should|should not)? see (a|any|that|that I am participating in (?:a|that)) challenge(?:s)?(?: called "([^\"]+)")?(?: issued to me by (\w+))?$/ do |should, what, called, issuer|
tag = what.match(/^that I am participating in/) ? '#participating .challenge .header' : '.challenge .header'
title = @challenge.title if what.match(/that/)
title = called if called.present?
html = begin
if issuer.present? and title.present?
/#{title}.*#{issuer}/
elsif issuer.present? and !title.present?
/#{issuer}/
elsif !issuer.present? and title.present?
/#{title}/
end
end
response.send should.sub(' ','_').to_sym, have_tag(tag, html)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment