[rspec-users] problem running rspec test with Webrat

Amit Kulkarni lists at ruby-forum.com
Tue Mar 8 09:10:18 EST 2011

I am trying to run rspec testcase using webrat but it is showing me an
error as "undefined method `last_response' for #<Capybara::Document>"

Following are my configurations:

roup :development, :test do
gem 'sqlite3-ruby', :require => 'sqlite3'
gem "rspec",      "=2.4.0"
gem "rspec-rails",      "2.4.0"
#gem "rspec",      ">= 2.0.0.beta.16"
#gem "rspec-rails",      ">= 2.0.0.beta.16"
gem 'webrat', '>=0.7.2.beta.6', :git =>
gem "autotest"
gem "autotest-rails"
gem "factory_girl", "=2.0.0.beta1"
gem 'capybara'
gem "launchy"

#gem 'autotest-fsevent'

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/core'
require 'rspec/matchers'
require 'webrat/core/matchers'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

require 'webrat'
require 'webrat/core/matchers'
  include Webrat::Methods
  include Webrat::Matchers
Webrat.configure do |config|
  config.mode = :rack

RSpec.configure do |config|
  config.include Rack::Test::Methods

  # == Mock Framework
  # If you prefer to use mocha, flexmock or RR, uncomment the
appropriate line:
  # config.mock_with :mocha
  # config.mock_with :flexmock
  # config.mock_with :rr
  config.mock_with :rspec

  # Remove this line if you're not using ActiveRecord or ActiveRecord
  config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of
  # examples within a transaction, remove the following line or assign
  # instead of true.
  config.use_transactional_fixtures = true
  include Webrat::Methods
  include Webrat::Matchers

Initially my spec was under spec/models/file_name,after searching i
change the path to spec/integratation/file_name but no success

Also initially i was using rspec version 2.0.0.beta.16 but after
searching i found that for webrat the version required for rspec is
I also installed that version but no success.

Also i want to know since my application is running on rails3,will the
change in version of rspec will effect running the specs

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list