Created
July 11, 2011 16:48
-
-
Save caspian311/1076251 to your computer and use it in GitHub Desktop.
How to setup cucumber for non-rails web apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------------------------------------------------------- | |
RVM Install | |
------------------------------------------------------------------------------- | |
$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm) | |
$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile | |
$ source .bash_profile | |
$ type rvm | head -1 | |
(should return "rvm in a function") | |
$ sudo apt-get install -y build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev | |
$ rvm install 1.9.2 | |
$ rvm use 1.9.2 --default | |
------------------------------------------------------------------------------- | |
Cucumber Install | |
------------------------------------------------------------------------------- | |
$ gem install cucumber capybara rspec bundler | |
------------------------------------------------------------------------------- | |
Project setup | |
------------------------------------------------------------------------------- | |
<top-level-directory> | |
config/ | |
cucumber.yml | |
features/ | |
support/ | |
env.rb | |
something_module.rb | |
step_definitions/ | |
page_steps.rb | |
something.feature | |
------------------------------------------------------------------------------- | |
config/cucumber.yml | |
------------------------------------------------------------------------------- | |
default: --tags ~@wip --format progress --format junit --out=path/to/junit/reports | |
wip: --tags @wip --format progress | |
------------------------------------------------------------------------------- | |
features/support/env.rb | |
------------------------------------------------------------------------------- | |
require 'rubygems' | |
require 'rspec' | |
require 'bundler/setup' | |
require 'capybara/cucumber' | |
$LOAD_PATH.push File.dirname(__FILE__) | |
require 'something_module' | |
Capybara.register_driver :selenium do |app| | |
Capybara::Selenium::Driver.new(app, :browser => :chrome) | |
end | |
Capybara.default_selector = :css | |
Capybara.default_driver = :selenium | |
Capybara.app_host = 'localhost:8080' | |
Capybara.run_server = false | |
World(SomethingModule) | |
------------------------------------------------------------------------------- | |
features/step_definitions/page_steps.rb | |
------------------------------------------------------------------------------- | |
When /^I go to the "([^"]*)" page$/ do |page| | |
visit path_to(page) | |
end | |
Then /^I should see "([^"]*)"$/ do |text| | |
page.should have_content(text) | |
end | |
And /^I don't fill in anything$/ do | |
end | |
And /^I fill in "([^"]*)" with "([^"]*)"$/ do |field, value| | |
fill_in(field, :with => value) | |
end | |
And /^I press "([^"]*)"$/ do |button| | |
click_button(button) | |
end | |
------------------------------------------------------------------------------- | |
features/support/something_module.rb | |
------------------------------------------------------------------------------- | |
module SomethingModule | |
def path_to(page_name) | |
page = '' | |
if page_name == 'home' | |
page = '/' | |
elsif page_name == 'foo' | |
page = '/bar' | |
end | |
"/#{page}" | |
end | |
end | |
------------------------------------------------------------------------------- | |
Run cukes! | |
------------------------------------------------------------------------------- | |
$ cucumber |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment