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
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 |
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
class Admin::BaseController < ApplicationController | |
before_filter :require_admin | |
protected | |
def require_admin | |
redirect_to error_path(403) unless current_user.is_administrator? | |
end | |
end |
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
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 |
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
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 |
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
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 |
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
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' |
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
#! /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| |
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
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 |
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
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 |
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
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 |
OlderNewer