I am working on a rails app to self teach BDD and testing in general. Using cucumber + webrat + rspec, after railcasts video tuts. In this app a quiz has_many questions. The view I am testing should render the question twice and non contiguously. (not testing contiguity here) I have a cucumber scenario aimed at checking this
Given quiz titled "Pearl Jam" has questions named "Corduroy, Dissident"
When I go to the experiment page for quiz titled "Pearl Jam"
Then I should see "Corduroy" twice
And I should see "Dissident" twice
My step is defined like this:
Then /^I should see "([^\"]*)" twice$/ do |text|
regexp = Regexp.new(text + "(.+)" + text)
response.should contain(regexp)
end
I tested the regex with a tool, and it seems to work, but the test fails on cucumber.
I googled for some documentation, but webrat's only documentation is the API docs; I wasn't able to get the response displayed as text.
Any suggestion?