Forum: RSpec Newbie: Rspec, Webrat, Mechanize, Cucumber

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
2e40e0748da35936dce13467aa06ac5c?d=identicon&s=25 DVG (Guest)
on 2009-05-07 19:38
(Received via mailing list)
Alright, I'm trying to get up to speed with using Rspec, Webrat,
Mechanize and Cucumber to test a non rails application.

The RSpec Matchers (I think) seem to not be working as expected. When
I run my feature, it says the world cannot find the method "contain"

I have the following gems installed:
cucumber 0.3.2
rspec 1.2.6
mechanize 0.9.2
webrat 0.4.4

My feature is as follows:
Feature: Google
  In order to buy a sweet new laptop
  As a apple enthusiest
  I want to find

  Scenario: Search for apple
    Given I visit ""
    When I fill in "q" with ""
    And I press "Google Search"
    Then I should see ""

require 'webrat'

Webrat.configure do |config|
  config.mode = :mechanize

require 'webrat/core/matchers'
require 'webrat/mechanize'
class MechanizeWorld < Webrat::MechanizeSession
  require 'spec'
  include Spec::Matchers

World do

Given /^I visit "(.*)"$/ do |url|

When I run the feature, everything passes except for the last step,
"should see"
Then /^I should see "([^\"]*)"$/ do |text|
  response.should contain(text)

The error it gives is:

    Then I should see ""
      undefined method `contain' for #<MechanizeWorld:0x429aa64>
      ./features/step_definitions/webrat_steps.rb:94:in `/^I should
see "([^\"]*)"$/'
      features/google.feature:10:in `Then I should see

As far as I know, contain is an rspec matcher which is getting
included in MechanizeWorld, but it doesn't seem to be working

Any ideas?
Ff937b6907db49432c980f2b6a5c7e71?d=identicon&s=25 Mischa Fierer (mischa)
on 2009-05-11 13:56
(Received via mailing list)
This topic is locked and can not be replied to.