code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
Rottenpotatoes::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart th... | Ruby |
Rottenpotatoes::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for th... | Ruby |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Rottenpotatoes::Application.initialize!
| Ruby |
require 'rubygems'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
| Ruby |
require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
if defined?(Bundler)
# If you precompile... | Ruby |
Rottenpotatoes::Application.routes.draw do
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# match... | Ruby |
Autotest.add_discovery { "rails" }
Autotest.add_discovery { "rspec2" }
| Ruby |
# TL;DR: YOU SHOULD DELETE THIS FILE
#
# This file is used by web_steps.rb, which you should also delete
#
# You have been warned
module HtmlSelectorsHelpers
# Maps a name to a selector. Used primarily by the
#
# When /^(.+) within (.+)$/ do |step, scope|
#
# step definitions in web_steps.rb
#
def selec... | Ruby |
# TL;DR: YOU SHOULD DELETE THIS FILE
#
# This file is used by web_steps.rb, which you should also delete
#
# You have been warned
module NavigationHelpers
# Maps a name to a path. Used by the
#
# When /^I go to (.+)$/ do |page_name|
#
# step definition in web_steps.rb
#
def path_to(page_name)
case p... | Ruby |
Given /the following movies exist/ do |movies_table|
movies_table.hashes.each do |movie|
Movie.create!(movie)
end
assert movies_table.hashes.size == Movie.all.count
end
Then /I should see "(.*)" before "(.*)"/ do |e1, e2|
titles = page.all("table#movies tbody tr td[1]").map {|t| t.text}
asse... | Ruby |
# Add a declarative step here for populating the DB with movies.
Given /the following movies exist/ do |movies_table|
movies_table.hashes.each do |movie|
Movie.create!(movie)
end
assert movies_table.hashes.size == Movie.all.count
end
# Make sure that one string (regexp) occurs before or after another one
# ... | Ruby |
module ApplicationHelper
end
| Ruby |
module MoviesHelper
# Checks if a number is odd:
def oddness(count)
count.odd? ? "odd" : "even"
end
end
| Ruby |
class Movie < ActiveRecord::Base
def self.all_ratings
%w(G PG PG-13 NC-17 R)
# is a shortcut for
#['G', 'PG', 'PG-13', 'R']
end
end
| Ruby |
class MoviesController < ApplicationController
def initialize
super
@all_ratings = Movie.all_ratings
end
#bwacek solution
def show
id = params[:id] # retrieve movie ID from URI route
@movie = Movie.find(id) # look up movie by unique ID
# will render app/views/movies/show.<extension> by d... | Ruby |
class ApplicationController < ActionController::Base
protect_from_forgery
end
| Ruby |
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rottenpotatoes::Application.load_tasks
| Ruby |
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
| Ruby |
#!/usr/bin/env ruby
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
if vendored_cucumber_bin
load File.expand_path(vendored_cucumber_bin)
else
require 'rubygems' unless ENV['NO_RUBYGEMS']
require 'cucumber'
load Cucumber::BINARY
end
| Ruby |
#!/usr/bin/env ruby
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
if vendored_cucumber_bin
load File.expand_path(vendored_cucumber_bin)
else
require 'rubygems' unless ENV['NO_RUBYGEMS']
require 'cucumber'
load Cucumber::BINARY
end
| Ruby |
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
| Ruby |
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rottenpotatoes::Application.load_tasks
| Ruby |
source 'http://rubygems.org'
gem 'rails', '3.1.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# for Heroku deployment - as described in Ap. A of ELLS book
group :development, :test do
gem 'sqlite3'
gem 'ruby-debug19', :require => 'ruby-debug'
gem 'cucumber-rails'
... | Ruby |
class CreateMovies < ActiveRecord::Migration
def up
create_table :movies do |t|
t.string :title
t.string :rating
t.text :description
t.datetime :release_date
# Add fields that let Rails automatically keep track
# of when movies are added or modified:
t.timestamps
end
... | Ruby |
class AddMoreMovies < ActiveRecord::Migration
MORE_MOVIES = [
{:title => 'Aladdin', :rating => 'G', :release_date => '25-Nov-1992'},
{:title => 'The Terminator', :rating => 'R', :release_date => '26-Oct-1984'},
{:title => 'When Harry Met Sally', :rating => 'R', :release_date => '21-Jul-1989'},
{:title... | Ruby |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rottenpotatoes::Application
| Ruby |
class CartesianProduct
include Enumerable
attr_accessor :res
def initialize(a, b)
@res = []
a.each {|x| b.each {|y| @res.push([x, y])}}
@res
end
def each
for i in 0...@res.length
yield @res[i]
end
#@res.each(|x| yield(x))
end
# your code here
end
c = CartesianProduct.ne... | Ruby |
# metaprogramming to the rescue!
class Numeric
@@currencies = {'yen' => 0.013, 'euro' => 1.292, 'rupee' => 0.019, 'dollar'=> 1}
def method_missing(method_id, *arguments, &block)
singular_currency = method_id.to_s.gsub( /s$/, '')
if @@currencies.has_key?(singular_currency)
self * @@currencies[s... | Ruby |
class CartesianProduct
include Enumerable
attr_accessor :res
def initialize(a, b)
@res = []
a.each {|x| b.each {|y| @res.push([x, y])}}
@res
end
def each
for i in 0...@res.length
yield @res[i]
end
#@res.each(|x| yield(x))
end
# your code here
end
c = CartesianProduct.ne... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', ... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
| Ruby |
# Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attac... | Ruby |
# Be sure to restart your server when you modify this file.
#
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters ... | Ruby |
# Be sure to restart your server when you modify this file.
Rottenpotatoes::Application.config.session_store :cookie_store, key: '_rottenpotatoes_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table... | Ruby |
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a probl... | Ruby |
Rottenpotatoes::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config... | Ruby |
Rottenpotatoes::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart th... | Ruby |
Rottenpotatoes::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for th... | Ruby |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Rottenpotatoes::Application.initialize!
| Ruby |
require 'rubygems'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
| Ruby |
require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
if defined?(Bundler)
# If you precompile... | Ruby |
Rottenpotatoes::Application.routes.draw do
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# match... | Ruby |
Autotest.add_discovery { "rails" }
Autotest.add_discovery { "rspec2" }
| Ruby |
# TL;DR: YOU SHOULD DELETE THIS FILE
#
# This file is used by web_steps.rb, which you should also delete
#
# You have been warned
module HtmlSelectorsHelpers
# Maps a name to a selector. Used primarily by the
#
# When /^(.+) within (.+)$/ do |step, scope|
#
# step definitions in web_steps.rb
#
def selec... | Ruby |
# TL;DR: YOU SHOULD DELETE THIS FILE
#
# This file is used by web_steps.rb, which you should also delete
#
# You have been warned
module NavigationHelpers
# Maps a name to a path. Used by the
#
# When /^I go to (.+)$/ do |page_name|
#
# step definition in web_steps.rb
#
def path_to(page_name)
case p... | Ruby |
# Add a declarative step here for populating the DB with movies.
Given /the following movies exist/ do |movies_table|
movies_table.hashes.each do |movie|
Movie.create!(movie)
end
assert movies_table.hashes.size == Movie.all.count
end
# Make sure that one string (regexp) occurs before or after another one
# ... | Ruby |
module ApplicationHelper
end
| Ruby |
module MoviesHelper
# Checks if a number is odd:
def oddness(count)
count.odd? ? "odd" : "even"
end
end
| Ruby |
class Movie < ActiveRecord::Base
def self.all_ratings
%w(G PG PG-13 NC-17 R)
end
end
| Ruby |
class MoviesController < ApplicationController
def show
id = params[:id] # retrieve movie ID from URI route
@movie = Movie.find(id) # look up movie by unique ID
# will render app/views/movies/show.<extension> by default
end
def index
sort = params[:sort] || session[:sort]
case sort
when ... | Ruby |
class ApplicationController < ActionController::Base
protect_from_forgery
end
| Ruby |
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rottenpotatoes::Application.load_tasks
| Ruby |
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
| Ruby |
#!/usr/bin/env ruby
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
if vendored_cucumber_bin
load File.expand_path(vendored_cucumber_bin)
else
require 'rubygems' unless ENV['NO_RUBYGEMS']
require 'cucumber'
load Cucumber::BINARY
end
| Ruby |
#!/usr/bin/env ruby
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
if vendored_cucumber_bin
load File.expand_path(vendored_cucumber_bin)
else
require 'rubygems' unless ENV['NO_RUBYGEMS']
require 'cucumber'
load Cucumber::BINARY
end
| Ruby |
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
| Ruby |
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rottenpotatoes::Application.load_tasks
| Ruby |
source 'http://rubygems.org'
gem 'rails', '3.1.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# for Heroku deployment - as described in Ap. A of ELLS book
group :development, :test do
gem 'sqlite3'
gem 'ruby-debug19', :require => 'ruby-debug'
gem 'cucumber-rails'
... | Ruby |
class CreateMovies < ActiveRecord::Migration
def up
create_table :movies do |t|
t.string :title
t.string :rating
t.text :description
t.datetime :release_date
# Add fields that let Rails automatically keep track
# of when movies are added or modified:
t.timestamps
end
... | Ruby |
class AddDirectorToMovies < ActiveRecord::Migration
def change
add_column :movies, :director, :string
end
end
| Ruby |
class AddMoreMovies < ActiveRecord::Migration
MORE_MOVIES = [
{:title => 'Aladdin', :rating => 'G', :release_date => '25-Nov-1992'},
{:title => 'The Terminator', :rating => 'R', :release_date => '26-Oct-1984'},
{:title => 'When Harry Met Sally', :rating => 'R', :release_date => '21-Jul-1989'},
{:title... | Ruby |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | Ruby |
require 'simplecov'
SimpleCov.start 'rails'
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
# Requires supporting ruby files with custom matchers and macr... | Ruby |
require 'spec_helper'
describe MoviesController do
describe 'searching TMDb' do
before :each do
@fake_results = [mock('movie1'), mock('movie2')]
end
it 'should call the model method that performs TMDb search' do
Movie.should_receive(:find_in_tmdb).with('hardware').
and_return(@fake_r... | Ruby |
require 'spec_helper'
describe MoviesController do
describe 'searching TMDb' do
it 'should call the model method that performs TMDb search' do
Movie.should_receive(:find_in_tmdb).with('hardware')
post :search_tmdb, {:search_terms => 'hardware'}
end
end
end
| Ruby |
require 'spec_helper'
describe MoviesController do
describe 'searching TMDb' do
it 'should call the model method that performs TMDb search'
it 'should select the Search Results template for rendering'
it 'should make the TMDb search results available to that template'
end
end
| Ruby |
require 'spec_helper'
describe MoviesController do
describe 'searching TMDb' do
it 'should call the model method that performs TMDb search' do
Movie.should_receive(:find_in_tmdb).with('hardware')
post :search_tmdb, {:search_terms => 'hardware'}
end
end
end
| Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rottenpotatoes::Application
| Ruby |
class Dessert
attr_accessor :name, :calories
def initialize(name, calories)
@name, @calories = name, calories
end
def healthy?
@calories < 200
end
def delicious?
true
end
end
class JellyBean < Dessert
attr_accessor :flavor
def initialize(name, calories, flavor)
super(name, calories)
@flavor = flavo... | Ruby |
class Dessert
attr_accessor :name, :calories
def initialize(name, calories)
@name, @calories = name, calories
end
def healthy?
@calories < 200
end
def delicious?
true
end
end
class JellyBean < Dessert
attr_accessor :flavor
def initialize(name, calories, flavor)
super.initialize(name, calories)
@fla... | Ruby |
def anagrams?(a, b)
a.downcase.split(//).sort === b.downcase.split(//).sort
end
def combine_anagrams(words)
b = []
words.each do |x|
found = false
if b.length === 0
b.push([x])
else
b.each do |y|
if anagrams?(x, y[0])
found = true
if !(x === y[0])
y.push(x)... | Ruby |
class Class
def attr_accessor_with_history(attr_name)
attr_name = attr_name.to_s # make sure it's a string
attr_reader attr_name # create the attribute's getter
attr_reader attr_name+"_history" # create bar_history getter
class_eval %{
def #{attr_name}=(val)
@#{attr_name} = val
@#{attr_name}... | Ruby |
class WrongNumberOfPlayersError < StandardError ; end
class WrongNumberOfElementsError < StandardError ; end
class NoSuchStrategyError < StandardError ; end
def players_number_check(game)
raise WrongNumberOfPlayersError unless game.length == 2
true
end
def elements_number_check(game)
game.each{|x| raise Wron... | Ruby |
class Dessert
attr_accessor :name, :calories
def initialize(name, calories)
@name, @calories = name, calories
end
def healthy?
@calories < 200
end
def delicious?
true
end
end
class JellyBean < Dessert
attr_accessor :flavor
def initialize(name, calories, flavor)
super(name, calories)
@flavor = flavo... | Ruby |
#Part 1: fun with strings. a)
def palindrome?(string)
s = string.downcase.gsub(/\W/, "")
s == s.reverse
end
#Part 1: fun with strings. b)
def count_words(string)
hsh = Hash.new(0)
a = string.downcase.split(/\b/).map{|x| x.gsub(/\W/, "")}
a.delete("")
a.each{|x| hsh[x] += 1 }
hsh
end | Ruby |
class WrongNumberOfPlayersError < StandardError ; end
class NoSuchStrategyError < StandardError ; end
def strategy_check(game)
game.each{|x| s = x[1].downcase
raise NoSuchStrategyError unless (s == 'r') or (s == 's') or (s == 'p')}
true
end
def winner(a, b)
q = a[1].downcase
w = b[1].downcase
if q == w... | Ruby |
class Dessert
attr_accessor :name, :calories
def initialize(name, calories)
@name, @calories = name, calories
end
def healthy?
@calories < 200
end
def delicious?
true
end
end
class JellyBean < Dessert
attr_accessor :flavor
def initialize(name, calories, flavor)
super.initialize(name, calories)
@fla... | Ruby |
#Part 1: fun with strings. a)
def palindrome?(string)
s = string.downcase.gsub(/\W/, "")
s == s.reverse
end
#Part 1: fun with strings. b)
def count_words(string)
hsh = Hash.new(0)
a = string.downcase.split(/\b/).map{|x| x.gsub(/\W/, "")}
a.delete("")
a.each{|x| hsh[x] += 1 }
hsh
end
count_words("1... | Ruby |
def anagrams?(a, b)
a.downcase.split(//).sort === b.downcase.split(//).sort
end
def combine_anagrams(words)
b = []
words.each do |x|
found = false
if b.length === 0
b.push([x])
else
b.each do |y|
if anagrams?(x, y[0])
found = true
y.push(x)
break
end
... | Ruby |
class WrongNumberOfPlayersError < StandardError ; end
class WrongNumberOfElementsError < StandardError ; end
class NoSuchStrategyError < StandardError ; end
def players_number_check(game)
raise WrongNumberOfPlayersError unless game.length == 2
true
end
def elements_number_check(game)
game.each{|x| raise Wron... | Ruby |
class WrongNumberOfPlayersError < StandardError ; end
class WrongNumberOfElementsError < StandardError ; end
class NoSuchStrategyError < StandardError ; end
def players_number_check(game)
raise WrongNumberOfPlayersError unless game.length == 2
true
end
def elements_number_check(game)
game.each{|x| raise Wron... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person',... | Ruby |
# Be sure to restart your server when you modify this file.
# These settings change the behavior of Rails 2 apps and will be defaults
# for Rails 3. You can remove this initializer when Rails 3 is released.
if defined?(ActiveRecord)
# Include Active Record class name as root for JSON serialized output.
ActiveReco... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
| Ruby |
# Be sure to restart your server when you modify this file.
# Your secret key for verifying cookie session data integrity.
# If you change this key, all old sessions will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
Act... | Ruby |
# A Site key gives additional protection against a dictionary attack if your
# DB is ever compromised. With no site key, we store
# DB_password = hash(user_password, DB_user_salt)
# If your database were to be compromised you'd be vulnerable to a dictionary
# attack on all your stupid users' passwords. With a site... | Ruby |
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying do debug a probl... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.action_controller.consider_all_reque... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.ca... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between... | Ruby |
# Be sure to restart your server when you modify this file
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.3' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
... | Ruby |
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end
def booted?
... | Ruby |
ActionController::Routing::Routes.draw do |map|
map.logout '/logout', :controller => 'sessions', :action => 'destroy'
map.login '/login', :controller => 'sessions', :action => 'new'
map.register '/register', :controller => 'users', :action => 'create'
map.signup '/signup', :controller => 'users', :action => 'ne... | Ruby |
#
# Where to go
#
#
# GET
# Go to a given page.
When "$actor goes to $path" do |actor, path|
case path
when 'the home page' then get '/'
else get path
end
end
# POST -- Ex:
# When she creates a book with ISBN: '0967539854' and comment: 'I love this book' and rating: '4'
# When she cre... | Ruby |
# The flexible code for resource testing came out of code from Ben Mabey
# http://www.benmabey.com/2008/02/04/rspec-plain-text-stories-webrat-chunky-bacon/
#
# Construct resources
#
#
# Build a resource as described, store it as an @instance variable. Ex:
# "Given a user with login: 'mojojojo'"
# produces a User in... | Ruby |
Before do
Fixtures.reset_cache
fixtures_folder = File.join(RAILS_ROOT, 'spec', 'fixtures')
Fixtures.create_fixtures(fixtures_folder, "users")
end
# Make visible for testing
ApplicationController.send(:public, :logged_in?, :current_user, :authorized?)
| Ruby |
# If you have a global stories helper, move this line there:
include AuthenticatedTestHelper
# Most of the below came out of code from Ben Mabey
# http://www.benmabey.com/2008/02/04/rspec-plain-text-stories-webrat-chunky-bacon/
# These allow exceptions to come through as opposed to being caught and having non-helpful... | Ruby |
#
# What you should see when you get there
#
#
# Destinations. Ex:
# She should be at the new kids page
# Tarkin should be at the destroy alderaan page
# The visitor should be at the '/lolcats/download' form
# The visitor should be redirected to '/hi/mom'
#
# It doesn't know anything about actual routes -- it... | Ruby |
RE_User = %r{(?:(?:the )? *(\w+) *)}
RE_User_TYPE = %r{(?: *(\w+)? *)}
#
# Setting
#
Given "an anonymous user" do
log_out!
end
Given "$an $user_type user with $attributes" do |_, user_type, attributes|
create_user! user_type, attributes.to_hash_from_story
end
Given "$an $user_type user named '$login'" do |... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.