You are using cucumber for your tests and you would like to use the modal dialog confirmation box in a rails application, with capybara but you are getting the following error:
Modal dialog present Selenium::WebDriver::Error::UnhandledAlertError)
In your steps file use the following to accept (press OK), in the confirmation dialog that pops up:
NOTE: Or in more recent versions when the above complains for ‘undefined method wait_until’
NOTE: Taken from the second comment made here
You are trying to use Webrat with a new Rails 3.0.3 application but the redirection doesn’t work, and you get an error like:
You are being redirected. (RSpec::Expectations::ExpectationNotMetError)
According to a post here, there is a way to patch the webrat code so it follows the redirection.
After adding what is suggested above into your
#starting at line 288
- URI.parse(current_url).host || @custom_headers["Host"] ||
+ URI.parse(current_url).host || @custom_headers["Host"] ||
+ def default_current_host
+ adapter.class==Webrat::RackAdapter ? "example.org" :
and running your tests again, they should work.
Thanks yannnimac 🙂
When using Cucumber and Webrat in a ruby on rails 3 application you see the error:
undefined method `visit' for #<:rails::world:0x..fdb6d16e4> (NoMethodError) and your scenario fails.
Replace the line:
config.mode = :rails
with the line:
config.mode = :rack
in the Webrat.configure block, in your
You would like to start using BDD in a new Ruby on Rails 3 application, and would like to install Webrat, Cucumber and RSpec to your project.
Follow the steps below (taken from the RSpec Book), for creating a new Rails 3 application and adding the necessary testing frameworks:
- Create your new ruby on rails application:
rails new my_app
- Go to your new application directory:
- Edit your Gemfile to include the following:
group :development, :test do
gem "rspec-rails", ">= 2.0.0"
gem "cucumber-rails", ">= 0.3.2"
gem "webrat", ">= 0.7.2"
- Use bundler to install all the gems and dependencies:
- Install the rspec files:
script/rails generate rspec:install
- Install the cucumber files:
script/rails generate cucumber:install
- Run the following and you shouldn’t be seeing any errors: