Skip to content

Instantly share code, notes, and snippets.

View phillipkoebbe's full-sized avatar

Phillip Koebbe phillipkoebbe

  • Carlinville, IL
View GitHub Profile
module ControllerMacros
def should_set_session(key, options = {})
it "should set session[:#{key}]" do
value = get_value_from_options(options)
if value
session[key].should == value
else
session[key].should_not be_nil
end
class Admin::BaseController < ApplicationController
before_filter :require_admin
protected
def require_admin
redirect_to error_path(403) unless current_user.is_administrator?
end
end
Given I am on the available_sports page
When I click the new_available_sport link
Then there should be an available_sport_form form
And the available_sport_name text_field should be empty
And the available_sport_name text_field should be focused
Then /^the ([^ ]+) ([^ ]+) (should|should not) be (enabled|visible|empty|focused)$/ do |what, type, expectation, state|
e = expectation.gsub(' ', '_')
send("element_#{e}_be_#{state}", type, what)
end
describe SessionsController do
it "should use SessionsController" do
controller.should be_an_instance_of(SessionsController)
end
describe 'request security' do
request_should_succeed(:get, :login, :logout)
request_should_succeed(:post, :login)
end
class Receipt < ActiveRecord::Base
private
def calculate_total
self.total = (self.sub_total || 0.0) + (self.tax_1 || 0.0) + (self.tax_2 || 0.0)
end
end
Feature: Registration
Background:
Given I am not logged in
And I am on the register page
Scenario Outline: A new registration - variations of valid emails
When I fill in user_first_name with 'New'
#! /usr/bin/env ruby
require 'optparse'
# This hash will hold all of the options
# parsed from the command-line by
# OptionParser.
$options = {}
optparse = OptionParser.new do |opts|
Feature: Registration Email Validation
Background:
Given I am not logged in
And I am on the register page
@1
Scenario Outline: A new registration - variations of valid emails
require 'culerity'
def culerity_startup
$rails_server ||= Culerity::run_rails(:environment => 'culerity_development', :port => 3001)
$server ||= Culerity::run_server
@host = 'http://localhost:3001'
ActionMailer::Base.clear_deliveries
end
def culerity_shutdown
begin
require File.dirname(__FILE__) + '/../../../../spec/spec_helper'
rescue LoadError
puts "You need to install rspec in your base app"
exit
end
ActionController::Routing::Routes.draw do |map|
map.resources :things
end