Navigation Menu

Skip to content

Commit

Permalink
use rspec for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mjankowski committed Sep 2, 2011
1 parent 53d093b commit ae7d28b
Show file tree
Hide file tree
Showing 51 changed files with 9,689 additions and 186 deletions.
20 changes: 6 additions & 14 deletions .gitignore
@@ -1,14 +1,6 @@
log/*
tmp/**/*
tmp/
db/schema.rb
db/*.sqlite3
public/system
*.DS_Store
coverage/*
coverage*
*.swp
public/announcement.html

!.keep
.sass-cache
.bundle/
log/*.log
pkg/
spec/dummy/db/*.sqlite3
spec/dummy/log/*.log
spec/dummy/tmp/
11 changes: 11 additions & 0 deletions Gemfile
@@ -0,0 +1,11 @@
source "http://rubygems.org"

gem "rails", "3.0.10"
gem "capybara", ">= 0.4.0"
gem "sqlite3"

gem "rspec-rails", ">= 2.0.0.beta"

# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
# gem 'ruby-debug19'
114 changes: 114 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,114 @@
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.10)
actionpack (= 3.0.10)
mail (~> 2.2.19)
actionpack (3.0.10)
activemodel (= 3.0.10)
activesupport (= 3.0.10)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.5.0)
rack (~> 1.2.1)
rack-mount (~> 0.6.14)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.0.10)
activesupport (= 3.0.10)
builder (~> 2.1.2)
i18n (~> 0.5.0)
activerecord (3.0.10)
activemodel (= 3.0.10)
activesupport (= 3.0.10)
arel (~> 2.0.10)
tzinfo (~> 0.3.23)
activeresource (3.0.10)
activemodel (= 3.0.10)
activesupport (= 3.0.10)
activesupport (3.0.10)
arel (2.0.10)
builder (2.1.2)
capybara (1.0.0)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 0.2.0)
xpath (~> 0.1.4)
childprocess (0.2.2)
ffi (~> 1.0.6)
diff-lcs (1.1.3)
erubis (2.6.6)
abstract (>= 1.0.0)
ffi (1.0.9)
i18n (0.5.0)
json_pure (1.5.4)
spruz (~> 0.2.8)
mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
nokogiri (1.5.0)
polyglot (0.3.2)
rack (1.2.3)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.10)
actionmailer (= 3.0.10)
actionpack (= 3.0.10)
activerecord (= 3.0.10)
activeresource (= 3.0.10)
activesupport (= 3.0.10)
bundler (~> 1.0)
railties (= 3.0.10)
railties (3.0.10)
actionpack (= 3.0.10)
activesupport (= 3.0.10)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.4)
rake (0.9.2)
rdoc (3.9.4)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
rspec-mocks (~> 2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0)
rspec-rails (2.6.1)
actionpack (~> 3.0)
activesupport (~> 3.0)
railties (~> 3.0)
rspec (~> 2.6.0)
rubyzip (0.9.4)
selenium-webdriver (0.2.2)
childprocess (>= 0.1.9)
ffi (>= 1.0.7)
json_pure
rubyzip
spruz (0.2.13)
sqlite3 (1.3.4)
thor (0.14.6)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.29)
xpath (0.1.4)
nokogiri (~> 1.3)

PLATFORMS
ruby

DEPENDENCIES
capybara (>= 0.4.0)
rails (= 3.0.10)
rspec-rails (>= 2.0.0.beta)
sqlite3
26 changes: 14 additions & 12 deletions Rakefile
@@ -1,23 +1,25 @@
# encoding: utf-8
# encoding: UTF-8
require 'rubygems'
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end

require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rdoc/task'

desc 'Default: run unit tests.'
task :default => :test
require 'rspec/core'
require 'rspec/core/rake_task'

Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
RSpec::Core::RakeTask.new(:spec)

task :default => :spec

Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'Flutie'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end
4 changes: 2 additions & 2 deletions flutie.gemspec
Expand Up @@ -6,8 +6,8 @@ Gem::Specification.new do |s|
s.homepage = 'http://github.com/thoughtbot/flutie'
s.summary = 'Flutie adds default stylesheets to web apps'
s.description = 'Flutie is a starting point for personal discovery'
s.files = ["README*", "Rakefile", "{app,config,lib,public}/**/*"].map { |glob| Dir[glob] }.flatten
s.files = Dir["{app,cnofig,lib,public}/**/*"] + ["MIT-LICENSE", "Rakefile", "Gemfile", "README*"]
s.authors = ['Chad Pytel', 'Kevin Burg', 'Matt Jankowski', 'Mike Burns', 'Fred Yates']
s.add_development_dependency('sass')
s.add_development_dependency('rails', '3.0.8')
s.add_development_dependency('rails', '3.0.10')
end
64 changes: 64 additions & 0 deletions spec/controllers/styleguides_controller_spec.rb
@@ -0,0 +1,64 @@
require 'spec_helper'

ActionController::Base.prepend_view_path File.join(File.dirname(__FILE__), '..', '..', 'app', 'views')
ActionController::Base.prepend_view_path File.join(File.dirname(__FILE__), '..', 'fixtures', 'app', 'views')

describe Flutie::StyleguidesController do

render_views

describe "GET to /styleguides/show" do
before { get :show }
it "should respond with success and render template" do
response.should be_success
response.should render_template(:show)
end
it "should use application layout" do
response.should render_template('layouts/application')
end
it "should render valid xml" do
lambda { REXML::Document.new(response.body) }.should_not raise_error
end
it "should render styleguide partials" do
response.body.should =~ %r{fixture partial 1}
response.body.should =~ %r{fixture partial 2}
end
end

describe "GET to /styleguides/show with flutie=false" do
before { get :show, :flutie => "false" }
it "should respond with success and render template" do
response.should be_success
response.should render_template(:show)
end
it "should use application layout" do
response.should render_template('layouts/application')
end
it "should render valid xml" do
lambda { REXML::Document.new(response.body) }.should_not raise_error
end
it "should render styleguide partials" do
response.body.should =~ %r{fixture partial 1}
response.body.should =~ %r{fixture partial 2}
end
end

describe "GET to /styleguides/show with flutie=true" do
before { get :show, :flutie => "true" }
it "should respond with success and render template" do
response.should be_success
response.should render_template(:show)
end
it "should use flutie layout" do
response.should render_template('layouts/flutie')
end
it "should render valid xml" do
lambda { REXML::Document.new(response.body) }.should_not raise_error
end
it "should render styleguide partials" do
response.body.should =~ %r{fixture partial 1}
response.body.should =~ %r{fixture partial 2}
end
end

end
5 changes: 1 addition & 4 deletions test/dummy/Rakefile → spec/dummy/Rakefile
Expand Up @@ -2,9 +2,6 @@
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

Rails::Application.load_tasks
Dummy::Application.load_tasks
14 changes: 14 additions & 0 deletions spec/dummy/app/views/layouts/application.html.erb
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Dummy</title>
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
</head>
<body>

<%= yield %>

</body>
</html>
File renamed without changes.
@@ -1,28 +1,28 @@
require File.expand_path('../boot', __FILE__)

require 'rails/all'
require "active_model/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_view/railtie"
require "action_mailer/railtie"

# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)

require 'sass'
require 'flutie'
Bundler.require
require "flutie"

module Dummy
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.

# Add additional load paths for your own custom dirs
# config.load_paths += %W( #{config.root}/extras )
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)

# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]

# Activate observers that should always be running
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
Expand All @@ -33,14 +33,13 @@ class Application < Rails::Application
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de

# Configure generators values. Many other options are available, be sure to check the documentation.
# config.generators do |g|
# g.orm :active_record
# g.template_engine :erb
# g.test_framework :test_unit, :fixture => true
# end
# JavaScript files you want as :defaults (application.js is always included).
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)

# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"

# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters << :password
config.filter_parameters += [:password]
end
end
10 changes: 10 additions & 0 deletions spec/dummy/config/boot.rb
@@ -0,0 +1,10 @@
require 'rubygems'
gemfile = File.expand_path('../../../../Gemfile', __FILE__)

if File.exist?(gemfile)
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup
end

$:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,5 +1,5 @@
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
# gem install sqlite3
development:
adapter: sqlite3
database: db/development.sqlite3
Expand Down
File renamed without changes.
@@ -1,5 +1,5 @@
Dummy::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb
# 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
Expand All @@ -16,4 +16,11 @@

# 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

0 comments on commit ae7d28b

Please sign in to comment.