From 11d7dca85a523cefbb6c2aeea9eb9445a2ab2c47 Mon Sep 17 00:00:00 2001 From: Joe Ferris Date: Tue, 14 Dec 2010 18:35:12 -0500 Subject: [PATCH] Fixes for Rails 3.0.3 and RSpec 2.3 --- Gemfile | 4 +- Gemfile.lock | 132 +++++++++--------- Rakefile | 3 + features/step_definitions/rails3_steps.rb | 6 +- .../allow_mass_assignment_of_matcher.rb | 8 +- spec/rails3_root/config/environments/test.rb | 1 + spec/rails3_root/config/routes.rb | 4 +- .../action_controller/route_matcher_spec.rb | 12 +- .../allow_mass_assignment_of_matcher_spec.rb | 2 +- spec/spec_helper.rb | 2 +- spec/support/model_builder.rb | 15 +- 11 files changed, 90 insertions(+), 99 deletions(-) diff --git a/Gemfile b/Gemfile index ac16ec8..c808d94 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,9 @@ source 'http://rubygems.org' -gem 'rails', '3.0.0.beta4' +gem 'rails', '3.0.3' gem 'sqlite3-ruby', :require => 'sqlite3' gem 'mocha' -gem 'rspec-rails', '2.0.0.beta.12' +gem 'rspec-rails' gem 'ruby-debug' gem 'cucumber' diff --git a/Gemfile.lock b/Gemfile.lock index 44231ea..48e6705 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,49 +2,48 @@ GEM remote: http://rubygems.org/ specs: abstract (1.0.0) - actionmailer (3.0.0.beta4) - actionpack (= 3.0.0.beta4) - mail (~> 2.2.3) - actionpack (3.0.0.beta4) - activemodel (= 3.0.0.beta4) - activesupport (= 3.0.0.beta4) + actionmailer (3.0.3) + actionpack (= 3.0.3) + mail (~> 2.2.9) + actionpack (3.0.3) + activemodel (= 3.0.3) + activesupport (= 3.0.3) builder (~> 2.1.2) - erubis (~> 2.6.5) - i18n (~> 0.4.1) - rack (~> 1.1.0) - rack-mount (~> 0.6.3) - rack-test (~> 0.5.4) - tzinfo (~> 0.3.16) - activemodel (3.0.0.beta4) - activesupport (= 3.0.0.beta4) + erubis (~> 2.6.6) + i18n (~> 0.4) + rack (~> 1.2.1) + rack-mount (~> 0.6.13) + rack-test (~> 0.5.6) + tzinfo (~> 0.3.23) + activemodel (3.0.3) + activesupport (= 3.0.3) builder (~> 2.1.2) - i18n (~> 0.4.1) - activerecord (3.0.0.beta4) - activemodel (= 3.0.0.beta4) - activesupport (= 3.0.0.beta4) - arel (~> 0.4.0) - tzinfo (~> 0.3.16) - activeresource (3.0.0.beta4) - activemodel (= 3.0.0.beta4) - activesupport (= 3.0.0.beta4) - activesupport (3.0.0.beta4) - arel (0.4.0) - activesupport (>= 3.0.0.beta) + i18n (~> 0.4) + activerecord (3.0.3) + activemodel (= 3.0.3) + activesupport (= 3.0.3) + arel (~> 2.0.2) + tzinfo (~> 0.3.23) + activeresource (3.0.3) + activemodel (= 3.0.3) + activesupport (= 3.0.3) + activesupport (3.0.3) + arel (2.0.6) builder (2.1.2) - columnize (0.3.1) - cucumber (0.9.4) - builder (~> 2.1.2) + columnize (0.3.2) + cucumber (0.10.0) + builder (>= 2.1.2) diff-lcs (~> 1.1.2) - gherkin (~> 2.2.9) + gherkin (~> 2.3.2) json (~> 1.4.6) term-ansicolor (~> 1.0.5) diff-lcs (1.1.2) erubis (2.6.6) abstract (>= 1.0.0) - gherkin (2.2.9) + gherkin (2.3.2) json (~> 1.4.6) term-ansicolor (~> 1.0.5) - i18n (0.4.1) + i18n (0.5.0) json (1.4.6) linecache (0.43) mail (2.2.12) @@ -55,53 +54,50 @@ GEM mime-types (1.16) mocha (0.9.10) rake - nokogiri (1.4.4) polyglot (0.3.1) - rack (1.1.0) + rack (1.2.1) rack-mount (0.6.13) rack (>= 1.0.0) rack-test (0.5.6) rack (>= 1.0) - rails (3.0.0.beta4) - actionmailer (= 3.0.0.beta4) - actionpack (= 3.0.0.beta4) - activerecord (= 3.0.0.beta4) - activeresource (= 3.0.0.beta4) - activesupport (= 3.0.0.beta4) - bundler (>= 0.9.26) - railties (= 3.0.0.beta4) - railties (3.0.0.beta4) - actionpack (= 3.0.0.beta4) - activesupport (= 3.0.0.beta4) - rake (>= 0.8.3) - thor (~> 0.13.6) + rails (3.0.3) + actionmailer (= 3.0.3) + actionpack (= 3.0.3) + activerecord (= 3.0.3) + activeresource (= 3.0.3) + activesupport (= 3.0.3) + bundler (~> 1.0) + railties (= 3.0.3) + railties (3.0.3) + actionpack (= 3.0.3) + activesupport (= 3.0.3) + rake (>= 0.8.7) + thor (~> 0.14.4) rake (0.8.7) - rspec (2.0.0.beta.12) - rspec-core (= 2.0.0.beta.12) - rspec-expectations (= 2.0.0.beta.12) - rspec-mocks (= 2.0.0.beta.12) - rspec-core (2.0.0.beta.12) - rspec-expectations (2.0.0.beta.12) - diff-lcs (>= 1.1.2) - rspec-mocks (2.0.0.beta.12) - rspec-rails (2.0.0.beta.12) - rspec (= 2.0.0.beta.12) - webrat (>= 0.7.0) - ruby-debug (0.10.3) + rspec (2.3.0) + rspec-core (~> 2.3.0) + rspec-expectations (~> 2.3.0) + rspec-mocks (~> 2.3.0) + rspec-core (2.3.0) + rspec-expectations (2.3.0) + diff-lcs (~> 1.1.2) + rspec-mocks (2.3.0) + rspec-rails (2.3.0) + actionpack (~> 3.0) + activesupport (~> 3.0) + railties (~> 3.0) + rspec (~> 2.3.0) + ruby-debug (0.10.4) columnize (>= 0.1) - ruby-debug-base (~> 0.10.3.0) - ruby-debug-base (0.10.3) + ruby-debug-base (~> 0.10.4.0) + ruby-debug-base (0.10.4) linecache (>= 0.3) sqlite3-ruby (1.3.2) term-ansicolor (1.0.5) - thor (0.13.8) + thor (0.14.6) treetop (1.4.9) polyglot (>= 0.3.1) tzinfo (0.3.23) - webrat (0.7.2) - nokogiri (>= 1.2.0) - rack (>= 1.0) - rack-test (>= 0.5.3) PLATFORMS ruby @@ -109,7 +105,7 @@ PLATFORMS DEPENDENCIES cucumber mocha - rails (= 3.0.0.beta4) - rspec-rails (= 2.0.0.beta.12) + rails (= 3.0.3) + rspec-rails ruby-debug sqlite3-ruby diff --git a/Rakefile b/Rakefile index 930caf6..81d238a 100644 --- a/Rakefile +++ b/Rakefile @@ -19,10 +19,13 @@ Rake::RDocTask.new { |rdoc| RSpec::Core::RakeTask.new do |t| t.pattern = "spec/**/*_spec.rb" + t.rspec_opts = '--color --format progress' + t.verbose = false end desc "Run code-coverage analysis using rcov" RSpec::Core::RakeTask.new(:coverage) do |t| + t.rspec_opts = '--color --format progress' t.rcov = true t.rcov_opts = %{--exclude osx\/objc,spec,gems\/ --failure-threshold 100} t.pattern = "spec/**/*_spec.rb" diff --git a/features/step_definitions/rails3_steps.rb b/features/step_definitions/rails3_steps.rb index f16ac31..30afec7 100644 --- a/features/step_definitions/rails3_steps.rb +++ b/features/step_definitions/rails3_steps.rb @@ -1,11 +1,11 @@ When /^I generate a new rails application$/ do @terminal.cd(TEMP_ROOT) - @terminal.run("rails _3.0.0.beta4_ new #{APP_NAME}") + @terminal.run("rails _3.0.3_ new #{APP_NAME}") steps %{ When I save the following as "Gemfile" """ source "http://rubygems.org" - gem 'rails', '3.0.0.beta4' + gem 'rails', '3.0.3' gem 'sqlite3-ruby', :require => 'sqlite3' """ } @@ -29,7 +29,7 @@ end When /^I configure the application to use rspec\-rails$/ do - append_to_gemfile "gem 'rspec-rails', '= 2.0.0.beta.12'" + append_to_gemfile "gem 'rspec-rails'" steps %{And I run "bundle install"} end diff --git a/lib/shoulda/active_record/allow_mass_assignment_of_matcher.rb b/lib/shoulda/active_record/allow_mass_assignment_of_matcher.rb index 8bd84d2..9e29b1e 100644 --- a/lib/shoulda/active_record/allow_mass_assignment_of_matcher.rb +++ b/lib/shoulda/active_record/allow_mass_assignment_of_matcher.rb @@ -21,12 +21,12 @@ def matches?(subject) @subject = subject if attr_mass_assignable? if whitelisting? - @failure_message = "#{@attribute} was made accessible" + @negative_failure_message = "#{@attribute} was made accessible" else if protected_attributes.empty? @negative_failure_message = "no attributes were protected" else - @failure_message = "#{class_name} is protecting " << + @negative_failure_message = "#{class_name} is protecting " << "#{protected_attributes.to_a.to_sentence}, " << "but not #{@attribute}." end @@ -34,10 +34,10 @@ def matches?(subject) true else if whitelisting? - @negative_failure_message = + @failure_message = "Expected #{@attribute} to be accessible" else - @negative_failure_message = + @failure_message = "Did not expect #{@attribute} to be protected" end false diff --git a/spec/rails3_root/config/environments/test.rb b/spec/rails3_root/config/environments/test.rb index 70e7187..24c768e 100644 --- a/spec/rails3_root/config/environments/test.rb +++ b/spec/rails3_root/config/environments/test.rb @@ -29,4 +29,5 @@ # This is necessary if your schema can't be completely dumped by the schema dumper, # like if you have constraints or database-specific column types # config.active_record.schema_format = :sql + config.active_support.deprecation = :stderr end diff --git a/spec/rails3_root/config/routes.rb b/spec/rails3_root/config/routes.rb index db1a28f..7a32cda 100644 --- a/spec/rails3_root/config/routes.rb +++ b/spec/rails3_root/config/routes.rb @@ -1,4 +1,2 @@ -Rails.application.routes.draw do |map| - map.resources :users, :has_many => :posts - map.resources :posts +Rails3Root::Application.routes.draw do end diff --git a/spec/shoulda/action_controller/route_matcher_spec.rb b/spec/shoulda/action_controller/route_matcher_spec.rb index 4d31b86..91a727e 100644 --- a/spec/shoulda/action_controller/route_matcher_spec.rb +++ b/spec/shoulda/action_controller/route_matcher_spec.rb @@ -5,15 +5,14 @@ context "given a controller with a defined glob url" do before do @controller = define_controller('Examples').new - define_routes do |map| - map.connect 'examples/*id', :controller => 'examples', - :action => 'example' + define_routes do + match 'examples/*id', :to => 'examples#example' end end it "should accept glob route" do @controller.should route(:get, '/examples/foo/bar'). - to(:action => 'example', :id => ['foo', 'bar']) + to(:action => 'example', :id => 'foo/bar') end end @@ -21,9 +20,8 @@ context "given a controller with a defined route" do before do @controller = define_controller('Examples').new - define_routes do |map| - map.connect 'examples/:id', :controller => 'examples', - :action => 'example' + define_routes do + match 'examples/:id', :to => 'examples#example' end end diff --git a/spec/shoulda/active_record/allow_mass_assignment_of_matcher_spec.rb b/spec/shoulda/active_record/allow_mass_assignment_of_matcher_spec.rb index c258ad6..27de56c 100644 --- a/spec/shoulda/active_record/allow_mass_assignment_of_matcher_spec.rb +++ b/spec/shoulda/active_record/allow_mass_assignment_of_matcher_spec.rb @@ -66,7 +66,7 @@ it "should assign a negative failure message" do matcher = allow_mass_assignment_of(:attr) - matcher.matches?(@model) + matcher.matches?(@model).should == true matcher.negative_failure_message.should_not be_nil end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 91a6cb4..adb09a5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,5 @@ ENV['RAILS_ENV'] = 'test' -ENV['RAILS_VERSION'] ||= '3.0.0.beta4' +ENV['RAILS_VERSION'] ||= '3.0.3' RAILS_GEM_VERSION = ENV['RAILS_VERSION'] rails_root = File.dirname(__FILE__) + '/rails3_root' diff --git a/spec/support/model_builder.rb b/spec/support/model_builder.rb index 8f1fcac..3c13b24 100644 --- a/spec/support/model_builder.rb +++ b/spec/support/model_builder.rb @@ -6,7 +6,6 @@ def self.included(example_group) example_group.class_eval do before do @created_tables ||= [] - @defined_constants ||= [] end after { teardown_defined_constants } @@ -32,11 +31,10 @@ def define_constant(class_name, base, &block) klass = Class.new(base) Object.const_set(class_name, klass) + klass.unloadable klass.class_eval(&block) if block_given? - @defined_constants << class_name - klass end @@ -81,8 +79,8 @@ def build_response(opts = {}, &block) klass = define_controller('Examples') block ||= lambda { render :nothing => true } klass.class_eval { layout false; define_method(action, &block) } - define_routes do |map| - map.connect 'examples', :controller => 'examples', :action => action + define_routes do + match 'examples', :to => "examples##{action}" end create_view("examples/#{action}.html.erb", "abc") @@ -111,10 +109,7 @@ def create_view(path, contents) end def teardown_defined_constants - @defined_constants.each do |class_name| - Object.send(:remove_const, class_name) - end - @defined_constants = [] + ActiveSupport::Dependencies.clear @created_tables.each do |table_name| ActiveRecord::Base. @@ -124,7 +119,7 @@ def teardown_defined_constants FileUtils.rm_rf(TMP_VIEW_PATH) - Rails.application.routes_reloader.reload! + Rails.application.reload_routes! end end