# Cucumber, Webrat, RSpec and Mechanize for Non-Ruby Apps

**URL:** <https://www.ruby-forum.com/t/cucumber-webrat-rspec-and-mechanize-for-non-ruby-apps/167335>\
**Category:** Rails\
**Created:** [May 6, 2009, 8:33pm UTC](https://www.ruby-forum.com/t/cucumber-webrat-rspec-and-mechanize-for-non-ruby-apps/167335 "2009-05-06T20:33:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DVG](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/67e7ee/32.png) [@DVG](https://www.ruby-forum.com/u/DVG)\
**Post date:** [May 6, 2009, 8:33pm UTC](https://www.ruby-forum.com/t/cucumber-webrat-rspec-and-mechanize-for-non-ruby-apps/167335/1 "2009-05-06T20:33:43Z")

</div>

The folks here have given me the task of figuring out if cucumber can  
be used successfully to test some of our apps.

I have the latest versions of rails, mechanize, cucumber webrat and  
rspec installed.

#/cuketest/features/google.feature  
Feature: New PC  
In order to get a sweet new PC  
As a apple nerd  
I want to find [apple.com](http://apple.com)

Scenario: Get a sweet new computer  
Given I visit “[http://www.google.com](http://www.google.com)”  
When I fill in “q” with “apple”  
And I press “Google Search”  
Then I should see “[www.apple.com](http://www.apple.com)”

#/cuketest/features/support/env.rb  
#…  
Webrat.configure do |config|  
config.mode = :mechanize  
end  
#…  
class MechanizeWorld \< Webrat::MechanizeSession  
require ‘spec’  
include Spec::Matchers  
end  
#…

#/cuketest/features/support/paths.rb  
module NavigationHelpers

# Maps a name to a path. Used by the

# 

# When /^I go to (.+)$/ do |page\_name|

# 

# step definition in webrat\_steps.rb

# 

def path\_to(page\_name)  
case page\_name

```
when /the homepage/
  '/'

# Add more mappings here.
# Here is a more fancy example:
#
# when /^(.*)'s profile page$/i
# user_profile_path(User.find_by_login($1))

else
  raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
    "Now, go and add a mapping in #{ __FILE__ }"
end

```

end  
end  
World(NavigationHelpers)[/code]  
This is not complete however. If I run rake features at this point, I  
get an error saying it doesn’t understand the visit command in the  
step (which i assume comes from Mechanize)

The various information around the internet points to me needing to  
add this to the world:

`World do
  MechanizeWorld.new
end`  
Adding this block gives me the following error:  
c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.2/bin/…/lib/cucumber/  
step\_mother.rb:195:in `World': You can only pass a pro c to #World once, but it's happening (Cucumber::MultipleWorld) in 2 places: ls/world.rb:84:in `World’  
features/support/paths.rb:26:in `World' Use Ruby modules instead to extend your worlds. See the Cucumber::StepMother#World RDoc or http://wiki.github.com/aslakhellesoy/cucumber/a-whole-new-world. from ./features/support/paths.rb:26 from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: 31:in `gem\_original\_require’  
from c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:  
31:in `polyglot_original_require' from c:/ruby/lib/ruby/gems/1.8/gems/polyglot-0.2.5/lib/ polyglot.rb:54:in `require’  
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/  
active\_support/dependencies.rb:158:in `require' from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.2/bin/../lib/ cucumber/cli/main.rb:79:in `require\_files’  
from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.2/bin/…/lib/  
cucumber/cli/main.rb:77:in `each' from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.2/bin/../lib/ cucumber/cli/main.rb:77:in `require\_files’  
from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.2/bin/…/lib/  
cucumber/cli/main.rb:34:in `execute!' from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.2/bin/../lib/ cucumber/cli/main.rb:20:in `execute’  
from c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.2/bin/  
cucumber:6  
rake aborted!  
Command failed with status (1): [c:/ruby/bin/ruby -I "c:/ruby/lib/ruby/  
gems…]  
(See full trace by running task with --trace)

So if I have to use a module to extend the world (even though the  
documentation seems to point at this being right) how do I go about  
doing this?
