Skip to content

Instantly share code, notes, and snippets.

@diabolo
diabolo / sample cucumber.yml
Created June 10, 2011 06:12
apremdas@yahoo.co.uk
# Running all features
# default runs all webrat features
<%
def_r = " -r features/support/env.rb -r features/step_definitions features "
def_f = " --format pretty "
def_t = " --tags ~@wip --tags ~@pending --tags ~@selenium"
def_opts = "#{def_r} #{def_f} #{def_t}"
use_webrat = "-r features/support/webrat.rb"
use_selenium_rc = "-r features/support/selenium_rc.rb"
@diabolo
diabolo / gist:989180
Created May 24, 2011 17:23
installing rspec with rvm
[andy@mini-un ~/Sites] (master)
➥ rvm use --create 1.9.2@test_rspec
Using /Users/andy/.rvm/gems/ruby-1.9.2-p180 with gemset test_rspec
[andy@mini-un ~/Sites] (master) ❷@test_rspec
➥ gem install rspec
Fetching: rspec-core-2.6.3.gem (100%)
Fetching: diff-lcs-1.1.2.gem (100%)
Fetching: rspec-expectations-2.6.0.gem (100%)
Fetching: rspec-mocks-2.6.0.gem (100%)
Fetching: rspec-2.6.0.gem (100%)
@diabolo
diabolo / foobar_steps.rb
Created May 6, 2011 12:40
Working with multi-step interfaces in Cucumber
def foo
# do whatever you need to do
end
def bar
# do whatever you need to do
end
def foobar
foo
bar
end
@diabolo
diabolo / json
Created April 12, 2011 13:58
sport refresh - single story, rdf
{
"headline" => "Test story",
"url" => "http://news.bbc.co.uk/sport/football",
"intro" => "This is the introduction",
"lastUpdated" => "10:57 GMT, 08/10/10",
"imageUrl" => "http://news.bbcimg.co.uk/media/images/48353000/jpg/_48353797_fabregas_getty226x170.jpg",
"imageAlt" => "This is an alt"
}
# Running all features
# default runs all webrat features
<%
def_r = " -r features/support/env.rb -r features/step_definitions features "
def_f = " --format pretty "
def_t = " --tags ~@wip --tags ~@pending --tags ~@selenium"
def_opts = "#{def_r} #{def_f} #{def_t}"
use_webrat = "-r features/support/webrat.rb"
use_selenium_rc = "-r features/support/selenium_rc.rb"
require 'spec_helper'
module PriceBandSpecHelper
def valid_attributes
{
:start_margin => 10,
:end_margin => 30
}
end
end
class CategoriesController < ApplicationController
before_filter :find_category, :only => [:show]
before_filter :ensure_current_post_url, :only => :show
def show
@products = @category.products.paginate :page => params[:page], :order => Product.pagination_ordering(session[:prefs][:product_sort]) if @category
end
private
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)
# 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)
config.after_initialize do
AppConfig.gateway = ActiveMerchant::Billing::AxiarGateway.new(:login => 'test', :password => 'test', :mode => self.gateway_mode)
end