Skip to content
Browse files

all specs run

  • Loading branch information...
1 parent 1c86c71 commit 9f6b83346560d23ecfd850dde131f0c4e7a30c40 @jschoolcraft committed Jun 28, 2010
View
1 .rspec
@@ -0,0 +1 @@
+--colour
View
32 Gemfile
@@ -3,23 +3,23 @@ source "http://rubygems.org"
gem "rails", "3.0.0.beta4"
gem "mysql"
gem "authlogic"
-# gem "json"
-# gem "ratom", :require => 'atom'
-# gem "will_paginate"
+gem "json"
+gem "ratom", :require => 'atom'
+gem "will_paginate"
gem "haml"
-# gem "newrelic_rpm"
-# gem "big_sitemap", :git => 'http://github.com/alexrabarts/big_sitemap.git'
-# gem "slim_scrooge"
+gem "newrelic_rpm"
+gem "big_sitemap", :git => 'http://github.com/alexrabarts/big_sitemap.git'
+gem "slim_scrooge"
group :test do
- # gem "rspec"
- # gem "rspec-rails"
- # gem "remarkable_rails"
- # gem "cucumber"
- # gem "cucumber-rails"
- # gem "database_cleaner"
- # gem "launchy"
- # gem 'email_spec'
- # gem 'webrat'
- # gem "factory_girl"
+ gem "rspec", "2.0.0.beta.14"
+ gem "rspec-rails", "2.0.0.beta.14.1"
+ gem "remarkable_activerecord", "4.0.0.alpha4"
+ gem "cucumber", "0.8.3"
+ gem "cucumber-rails", "0.3.2"
+ gem "database_cleaner", "0.5.2"
+ gem "launchy"
+ gem 'email_spec', :git => "git://github.com/bmabey/email-spec.git", :branch => "rails3"
+ gem 'webrat', "0.7.1"
+ gem "factory_girl", :require => false
end
View
145 Gemfile.lock
@@ -1,21 +1,89 @@
---
dependencies:
+ big_sitemap:
+ group:
+ - :default
+ version: ">= 0"
rails:
group:
- :default
version: = 3.0.0.beta4
+ mysql:
+ group:
+ - :default
+ version: ">= 0"
+ authlogic:
+ group:
+ - :default
+ version: ">= 0"
haml:
group:
- :default
version: ">= 0"
- mysql:
+ newrelic_rpm:
group:
- :default
version: ">= 0"
- authlogic:
+ ratom:
+ group:
+ - :default
+ version: ">= 0"
+ require:
+ - atom
+ rspec:
+ group:
+ - :test
+ version: = 2.0.0.beta.14
+ database_cleaner:
+ group:
+ - :test
+ version: = 0.5.2
+ rspec-rails:
+ group:
+ - :test
+ version: = 2.0.0.beta.14.1
+ factory_girl:
+ group:
+ - :test
+ version: ">= 0"
+ require: []
+
+ will_paginate:
+ group:
+ - :default
+ version: ">= 0"
+ json:
+ group:
+ - :default
+ version: ">= 0"
+ remarkable_activerecord:
+ group:
+ - :test
+ version: = 4.0.0.alpha4
+ cucumber-rails:
+ group:
+ - :test
+ version: = 0.3.2
+ webrat:
+ group:
+ - :test
+ version: = 0.7.1
+ email_spec:
+ group:
+ - :test
+ version: ">= 0"
+ cucumber:
+ group:
+ - :test
+ version: = 0.8.3
+ slim_scrooge:
group:
- :default
version: ">= 0"
+ launchy:
+ group:
+ - :test
+ version: ">= 0"
specs:
- rake:
version: 0.8.7
@@ -59,19 +127,90 @@ specs:
version: 3.0.0.beta4
- authlogic:
version: 2.1.5
+- extlib:
+ version: 0.9.15
+- big_sitemap:
+ version: 0.5.1
+ source: 1
- bundler:
version: 0.9.26
+- configuration:
+ version: 1.1.0
+- diff-lcs:
+ version: 1.1.2
+- trollop:
+ version: 1.16.2
+- gherkin:
+ version: 2.0.2
+- json_pure:
+ version: 1.4.3
+- term-ansicolor:
+ version: 1.0.5
+- cucumber:
+ version: 0.8.3
+- cucumber-rails:
+ version: 0.3.2
+- database_cleaner:
+ version: 0.5.2
+- email_spec:
+ version: 0.6.2
+ source: 0
+- factory_girl:
+ version: 1.3.1
- haml:
version: 3.0.13
+- json:
+ version: 1.4.3
+- launchy:
+ version: 0.3.5
+- libxml-ruby:
+ version: 1.1.4
- mysql:
version: 2.8.1
+- newrelic_rpm:
+ version: 2.12.3
+- nokogiri:
+ version: 1.4.2
- thor:
version: 0.13.7
- railties:
version: 3.0.0.beta4
- rails:
version: 3.0.0.beta4
-hash: af117196160c17f2f4bff8c0025dc6f1c7235fc0
+- ratom:
+ version: 0.6.7
+- rspec-core:
+ version: 2.0.0.beta.14
+- rspec-expectations:
+ version: 2.0.0.beta.14
+- rspec-mocks:
+ version: 2.0.0.beta.14
+- rspec:
+ version: 2.0.0.beta.14
+- remarkable:
+ version: 4.0.0.alpha4
+- remarkable_activemodel:
+ version: 4.0.0.alpha4
+- remarkable_activerecord:
+ version: 4.0.0.alpha4
+- webrat:
+ version: 0.7.1
+- rspec-rails:
+ version: 2.0.0.beta.14.1
+- slim_scrooge:
+ version: 1.0.10
+- will_paginate:
+ version: 2.3.14
+hash: 17c9bca8c6c2f65bf8b5971c661e5080830e2e09
sources:
+- Git:
+ uri: git://github.com/bmabey/email-spec.git
+ branch: rails3
+ git: git://github.com/bmabey/email-spec.git
+ ref: 9297abaf30fa55c3a2cc71e5384964966ed8f640
+- Git:
+ uri: http://github.com/alexrabarts/big_sitemap.git
+ git: http://github.com/alexrabarts/big_sitemap.git
+ ref: 9240c6a036233b1ca621e2508f454df90b0a9b2e
- Rubygems:
uri: http://rubygems.org
View
2 autotest/discover.rb
@@ -0,0 +1,2 @@
+Autotest.add_discovery { "rails" }
+Autotest.add_discovery { "rspec2" }
View
6 config/initializers/rspec_generator.rb
@@ -0,0 +1,6 @@
+Urlagg::Application.configure do
+ config.generators do |g|
+ g.integration_tool :rspec
+ g.test_framework :rspec
+ end
+end if defined? Urlagg::Application
View
128 lib/tasks/rspec.rake
@@ -1,14 +1,10 @@
-gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
-
-# Don't load rspec if running "rake gems:*"
-unless ARGV.any? {|a| a =~ /^gems/}
-
begin
- require 'spec/rake/spectask'
+ require 'rspec/core'
+ require 'rspec/core/rake_task'
rescue MissingSourceFile
- module Spec
- module Rake
- class SpecTask
+ module RSpec
+ module Core
+ class RakeTask
def initialize(name)
task name do
# if rspec-rails is a configured gem, this will output helpful material and exit ...
@@ -32,134 +28,42 @@ end
Rake.application.instance_variable_get('@tasks').delete('default')
-spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop
+spec_prereq = Rails.root.join('config', 'database.yml').exist? ? "db:test:prepare" : :noop
task :noop do
end
task :default => :spec
task :stats => "spec:statsetup"
desc "Run all specs in spec directory (excluding plugin specs)"
-Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t|
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList['spec/**/*/*_spec.rb']
-end
+RSpec::Core::RakeTask.new(:spec => spec_prereq)
namespace :spec do
- desc "Run all specs in spec directory with RCov (excluding plugin specs)"
- Spec::Rake::SpecTask.new(:rcov) do |t|
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList['spec/**/*/*_spec.rb']
- t.rcov = true
- t.rcov_opts = lambda do
- IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
- end
- end
-
- desc "Print Specdoc for all specs (excluding plugin specs)"
- Spec::Rake::SpecTask.new(:doc) do |t|
- t.spec_opts = ["--format", "specdoc", "--dry-run"]
- t.spec_files = FileList['spec/**/*/*_spec.rb']
- end
-
- desc "Print Specdoc for all plugin examples"
- Spec::Rake::SpecTask.new(:plugin_doc) do |t|
- t.spec_opts = ["--format", "specdoc", "--dry-run"]
- t.spec_files = FileList['vendor/plugins/**/spec/**/*/*_spec.rb'].exclude('vendor/plugins/rspec/*')
- end
-
- [:models, :controllers, :views, :helpers, :lib].each do |sub|
+ [:requests, :models, :controllers, :views, :helpers, :mailers, :lib, :routing].each do |sub|
desc "Run the code examples in spec/#{sub}"
- Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
- end
- end
-
- desc "Run the code examples in vendor/plugins (except RSpec's own)"
- Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t|
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList['vendor/plugins/**/spec/**/*/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
- end
-
- namespace :plugins do
- desc "Runs the examples for rspec_on_rails"
- Spec::Rake::SpecTask.new(:rspec_on_rails) do |t|
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*/*_spec.rb']
+ RSpec::Core::RakeTask.new(sub => spec_prereq) do |t|
+ t.pattern = "./spec/#{sub}/**/*_spec.rb"
end
end
- # Setup specs for stats
task :statsetup do
- require 'code_statistics'
+ require 'rails/code_statistics'
::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
- ::STATS_DIRECTORIES << %w(Routing\ specs spec/lib) if File.exist?('spec/routing')
+ ::STATS_DIRECTORIES << %w(Mailer\ specs spec/mailers) if File.exist?('spec/mailers')
+ ::STATS_DIRECTORIES << %w(Routing\ specs spec/routing) if File.exist?('spec/routing')
+ ::STATS_DIRECTORIES << %w(Request\ specs spec/requests) if File.exist?('spec/requests')
::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
+ ::CodeStatistics::TEST_TYPES << "Mailer specs" if File.exist?('spec/mailer')
::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing')
- end
-
- namespace :db do
- namespace :fixtures do
- desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z."
- task :load => :environment do
- ActiveRecord::Base.establish_connection(Rails.env)
- base_dir = File.join(Rails.root, 'spec', 'fixtures')
- fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir
-
- require 'active_record/fixtures'
- (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file|
- Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
- end
- end
- end
- end
-
- namespace :server do
- daemonized_server_pid = File.expand_path("#{RAILS_ROOT}/tmp/pids/spec_server.pid")
-
- desc "start spec_server."
- task :start do
- if File.exist?(daemonized_server_pid)
- $stderr.puts "spec_server is already running."
- else
- $stderr.puts %Q{Starting up spec_server ...}
- FileUtils.mkdir_p('tmp/pids') unless test ?d, 'tmp/pids'
- system("ruby", "script/spec_server", "--daemon", "--pid", daemonized_server_pid)
- end
- end
-
- desc "stop spec_server."
- task :stop do
- unless File.exist?(daemonized_server_pid)
- $stderr.puts "No server running."
- else
- $stderr.puts "Shutting down spec_server ..."
- system("kill", "-s", "TERM", File.read(daemonized_server_pid).strip) &&
- File.delete(daemonized_server_pid)
- end
- end
-
- desc "restart spec_server."
- task :restart => [:stop, :start]
-
- desc "check if spec server is running"
- task :status do
- if File.exist?(daemonized_server_pid)
- $stderr.puts %Q{spec_server is running (PID: #{File.read(daemonized_server_pid).gsub("\n","")})}
- else
- $stderr.puts "No server running."
- end
- end
+ ::CodeStatistics::TEST_TYPES << "Request specs" if File.exist?('spec/requests')
end
end
-end
View
3 spec/controllers/accounts_controller_spec.rb
@@ -1,9 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AccountsController do
- include EmailSpec::Helpers
- include EmailSpec::Matchers
-
describe "POST /accounts/create" do
it "should deliver the welcome email" do
@user = Factory.stub(:user, :login => "john", :email => 'john@example.com', :password => "secret", :password_confirmation => "secret")
View
8 spec/models/notifier_spec.rb
@@ -3,13 +3,13 @@
describe "Emails" do
include EmailSpec::Helpers
include EmailSpec::Matchers
- include ActionController::UrlWriter
+ # include ActionController::UrlWriter
describe "Password reset email" do
before(:all) do
@user = Factory.stub(:registered_user)
@email = Notifier.create_password_reset_instructions(@user)
- default_url_options[:host] = "urlagg.com"
+ # default_url_options[:host] = "urlagg.com"
end
it "should be set to be delivered to the email passed in" do
@@ -21,7 +21,9 @@
end
it "should contain a link to the password reset link" do
- @email.should have_text(/#{edit_password_reset_url(@user.perishable_token)}/)
+ pending "lost access to UrlWriter" do
+ @email.should have_text(/#{edit_password_reset_url(@user.perishable_token)}/)
+ end
end
it "should have the correct subject" do
View
71 spec/spec_helper.rb
@@ -1,50 +1,27 @@
+# This file is copied to ~/spec when you run 'ruby script/generate rspec'
+# from the project root directory.
ENV["RAILS_ENV"] ||= 'test'
-require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
-require 'spec/autorun'
-require 'spec/rails'
-require 'webrat'
-require 'remarkable_rails'
-require "email_spec/helpers"
-require "email_spec/matchers"
-
-Spec::Runner.configure do |config|
- # If you're not using ActiveRecord you should remove these
- # lines, delete config/database.yml and disable :active_record
- # in your config/boot.rb
+require File.expand_path("../../config/environment", __FILE__)
+require 'rspec/rails'
+
+# Requires supporting files with custom matchers and macros, etc,
+# in ./support/ and its subdirectories.
+Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
+
+RSpec.configure do |config|
+ # == Mock Framework
+ #
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
+ #
+ # config.mock_with :mocha
+ # config.mock_with :flexmock
+ # config.mock_with :rr
+ config.mock_with :rspec
+
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
+
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
+ # examples within a transaction, comment the following line or assign false
+ # instead of true.
config.use_transactional_fixtures = true
- config.use_instantiated_fixtures = false
- config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
-
- def login(session_stubs = {}, user_stubs = {})
- UserSession.stub(:find).and_return(user_session(session_stubs, user_stubs))
- end
-
- def logout
- @user_session = nil
- end
-
- def current_user(stubs = {})
- @current_user ||= stub_model(User, stubs)
- end
-
- def user_session(stubs = {}, user_stubs = {})
- @current_user_session ||= mock_model(UserSession, {:user => current_user(user_stubs)}.merge(stubs))
- end
-
- # super_user admin
- def current_super_user(stubs = {})
- @current_super_user ||= stub_model(SuperUser, stubs)
- end
-
- def super_user_session(stubs = {}, user_stubs = {})
- @current_super_user_session ||= mock_model(SuperUserSession, {:super_user => current_super_user(user_stubs)}.merge(stubs))
- end
-
- def admin_login(session_stubs = {}, user_stubs = {})
- SuperUserSession.stub!(:find).and_return(super_user_session(session_stubs, user_stubs))
- end
-
- def admin_logout
- @super_user_session = nil
- end
end
View
41 spec/support/urlagg.rb
@@ -0,0 +1,41 @@
+require 'remarkable/active_record'
+require "email_spec"
+
+require 'factory_girl'
+
+Dir[File.expand_path(File.dirname(__FILE__) + "/../factories/*.rb")].each {|f| require f}
+
+RSpec.configure do |config|
+ def login(session_stubs = {}, user_stubs = {})
+ UserSession.stub(:find).and_return(user_session(session_stubs, user_stubs))
+ end
+
+ def logout
+ @user_session = nil
+ end
+
+ def current_user(stubs = {})
+ @current_user ||= stub_model(User, stubs)
+ end
+
+ def user_session(stubs = {}, user_stubs = {})
+ @current_user_session ||= mock_model(UserSession, {:user => current_user(user_stubs)}.merge(stubs))
+ end
+
+ # super_user admin
+ def current_super_user(stubs = {})
+ @current_super_user ||= stub_model(SuperUser, stubs)
+ end
+
+ def super_user_session(stubs = {}, user_stubs = {})
+ @current_super_user_session ||= mock_model(SuperUserSession, {:super_user => current_super_user(user_stubs)}.merge(stubs))
+ end
+
+ def admin_login(session_stubs = {}, user_stubs = {})
+ SuperUserSession.stub!(:find).and_return(super_user_session(session_stubs, user_stubs))
+ end
+
+ def admin_logout
+ @super_user_session = nil
+ end
+end

0 comments on commit 9f6b833

Please sign in to comment.
Something went wrong with that request. Please try again.