Skip to content
This repository has been archived by the owner on Mar 29, 2018. It is now read-only.

Commit

Permalink
Set up RSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
nbudin committed Sep 21, 2010
1 parent 49ed082 commit 83be669
Show file tree
Hide file tree
Showing 28 changed files with 463 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
pkg/*
spec/scenario/db/*.sqlite3
spec/scenario/tmp/*
14 changes: 14 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
source "http://rubygems.org"

gemspec

gem 'rails', '3.0.0'
gem "rspec", ">= 2.0.0.beta.17"
gem "rspec-rails", ">= 2.0.0.beta.17"
gem "mocha"
gem "shoulda"
gem "sqlite3-ruby"
gem "sham_rack"
gem "webrat"
gem "ruby-debug"
gem "jeweler"
137 changes: 137 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
PATH
remote: .
specs:
devise_cas_authenticatable (1.0.0.alpha3)
devise (>= 1.0.6)
rubycas-client (~> 2.1.0)

GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.0)
actionpack (= 3.0.0)
mail (~> 2.2.5)
actionpack (3.0.0)
activemodel (= 3.0.0)
activesupport (= 3.0.0)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4.1)
rack (~> 1.2.1)
rack-mount (~> 0.6.12)
rack-test (~> 0.5.4)
tzinfo (~> 0.3.23)
activemodel (3.0.0)
activesupport (= 3.0.0)
builder (~> 2.1.2)
i18n (~> 0.4.1)
activerecord (3.0.0)
activemodel (= 3.0.0)
activesupport (= 3.0.0)
arel (~> 1.0.0)
tzinfo (~> 0.3.23)
activeresource (3.0.0)
activemodel (= 3.0.0)
activesupport (= 3.0.0)
activesupport (3.0.0)
arel (1.0.1)
activesupport (~> 3.0.0)
bcrypt-ruby (2.1.2)
builder (2.1.2)
columnize (0.3.1)
devise (1.1.2)
bcrypt-ruby (~> 2.1.2)
warden (~> 0.10.7)
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
gemcutter (0.6.1)
git (1.2.5)
i18n (0.4.1)
jeweler (1.4.0)
gemcutter (>= 0.1.0)
git (>= 1.2.5)
rubyforge (>= 2.0.0)
json_pure (1.4.6)
linecache (0.43)
mail (2.2.6.1)
activesupport (>= 2.3.6)
mime-types
treetop (>= 1.4.5)
mime-types (1.16)
mocha (0.9.8)
rake
nokogiri (1.4.3.1)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.4)
rack (>= 1.0)
rails (3.0.0)
actionmailer (= 3.0.0)
actionpack (= 3.0.0)
activerecord (= 3.0.0)
activeresource (= 3.0.0)
activesupport (= 3.0.0)
bundler (~> 1.0.0)
railties (= 3.0.0)
railties (3.0.0)
actionpack (= 3.0.0)
activesupport (= 3.0.0)
rake (>= 0.8.4)
thor (~> 0.14.0)
rake (0.8.7)
rspec (2.0.0.beta.22)
rspec-core (= 2.0.0.beta.22)
rspec-expectations (= 2.0.0.beta.22)
rspec-mocks (= 2.0.0.beta.22)
rspec-core (2.0.0.beta.22)
rspec-expectations (2.0.0.beta.22)
diff-lcs (>= 1.1.2)
rspec-mocks (2.0.0.beta.22)
rspec-core (= 2.0.0.beta.22)
rspec-expectations (= 2.0.0.beta.22)
rspec-rails (2.0.0.beta.22)
rspec (= 2.0.0.beta.22)
ruby-debug (0.10.3)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.3.0)
ruby-debug-base (0.10.3)
linecache (>= 0.3)
rubycas-client (2.1.0)
activesupport
rubyforge (2.0.4)
json_pure (>= 1.1.7)
sham_rack (1.3.2)
shoulda (2.11.3)
sqlite3-ruby (1.3.1)
thor (0.14.1)
treetop (1.4.8)
polyglot (>= 0.3.1)
tzinfo (0.3.23)
warden (0.10.7)
rack (>= 1.0.0)
webrat (0.7.1)
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)

PLATFORMS
ruby

DEPENDENCIES
devise (>= 1.0.6)
devise_cas_authenticatable!
jeweler
mocha
rails (= 3.0.0)
rspec (>= 2.0.0.beta.17)
rspec-rails (>= 2.0.0.beta.17)
ruby-debug
rubycas-client (~> 2.1.0)
sham_rack
shoulda
sqlite3-ruby
webrat
15 changes: 5 additions & 10 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rspec/mocks/version'
require 'rspec/core/rake_task'

desc 'Default: run unit tests.'
task :default => :test
RSpec::Core::RakeTask.new(:spec)

desc 'Test the devise_cas_authenticatable plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Default: run specs.'
task :default => :spec

desc 'Generate documentation for the devise_cas_authenticatable plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
Expand Down
17 changes: 17 additions & 0 deletions spec/routes_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'spec_helper'

describe Devise::CasSessionsController do
include RSpec::Rails::ControllerExampleGroup

it { should route(:get, "/users").to(:action => "service") }
it { should route(:get, "/users/sign_in").to(:action => "create") }
it { should route(:post, "/users/sign_in").to(:action => "create") }
it { should route(:get, "/users/sign_out").to(:action => "destroy") }

it "should have the right route names" do
controller.should respond_to("new_user_session_path", "user_session_path", "destroy_user_session_path")
controller.new_user_session_path.should == "/users/sign_in"
controller.user_session_path.should == "/users/sign_in"
controller.destroy_user_session_path.should == "/users/sign_out"
end
end
4 changes: 4 additions & 0 deletions spec/scenario/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.bundle
db/*.sqlite3
log/*.log
tmp/**/*
4 changes: 4 additions & 0 deletions spec/scenario/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :authenticate_user!
end
5 changes: 5 additions & 0 deletions spec/scenario/app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class HomeController < ApplicationController
def index
head(:ok)
end
end
3 changes: 3 additions & 0 deletions spec/scenario/app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class User < ActiveRecord::Base
devise :cas_authenticatable, :rememberable
end
17 changes: 17 additions & 0 deletions spec/scenario/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<title>Scenario</title>
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
</head>
<body>

<p class="alert"><%= alert %></p>
<p class="notice"><%= notice %></p>

<%= yield %>

</body>
</html>
4 changes: 4 additions & 0 deletions spec/scenario/config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run Scenario::Application
18 changes: 18 additions & 0 deletions spec/scenario/config/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require File.expand_path('../boot', __FILE__)

require 'rails/all'

Bundler.require(:default, Rails.env) if defined?(Bundler)

require "devise"
require "devise_cas_authenticatable"

Devise.setup do |config|
require "devise/orm/active_record"
end

module Scenario
class Application < Rails::Application
config.active_support.deprecation = :stderr
end
end
13 changes: 13 additions & 0 deletions spec/scenario/config/boot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'rubygems'

# Set up gems listed in the Gemfile.
gemfile = File.expand_path('../../Gemfile', __FILE__)
begin
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup
rescue Bundler::GemNotFound => e
STDERR.puts e.message
STDERR.puts "Try running `bundle install`."
exit!
end if File.exist?(gemfile)
22 changes: 22 additions & 0 deletions spec/scenario/config/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000

production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
5 changes: 5 additions & 0 deletions spec/scenario/config/environment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Load the rails application
require File.expand_path('../application', __FILE__)

# Initialize the rails application
Scenario::Application.initialize!
26 changes: 26 additions & 0 deletions spec/scenario/config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Scenario::Application.configure do
# 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.cache_classes = false

# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true

# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_view.debug_rjs = true
config.action_controller.perform_caching = false

# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false

# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log

# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
end

49 changes: 49 additions & 0 deletions spec/scenario/config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Scenario::Application.configure do
# 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.consider_all_requests_local = false
config.action_controller.perform_caching = true

# Specifies the header that your server uses for sending files
config.action_dispatch.x_sendfile_header = "X-Sendfile"

# For nginx:
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'

# If you have no front-end server that supports something like X-Sendfile,
# just comment this out and Rails will serve the files

# See everything in the log (default is :info)
# config.log_level = :debug

# Use a different logger for distributed setups
# config.logger = SyslogLogger.new

# Use a different cache store in production
# config.cache_store = :mem_cache_store

# Disable Rails's static asset server
# In production, Apache or nginx will already do this
config.serve_static_assets = false

# Enable serving of images, stylesheets, and javascripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"

# Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false

# Enable threaded mode
# config.threadsafe!

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
config.i18n.fallbacks = true

# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify
end
Loading

0 comments on commit 83be669

Please sign in to comment.