cucumber and capybara, how to open external url or visit outside url

i am using cucumber and capybara. in a rails 3.0.9 platform. i am getting this test case fail: log is:

(::) failed steps (::)

No route matches "/wiki/Baltimore_Ravens" (ActionController::RoutingError)
<internal:prelude>:10:in `synchronize'
./features/step_definitions/web_steps.rb:20:in `/^(?:|I )am on (.+)$/'
features/annotate.feature:7:in `Given I am on a web page'

Failing Scenarios:
cucumber features/annotate.feature:11 # Scenario: launch annotation/ logged in

6 scenarios (1 failed, 5 skipped)
63 steps (1 failed, 62 skipped)

the file web_steps: got this piece of code:

19 Given /^(?:|I )am on (.+)$/ do |page_name|
20   visit path_to(page_name)
21 end

the file annotate.feature got this code:

7 Given I am on a web page

"a web page" is defined in support/paths.rb as:

when /a web page/

obviously this is an external url. i want to open it and capybara and cucumber wont allow me to do it. so, help me find a way to open outside url in cucumber test case!


Capybara uses RackTest as the default driver, and this driver doesn't allow to visit external urls (i.e. test remote applications).

If you want to visit external urls (to test, e.g, that your app redirects correctly), you have basically two options:

1/ Use another driver like e.g selenium:

before do
  Capybara.current_driver = :selenium

Then, in code, you can call the url like so:

visit ''

Or, if you set the default app_host like so:

Capybara.app_host = ''
Capybara.run_server = false # don't start Rack

Then you can call the url:

visit '/wiki/Baltimore_Ravens'

You can configure the driver and app host in your spec_helper.rb to enable them globally across all you specs:

Capybara.configure do |config|
  config.current_driver = :selenium
  config.run_server = false
  config.app_host   = ''

2/ Use capybara-mechanize

Need Your Help

Print numbers in range of two user-input values with while loop

c++ math while-loop range cout

I feel like I might be missing something here, but something is telling me that I might just be making this more difficult that it has to be, but from the book, "C++ Primer, 5th ed.," I'm stuck on ...

WCF service for receiving image

.net wcf web-services image

What is the best way to create a webservice for accepting an image.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.