From: tamouse mailing lists Date: 2013-06-08T04:59:17+09:00 Subject: Use of capybara outside of any application I'm trying to set up a cucumber/capybara test suite that I can use outside of my rails app to drive testing from the outside in. I've been reading through the capy README and thought I understood this, but apparently I'm just missing something fundamental. I am starting with just this simple file: tamara@monovular Test/cukecapytest$ cat justtestit.rb require 'capybara' require 'capybara/dsl' Capybara.default_driver = :selenium Capybara.current_driver = :selenium Capybara.run_server = false Capybara.app_host = "http://www.google.com" module JustTestIt include Capybara::DSL def self.run visit '/' end end JustTestIt.run tamara@monovular Test/cukecapytest$ ruby justtestit.rb justtestit.rb:10:in `run': undefined method `visit' for JustTestIt:Module (NoMethodError) from justtestit.rb:14:in `
' I thought doing the include would bring in the methods. When I do the include and visit without the module warpper, I get a warning about including Capybara::DSL in the global context, BUT, the visit works in that case. tamara@monovular Test/cukecapytest$ cat justtestitnomod.rb require 'capybara' require 'capybara/dsl' Capybara.default_driver = :selenium Capybara.current_driver = :selenium Capybara.run_server = false Capybara.app_host = "http://www.google.com" include Capybara::DSL def run visit '/' end run tamara@monovular Test/cukecapytest$ ruby justtestitnomod.rb including Capybara::DSL in the global scope is not recommended! and it brings up a browser, goes to http://www.google.com/ as expected. So there is something here I'm just not getting (not a capybara problem, but a basic understanding of how the mixin works??) halp?