Skip to content

Instantly share code, notes, and snippets.

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
require 'spec_helper'
module PriceBandSpecHelper
def valid_attributes
{
:start_margin => 10,
:end_margin => 30
}
end
end
# 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 / 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"
}
@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 / 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%)
# 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 / Gemfile
Created June 27, 2011 17:22
Spork Cucumber Fail
source 'http://rubygems.org'
gem 'rails', '3.1.0.rc4'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
# Asset template engines
@diabolo
diabolo / bdd.vim
Created December 4, 2011 13:01
Run RSpec and Cucumber from vim, on the current spec/feature
" Vim functions to run RSpec and Cucumber on the current file and optionally on
" the spec/scenario under the cursor.
function! RailsScriptIfExists(name)
" Bundle exec
if isdirectory(".bundle") || (exists("b:rails_root") && isdirectory(b:rails_root . "/.bundle"))
return "bundle exec " . a:name
" System Binary
else
return a:name
@diabolo
diabolo / bad_step_def.rb
Created July 13, 2012 05:00
Don't use variables in step_defs
require 'rubygems'
require 'mechanize'
require 'json'
module ApiExtensions
@agent = Mechanize.new
@api_header = {'Accept' => 'application/json', 'Content-Type' => 'application/json'}
@api_uris = {
'the list of campuses' => 'http://example.com/servicehosts/campus.svc',