Skip to content
This repository
  • 12 commits
  • 17 files changed
  • 0 comments
  • 1 contributor
18  Gemfile
... ...
@@ -1,20 +1,18 @@
1 1
 source "http://rubygems.org"
2 2
 
3  
-gem 'arel', :path => "./vendor/arel"
4  
-gem 'rails', :path => "./vendor/rails"
  3
+gem 'rails', :path => File.expand_path("../vendor/rails", __FILE__)
5 4
 
6  
-gem 'rspec-rails', :path => "."
7  
-gem 'rspec-core', :path => "../rspec-core"
8  
-gem 'rspec-expectations', :path => "../rspec-expectations"
9  
-gem 'rspec-mocks', :path => "../rspec-mocks"
10  
-gem 'rspec', :path => "../rspec"
  5
+%w[rspec rspec-core rspec-expectations rspec-mocks rspec-rails].each do |lib|
  6
+  gem lib, :path => File.expand_path("../../#{lib}", __FILE__)
  7
+end
11 8
 
12  
-gem 'cucumber', '~> 0.9.2'
13  
-gem 'aruba', "~> 0.2.3", :require => nil
14  
-gem 'webrat', ">= 0.7.2.beta.1"
15 9
 gem 'sqlite3-ruby', :require => 'sqlite3'
16 10
 
  11
+gem "cucumber", "0.8.5"
  12
+gem "aruba", "0.2.2"
  13
+gem 'webrat', ">= 0.7.2"
17 14
 gem 'autotest'
  15
+gem 'relish'
18 16
 
19 17
 case RUBY_VERSION
20 18
 when /^1\.9/
7  History.md
Source Rendered
... ...
@@ -1,5 +1,12 @@
1 1
 ## rspec-rails-2 release history (incomplete)
2 2
 
  3
+### 2.0.2 / in development
  4
+
  5
+[full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.1...master)
  6
+
  7
+* Enhancements
  8
+  * Re-added and properly deprecated `integrate_views` from rspec-rails-1
  9
+
3 10
 ### 2.0.1 / 2010-10-15
4 11
 
5 12
 [full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.0...v2.0.1)
13  README.markdown
Source Rendered
@@ -2,9 +2,16 @@
2 2
 
3 3
 rspec-2 for rails-3 with lightweight extensions to each
4 4
 
  5
+NOTE: rspec-2 does _not_ support rails-2. Use rspec-rails-1.3.x for rails-2.
  6
+
  7
+## Documentation
  8
+
  9
+* [Cucumber features](http://relishapp.com/rspec/rspec-rails/v/2-0)
  10
+* [RDoc](http://rubydoc.info/gems/rspec-rails/2.0.1/frames)
  11
+
5 12
 ## Install
6 13
 
7  
-    gem install rspec-rails --pre
  14
+    gem install rspec-rails
8 15
 
9 16
 This installs the following gems:
10 17
 
@@ -19,7 +26,7 @@ This installs the following gems:
19 26
 Add `rspec-rails` to the `:test` and `:development` groups in the Gemfile:
20 27
 
21 28
     group :test, :development do
22  
-      gem "rspec-rails", ">= 2.0.0.beta.22"
  29
+      gem "rspec-rails", "~> 2.0.1"
23 30
     end
24 31
 
25 32
 It needs to be in the `:development` group to expose generators and rake
@@ -99,8 +106,6 @@ not send you to the doctor with a migraine.
99 106
 
100 107
 See http://github.com/rspec/rspec-rails/issues
101 108
 
102  
-Also see [Gotchas.markdown](http://github.com/rspec/rspec-rails/blob/master/Gotchas.markdown)
103  
-
104 109
 # Request Specs
105 110
 
106 111
 Request specs live in spec/requests.
39  Rakefile
... ...
@@ -1,9 +1,8 @@
1  
-unless File.directory?("vendor/rails") && File.directory?("vendor/arel")
  1
+unless File.directory?("vendor/rails")
2 2
   raise <<-MESSAGE
3  
-You need to clone the rails and arel git repositories into ./vendor
4  
-before you can use any of the rake tasks.
  3
+You need to clone the rails git repository into ./vendor before you can use any
  4
+of the rake tasks.
5 5
 
6  
-    git clone git://github.com/rails/arel.git  vendor/arel
7 6
     git clone git://github.com/rails/rails.git vendor/rails
8 7
 
9 8
 MESSAGE
@@ -20,14 +19,6 @@ require 'rspec'
20 19
 require 'rspec/core/rake_task'
21 20
 require 'cucumber/rake/task'
22 21
 
23  
-class Cucumber::Rake::Task::ForkedCucumberRunner
24  
-  # When cucumber shells out, we still need it to run in the context of our
25  
-  # bundle.
26  
-  def run
27  
-    sh "bundle exec #{RUBY} " + args.join(" ")
28  
-  end
29  
-end
30  
-
31 22
 task :cleanup_rcov_files do
32 23
   rm_rf 'coverage.data'
33 24
 end
@@ -70,33 +61,33 @@ namespace :generate do
70 61
 
71 62
   desc "generate a bunch of stuff with generators"
72 63
   task :stuff do
73  
-    Dir.chdir("./tmp/example_app/") do
74  
-      sh "rake rails:template LOCATION='../../templates/generate_stuff.rb'"
  64
+    in_example_app "rake rails:template LOCATION='../../templates/generate_stuff.rb'"
  65
+  end
  66
+end
  67
+
  68
+def in_example_app(command)
  69
+  Dir.chdir("./tmp/example_app/") do
  70
+    Bundler.with_clean_env do
  71
+      sh command
75 72
     end
76 73
   end
77 74
 end
78 75
 
79 76
 namespace :db do
80 77
   task :migrate do
81  
-    Dir.chdir("./tmp/example_app/") do
82  
-      sh "rake db:migrate"
83  
-    end
  78
+    in_example_app "rake db:migrate"
84 79
   end
85 80
 
86 81
   namespace :test do
87 82
     task :prepare do
88  
-      Dir.chdir("./tmp/example_app/") do
89  
-        sh "rake db:test:prepare"
90  
-      end
  83
+      in_example_app "rake db:test:prepare"
91 84
     end
92 85
   end
93 86
 end
94 87
 
95 88
 desc "run a variety of specs against the generated app"
96 89
 task :smoke do
97  
-  Dir.chdir("./tmp/example_app/") do
98  
-    sh "rake rails:template LOCATION='../../templates/run_specs.rb'"
99  
-  end
  90
+  in_example_app "rake rails:template --trace LOCATION='../../templates/run_specs.rb'"
100 91
 end
101 92
 
102 93
 desc 'clobber generated files'
@@ -116,7 +107,7 @@ end
116 107
 desc "Push cukes to relishapp using the relish-client-gem"
117 108
 task :relish, :version do |t, args|
118 109
   raise "rake relish[VERSION]" unless args[:version]
119  
-  sh "bundle exec relish --organization rspec --project rspec-rails -v #{args[:version]} push"
  110
+  sh "relish push --organization rspec --project rspec-rails -v #{args[:version]}"
120 111
 end
121 112
 
122 113
 task :default => [:spec, "clobber:app", "generate:app", "generate:stuff", :smoke, :cucumber]
35  Thorfile
... ...
@@ -1,43 +1,16 @@
1 1
 class Rails < Thor
2  
-  VERSIONS = {
3  
-    :rails => {
4  
-      "master" => "master",
5  
-      "3.0.0" => "v3.0.0",
6  
-      "3.0.1" => "v3.0.1",
7  
-      "3-0-stable" => "origin/3-0-stable"
8  
-    },
9  
-    :arel => {
10  
-      "master" => "master",
11  
-      "3.0.0" => "v1.0.0",
12  
-      "3.0.1" => "v1.0.0",
13  
-      "3-0-stable" => "master"
14  
-    }
15  
-  }
16  
-
17  
-  desc "checkout VERSION", "checks it out (and arel)"
  2
+  desc "checkout VERSION", "checks it out"
18 3
   def checkout(version)
19  
-    unless VERSIONS[:rails].has_key?(version)
20  
-      raise "\n#{"*"*50}\nvalid versions are: #{VERSIONS[:rails].keys.join(", ")}\n#{"*"*50}\n"
21  
-    end
22  
-
23  
-    puts "***** checking out rails at #{VERSIONS[:rails][version]} ..."
  4
+    puts "***** checking out rails at #{version} ..."
24 5
     Dir.chdir("vendor/rails") do
25  
-      `git checkout #{VERSIONS[:rails][version]}`
26  
-    end
27  
-
28  
-    puts "***** checking out arel at #{VERSIONS[:arel][version]} ..."
29  
-    Dir.chdir("vendor/arel") do
30  
-      `git checkout #{VERSIONS[:arel][version]}`
  6
+      `git checkout #{version}`
31 7
     end
32 8
   end
33 9
 
34  
-  desc "fetch", "update vendor/rails and vendor/arel"
  10
+  desc "fetch", "update vendor/rails"
35 11
   def fetch
36 12
     Dir.chdir("vendor/rails") do
37 13
       `git fetch`
38 14
     end
39  
-    Dir.chdir("vendor/arel") do
40  
-      `git fetch`
41  
-    end
42 15
   end
43 16
 end
25  features/support/env.rb
... ...
@@ -1,6 +1,22 @@
1 1
 require 'aruba'
2 2
 require 'webrat'
3 3
 
  4
+module Aruba::Api
  5
+  alias_method :orig_run, :run
  6
+
  7
+  def run(cmd, fail_on_error=false)
  8
+    if cmd =~ /^rspec/
  9
+      orig_run("bundle exec #{cmd}", fail_on_error)
  10
+    else
  11
+      orig_run(cmd, fail_on_error)
  12
+    end 
  13
+  end
  14
+end
  15
+
  16
+Before do
  17
+  unset_bundler_env_vars
  18
+end
  19
+
4 20
 unless File.directory?('./tmp/example_app')
5 21
   system "rake generate:app generate:stuff"
6 22
 end
@@ -25,15 +41,14 @@ def copy(file_or_dir)
25 41
   system "cp -r #{source} #{target}"
26 42
 end
27 43
 
  44
+
28 45
 Before do
29 46
   steps %Q{
30 47
     Given a directory named "spec"
31 48
   }
32 49
 
33 50
   Dir['tmp/example_app/*'].each do |file_or_dir|
34  
-    if file_or_dir =~ /Gemfile/
35  
-      copy(file_or_dir)
36  
-    elsif !(file_or_dir =~ /spec$/)
  51
+    if !(file_or_dir =~ /spec$/)
37 52
       write_symlink(file_or_dir)
38 53
     end
39 54
   end
@@ -43,3 +58,7 @@ def copy(file_or_dir)
43 58
   end
44 59
 
45 60
 end
  61
+
  62
+Around do |scenario, block|
  63
+  Bundler.with_clean_env &block
  64
+end
10  lib/rspec/rails.rb
... ...
@@ -1,13 +1,3 @@
1  
-module RSpec
2  
-  module Rails
3  
-    class << self
4  
-      def using_active_record?
5  
-        ::Rails.configuration.generators.options[:rails][:orm] == :active_record
6  
-      end
7  
-    end
8  
-  end
9  
-end
10  
-
11 1
 require 'rspec/core'
12 2
 
13 3
 RSpec::configure do |c|
60  lib/rspec/rails/extensions/active_record/base.rb
... ...
@@ -1,44 +1,40 @@
1 1
 module RSpec
2 2
   module Rails
3  
-    if using_active_record?
  3
+    if defined?(ActiveRecord)
4 4
       module Extensions
5 5
         module ActiveRecord
6  
-          module ClassMethods
7  
-            # :call-seq:
8  
-            #   ModelClass.should have(:no).records
9  
-            #   ModelClass.should have(1).record
10  
-            #   ModelClass.should have(n).records
11  
-            #
12  
-            # Extension to enhance <tt>should have</tt> on AR Model classes
13  
-            def records
14  
-              find(:all)
15  
-            end
16  
-            alias :record :records
17  
-          end
18  
-
19  
-          module InstanceMethods
20  
-            # :call-seq:
21  
-            #   model.should have(:no).errors_on(:attribute)
22  
-            #   model.should have(1).error_on(:attribute)
23  
-            #   model.should have(n).errors_on(:attribute)
24  
-            #
25  
-            # Extension to enhance <tt>should have</tt> on AR Model instances.
26  
-            # Calls model.valid? in order to prepare the object's errors
27  
-            # object.
28  
-            def errors_on(attribute)
29  
-              self.valid?
30  
-              [self.errors[attribute]].flatten.compact
31  
-            end
32  
-            alias :error_on :errors_on
  6
+          # :call-seq:
  7
+          #   ModelClass.should have(:no).records
  8
+          #   ModelClass.should have(1).record
  9
+          #   ModelClass.should have(n).records
  10
+          #
  11
+          # Extension to enhance <tt>should have</tt> on AR Model classes
  12
+          def records
  13
+            find(:all)
33 14
           end
  15
+          alias :record :records
34 16
         end
35  
-      end
36 17
 
37  
-      class ::ActiveRecord::Base #:nodoc:
38  
-        extend  RSpec::Rails::Extensions::ActiveRecord::ClassMethods
39  
-        include RSpec::Rails::Extensions::ActiveRecord::InstanceMethods
  18
+        class ::ActiveRecord::Base #:nodoc:
  19
+          extend RSpec::Rails::Extensions::ActiveRecord
  20
+        end
40 21
       end
41 22
     end
42 23
   end
43 24
 end
44 25
 
  26
+module ::ActiveModel::Validations
  27
+  # :call-seq:
  28
+  #   model.should have(:no).errors_on(:attribute)
  29
+  #   model.should have(1).error_on(:attribute)
  30
+  #   model.should have(n).errors_on(:attribute)
  31
+  #
  32
+  # Extension to enhance <tt>should have</tt> on AR Model instances.
  33
+  # Calls model.valid? in order to prepare the object's errors
  34
+  # object.
  35
+  def errors_on(attribute)
  36
+    self.valid?
  37
+    [self.errors[attribute]].flatten.compact
  38
+  end
  39
+  alias :error_on :errors_on
  40
+end
2  lib/rspec/rails/fixture_support.rb
... ...
@@ -1,6 +1,6 @@
1 1
 module RSpec
2 2
   module Rails
3  
-    if using_active_record?
  3
+    if defined?(ActiveRecord)
4 4
       module FixtureSupport
5 5
         extend ActiveSupport::Concern
6 6
 
4  lib/rspec/rails/mocks.rb
@@ -70,7 +70,7 @@ def mock_model(string_or_model_class, stubs = {})
70 70
           m.extend ActiveModelInstanceMethods
71 71
           m.singleton_class.__send__ :include, ActiveModel::Conversion
72 72
           m.singleton_class.__send__ :include, ActiveModel::Validations
73  
-          if RSpec::Rails::using_active_record?
  73
+          if defined?(ActiveRecord)
74 74
             m.extend ActiveRecordInstanceMethods
75 75
             [:save, :update_attributes].each do |key|
76 76
               if stubs[key] == false
@@ -175,7 +175,7 @@ def connection
175 175
       def stub_model(model_class, stubs={})
176 176
         model_class.new.tap do |m|
177 177
           m.extend ActiveModelStubExtensions
178  
-          if RSpec::Rails::using_active_record? && model_class < ActiveRecord::Base
  178
+          if defined?(ActiveRecord) && model_class < ActiveRecord::Base
179 179
             m.extend ActiveRecordStubExtensions
180 180
             primary_key = model_class.primary_key.to_sym
181 181
             stubs = stubs.reverse_merge(primary_key => next_id)
2  lib/rspec/rails/version.rb
... ...
@@ -1,7 +1,7 @@
1 1
 module RSpec # :nodoc:
2 2
   module Rails # :nodoc:
3 3
     module Version # :nodoc:
4  
-      STRING = '2.0.1'
  4
+      STRING = '2.0.2.pre'
5 5
     end
6 6
   end
7 7
 end
5  lib/rspec/rails/view_rendering.rb
@@ -15,6 +15,11 @@ def render_views
15 15
           metadata_for_rspec_rails[:render_views] = true
16 16
         end
17 17
 
  18
+        def integrate_views
  19
+          RSpec.deprecate("integrate_views","render_views")
  20
+          render_views
  21
+        end
  22
+
18 23
         def render_views?
19 24
           !!metadata_for_rspec_rails[:render_views]
20 25
         end
2  rspec-rails.gemspec
@@ -57,6 +57,6 @@ Gem::Specification.new do |s|
57 57
 **************************************************
58 58
 }
59 59
 
60  
-  s.add_runtime_dependency "rspec", "~> 2.0.0"
  60
+  s.add_runtime_dependency "rspec", "~> 2.0.2.pre"
61 61
 end
62 62
 
18  spec/rspec/rails/deprecations_spec.rb
... ...
@@ -0,0 +1,18 @@
  1
+require 'spec_helper'
  2
+
  3
+describe "rspec-rails-2 deprecations" do
  4
+  context "controller specs" do
  5
+    describe "::integrate_views" do
  6
+      let(:group) do
  7
+        RSpec::Core::ExampleGroup.describe do
  8
+          include RSpec::Rails::ControllerExampleGroup
  9
+        end
  10
+      end
  11
+
  12
+      it "is deprecated" do
  13
+        RSpec.should_receive(:deprecate)
  14
+        group.integrate_views
  15
+      end
  16
+    end
  17
+  end
  18
+end
23  spec/rspec/rails/extensions/active_model/errors_on_spec.rb
... ...
@@ -0,0 +1,23 @@
  1
+require "spec_helper"
  2
+
  3
+describe "errors_on" do
  4
+  let(:klass) do
  5
+    Class.new do
  6
+      include ActiveModel::Validations
  7
+    end
  8
+  end
  9
+
  10
+  it "calls valid?" do
  11
+    model = klass.new
  12
+    model.should_receive(:valid?)
  13
+    model.errors_on(:foo)
  14
+  end
  15
+
  16
+  it "returns the errors on that attribute" do
  17
+    model = klass.new
  18
+    model.stub(:errors) do
  19
+      { :foo => ['a', 'b'] }
  20
+    end
  21
+    model.errors_on(:foo).should eq(['a','b'])
  22
+  end
  23
+end
9  spec/rspec/rails/extensions/active_record/records_spec.rb
... ...
@@ -0,0 +1,9 @@
  1
+require 'spec_helper'
  2
+
  3
+describe "records" do
  4
+  it "delegates to find(:all)" do
  5
+    klass = Class.new(ActiveRecord::Base)
  6
+    klass.should_receive(:find).with(:all)
  7
+    klass.records
  8
+  end
  9
+end
27  templates/Gemfile
... ...
@@ -1,18 +1,19 @@
1  
-source 'http://rubygems.org'
  1
+source "http://rubygems.org"
2 2
 
3  
-gem 'arel', :path => "../../vendor/arel"
4  
-gem 'rails', :path => "../../vendor/rails"
  3
+gem 'rails', :path => File.expand_path("../../../vendor/rails", __FILE__)
  4
+
  5
+%w[rspec rspec-core rspec-expectations rspec-mocks rspec-rails].each do |lib|
  6
+  gem lib, :path => File.expand_path("../../../../#{lib}", __FILE__)
  7
+end
5 8
 
6 9
 gem 'sqlite3-ruby', :require => 'sqlite3'
7 10
 
8  
-group :development, :test do
9  
-  gem "rspec-rails",        :path => "../../../rspec-rails"
10  
-  gem "rspec",              :path => "../../../rspec"
11  
-  gem "rspec-core",         :path => "../../../rspec-core"
12  
-  gem "rspec-expectations", :path => "../../../rspec-expectations"
13  
-  gem "rspec-mocks",        :path => "../../../rspec-mocks"
14  
-  gem "rcov"
15  
-  gem "webrat"
16  
-  gem "autotest"
17  
-  gem "watchr"
  11
+gem 'webrat', ">= 0.7.2"
  12
+
  13
+case RUBY_VERSION
  14
+when /^1\.9/
  15
+  gem 'ruby-debug19'
  16
+when /^1\.8/
  17
+  gem 'ruby-debug'
18 18
 end
  19
+

No commit comments for this range

Something went wrong with that request. Please try again.