Webrat 0.7.2 and rails 3

82 views
Skip to first unread message

Fjan

unread,
Nov 1, 2010, 7:15:09 PM11/1/10
to webrat
Hi there,

I'm trying to convert to rails 3 and run into the following problem
with webrat 0.7.2:

- if I set config.mode=:rack then the @request variable gets set to
nil, breaking all test::unit assertions such as assert_response
- if I set config.mode=:rails then the webrat methods don't get
included and I get errors like "undefined method 'visit'"

Downgrading to webrat 0.7.1 fixes the first problem, but not the
second. Any ideas what I could be doing wrong?

My test is really simple so it can’t be that:

test "fp" do
visit '/'
assert_response :ok
end

Fjan

unread,
Nov 2, 2010, 10:21:10 AM11/2/10
to webrat
Just to answer my own question for people that come googling here.

Here is what you need to do if you want to make webrat work with Rails
3 and the regular rails (non-rspec, non-cucumber) test suite.

To your gem file add:
gem 'webrat', '>=0.7.2.pre', :git => 'http://github.com/kalv/
webrat.git'

To your testhelper.rb add:
include Webrat::Methods
include Webrat::Matchers

Leave config.mode = :rails, (don't use :rack), and make sure you have
git installed, obviously, then run bundle.

Cheers,
Jan
(Answer derived from the thread below that deals with Rails 3 and
Cucumber. I didn't have any luck with the orangewise fork mentioned
in the other thread.).
Reply all
Reply to author
Forward
0 new messages