Fernando Perez wrote:
> However yesterday I looked in the code of a project (mephistoblog was
> it?), and I noticed that they have: config.gem 'nokogiri' in
> environement.rb. I don't have it, is it compulsory for correctly parsing
> the response body?
I don't have config.gem 'nokogiri' in environement.rb, but I do have the
gem installed.
> I don't have any step definition, I simply use: Then I should see
> "<title>Hello world</title>, its definition is in webrat_steps.rb
Here is the step definition:
Then /^I should see "(.*)"$/ do |text|
response.body.should =~ /#{text}/m
end
That works pretty much the same way you would use it in RSpec. I don't
see any webrat methods (please correct me if I am mistaken).
I think what might be tripping you up is that this step definition just
puts whatever is in quotes into a Regex. I personally think we should
avoid having a Regex in a step because most business users don't
understand them. So I often change this matcher to be
Then /^I should see "(.*)"$/ do |text|
response.body.should =~ /#{Regexp.escape(text)}/m
end
I suggest you either try that step matcher, or you make sure your step
is properly escaping any special Regex characters. Perhaps this:
Then I should see "\<title\>Hello world\<\/title\>"
I believe that it prints out the regex used if response.body.should =~
/#{text}/m fails. If you still can't get it to work, pasting the entire
output of you test here (maybe use Pastie.org)
Caveat: I am running version 0.1.13 so it is possible things have
changed.
HTH
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users