Skip to content

Instantly share code, notes, and snippets.

@diabolo
diabolo / Cucumber.haml
Created January 30, 2009 04:33
Possible html output for cucumber
.comment
Comments in this file are this color and wrapped in a "div class="comment"". There not expected to be in the output
.run
.info
date command project etc.
.summary
%h3
Summary
%span (click on any summary item to go the step)
Feature: Background
In for background to work properly
As a user
I want it to run transactionally and only once when I call an individual scenario
Background:
Given plop
Scenario: Barping
When I barp
Background:
Given an admin user Philip exists
When I login as Philip
Then I should be logged in as Philip
Scenario Outline: Admin can view resources
Given there are 3 <object>
When I goto admin_<collection>
Then I should see a list of <item>
require 'cucumber/rake/task'
namespace :cucumber do
Cucumber::Rake::Task.new(:webrat) do |t|
t.fork = true # Explicitly fork for cucumber 0.3.4 and rails
t.cucumber_opts = "--format progress"
t.step_list = %w{features/support/env.rb features/support/webrat.rb features/step_definitions}
t.feature_list = %w{features/webrat}
end
task :webrat => 'db:test:prepare'
describe Customer, "last billing address" do
before do
@customer = Customer.generate!
@customer = Address.new
end
it "should be settable and gettable" do
@customer.last_billing_address = @account_address
@customer.last_billing_address.should == @account_address
end
...
require 'rubygems'
require 'spork'
Spork.prefork do
# Sets up the Rails environment for Cucumber
ENV["RAILS_ENV"] = "cucumber"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "textmate_formatter"))
config.after_initialize do
MVOR::Gateway.use_3ds_test_gateway
end
config.after_initialize do
AppConfig.gateway = ActiveMerchant::Billing::AxiarGateway.new(:login => 'test', :password => 'test', :mode => self.gateway_mode)
end
# config/cucumber.yml
default: --tags ~@wip
new: --tags @wip:2 --wip
# see cucumber-rails wiki for interesting ways to use this file to run cucumber how you want (link here)
module UserStepHelper
def user_fill_in_login(name, password=nil)
login = name =~ /@/ ? name : remove_non_ascii(name)+'@example.com'
login.downcase!
password ||= name + 'pass'
fill_in('login', :with => login)
fill_in('password', :with => password)
end
def user_fill_in_signup(name)