Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include Capybara into module in Cucumber project

I defined a module:

module Support
  include Capybara::DSL

  def self.do_something
    click_link 'Questions'
  end
end

It's situated at features/support/support.rb

My env.rb:

require 'capybara'
require 'cucumber'
require 'capybara/cucumber'

Capybara.app_host = "http://www.stackoverflow.com"
Capybara.run_server = false
Capybara.default_driver = :selenium

I invoke function of module in steps.rb:

Support::do_something

And I have exception:

undefined method `click_link' for Support:Module (NoMethodError)

How can I make Capybara available in Support module?

like image 786
Andrei Botalov Avatar asked Dec 27 '12 16:12

Andrei Botalov


People also ask

What is Capybara cucumber?

cucumber is a BDD tool that expresses testing scenarios in a business-readable, domain-specific language. capybara is an automated testing tool (often used) for ROR applications.

What is Capybara gem in rails?

Capybara is an integration testing tool for rack based web applications. It simulates how a user would interact with a website.


1 Answers

Capybara should be extend-ed, not include-ed:

module Support
  extend Capybara::DSL

  def self.do_something
    click_link 'Questions'
  end
end
like image 111
Andrei Botalov Avatar answered Oct 12 '22 13:10

Andrei Botalov