rspec-rails 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,24 +1,23 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem 'arel', :path => "./vendor/arel"
4
- gem 'rails', :path => "./vendor/rails"
3
+ gem "rack", :git => "git://github.com/rack/rack.git"
4
+ gem 'rails', :path => File.expand_path("../vendor/rails", __FILE__)
5
5
 
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"
6
+ %w[rspec-rails rspec rspec-core rspec-expectations rspec-mocks].each do |lib|
7
+ gem lib, :path => File.expand_path("../../#{lib}", __FILE__)
8
+ end
11
9
 
12
- gem 'cucumber', '~> 0.9.2'
13
- gem 'aruba', "~> 0.2.3", :require => nil
14
- gem 'webrat', ">= 0.7.2.beta.1"
10
+ gem "cucumber", "0.8.5"
11
+ gem "aruba", "0.2.2"
12
+ gem 'webrat', "0.7.2"
15
13
  gem 'sqlite3-ruby', :require => 'sqlite3'
16
14
 
17
15
  gem 'autotest'
18
16
 
19
- case RUBY_VERSION
20
- when /^1\.9/
17
+ platforms :mri_19 do
21
18
  gem 'ruby-debug19'
22
- when /^1\.8/
19
+ end
20
+
21
+ platforms :mri_18 do
23
22
  gem 'ruby-debug'
24
23
  end
data/History.md CHANGED
@@ -1,5 +1,16 @@
1
1
  ## rspec-rails-2 release history (incomplete)
2
2
 
3
+ ### 2.1.0 / 2010-11-07
4
+
5
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.1...v2.1.0)
6
+
7
+ * Enhancements
8
+ * Move errors_on to ActiveModel to support other AM-compliant ORMs
9
+
10
+ * Bug fixes
11
+ * Check for presence of ActiveRecord instead of checking Rails config
12
+ (gets rspec out of the way of multiple ORMs in the same app)
13
+
3
14
  ### 2.0.1 / 2010-10-15
4
15
 
5
16
  [full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.0...v2.0.1)
@@ -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.
data/Rakefile CHANGED
@@ -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,34 @@ 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 "bundle install"
65
+ in_example_app "rake rails:template LOCATION='../../templates/generate_stuff.rb'"
66
+ end
67
+ end
68
+
69
+ def in_example_app(command)
70
+ Dir.chdir("./tmp/example_app/") do
71
+ Bundler.with_clean_env do
72
+ sh command
75
73
  end
76
74
  end
77
75
  end
78
76
 
79
77
  namespace :db do
80
78
  task :migrate do
81
- Dir.chdir("./tmp/example_app/") do
82
- sh "rake db:migrate"
83
- end
79
+ in_example_app "rake db:migrate"
84
80
  end
85
81
 
86
82
  namespace :test do
87
83
  task :prepare do
88
- Dir.chdir("./tmp/example_app/") do
89
- sh "rake db:test:prepare"
90
- end
84
+ in_example_app "rake db:test:prepare"
91
85
  end
92
86
  end
93
87
  end
94
88
 
95
89
  desc "run a variety of specs against the generated app"
96
90
  task :smoke do
97
- Dir.chdir("./tmp/example_app/") do
98
- sh "rake rails:template LOCATION='../../templates/run_specs.rb'"
99
- end
91
+ in_example_app "rake rails:template --trace LOCATION='../../templates/run_specs.rb'"
100
92
  end
101
93
 
102
94
  desc 'clobber generated files'
@@ -121,3 +113,4 @@ end
121
113
 
122
114
  task :default => [:spec, "clobber:app", "generate:app", "generate:stuff", :smoke, :cucumber]
123
115
 
116
+
data/Thorfile CHANGED
@@ -1,43 +1,18 @@
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}`
7
+ `rm Gemfile.lock` if File.exist?('Gemfile.lock')
8
+ puts `bundle show`
31
9
  end
32
10
  end
33
11
 
34
- desc "fetch", "update vendor/rails and vendor/arel"
12
+ desc "fetch", "update vendor/rails"
35
13
  def fetch
36
14
  Dir.chdir("vendor/rails") do
37
15
  `git fetch`
38
16
  end
39
- Dir.chdir("vendor/arel") do
40
- `git fetch`
41
- end
42
17
  end
43
18
  end
@@ -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,8 @@ Before do
43
58
  end
44
59
 
45
60
  end
61
+
62
+ Around do |scenario, block|
63
+ Bundler.with_clean_env &block
64
+ end
65
+
@@ -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|
@@ -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
@@ -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
 
@@ -1,5 +1,4 @@
1
1
  require 'rspec/core/deprecation'
2
- require 'rspec/core/backward_compatibility'
3
2
  require 'rspec/matchers'
4
3
 
5
4
  module RSpec::Rails
@@ -70,7 +70,7 @@ EOM
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 @@ EOM
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)
@@ -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.1.0'
5
5
  end
6
6
  end
7
7
  end
@@ -15,6 +15,11 @@ module RSpec
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
@@ -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.1.0"
61
61
  end
62
62
 
@@ -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
@@ -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
@@ -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
@@ -1,16 +1,13 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'arel', :path => "../../vendor/arel"
4
- gem 'rails', :path => "../../vendor/rails"
5
-
3
+ gem "rack", :git => "git://github.com/rack/rack.git"
4
+ gem 'rails', :path => File.expand_path("../../../vendor/rails", __FILE__)
6
5
  gem 'sqlite3-ruby', :require => 'sqlite3'
7
6
 
8
7
  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"
8
+ %w[rspec rspec-core rspec-expectations rspec-mocks rspec-rails].each do |lib|
9
+ gem lib, :path => File.expand_path("../../../../#{lib}", __FILE__)
10
+ end
14
11
  gem "rcov"
15
12
  gem "webrat"
16
13
  gem "autotest"
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
5
4
  prerelease: false
6
5
  segments:
7
6
  - 2
8
- - 0
9
7
  - 1
10
- version: 2.0.1
8
+ - 0
9
+ version: 2.1.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - David Chelimsky
@@ -16,25 +15,24 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2010-10-15 00:00:00 -05:00
18
+ date: 2010-11-07 01:00:00 -05:00
20
19
  default_executable:
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
23
- version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ name: rspec
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
25
25
  requirements:
26
26
  - - ~>
27
27
  - !ruby/object:Gem::Version
28
- hash: 15
29
28
  segments:
30
29
  - 2
30
+ - 1
31
31
  - 0
32
- - 0
33
- version: 2.0.0
34
- requirement: *id001
32
+ version: 2.1.0
35
33
  type: :runtime
36
- name: rspec
37
34
  prerelease: false
35
+ version_requirements: *id001
38
36
  description: RSpec-2 for Rails-3
39
37
  email: dchelimsky@gmail.com;chad.humphries@gmail.com
40
38
  executables: []
@@ -136,6 +134,7 @@ files:
136
134
  - rspec-rails.gemspec
137
135
  - spec/autotest/rails_rspec2_spec.rb
138
136
  - spec/rspec/rails/assertion_adapter_spec.rb
137
+ - spec/rspec/rails/deprecations_spec.rb
139
138
  - spec/rspec/rails/example/controller_example_group_spec.rb
140
139
  - spec/rspec/rails/example/helper_example_group_spec.rb
141
140
  - spec/rspec/rails/example/mailer_example_group_spec.rb
@@ -144,6 +143,8 @@ files:
144
143
  - spec/rspec/rails/example/routing_example_group_spec.rb
145
144
  - spec/rspec/rails/example/view_example_group_spec.rb
146
145
  - spec/rspec/rails/example/view_rendering_spec.rb
146
+ - spec/rspec/rails/extensions/active_model/errors_on_spec.rb
147
+ - spec/rspec/rails/extensions/active_record/records_spec.rb
147
148
  - spec/rspec/rails/fixture_support_spec.rb
148
149
  - spec/rspec/rails/matchers/be_a_new_spec.rb
149
150
  - spec/rspec/rails/matchers/be_new_record_spec.rb
@@ -167,7 +168,7 @@ licenses: []
167
168
  post_install_message: |
168
169
  **************************************************
169
170
 
170
- Thank you for installing rspec-rails-2.0.1!
171
+ Thank you for installing rspec-rails-2.1.0!
171
172
 
172
173
  This version of rspec-rails only works with versions of rails >= 3.0.0
173
174
 
@@ -177,7 +178,7 @@ post_install_message: |
177
178
  can access its generators and rake tasks.
178
179
 
179
180
  group :development, :test do
180
- gem "rspec-rails", ">= 2.0.1"
181
+ gem "rspec-rails", ">= 2.1.0"
181
182
  end
182
183
 
183
184
  Be sure to run the following command in each of your Rails apps if you're
@@ -208,7 +209,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
208
209
  requirements:
209
210
  - - ">="
210
211
  - !ruby/object:Gem::Version
211
- hash: 3
212
+ hash: 101005116309468581
212
213
  segments:
213
214
  - 0
214
215
  version: "0"
@@ -217,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
218
  requirements:
218
219
  - - ">="
219
220
  - !ruby/object:Gem::Version
220
- hash: 3
221
+ hash: 101005116309468581
221
222
  segments:
222
223
  - 0
223
224
  version: "0"
@@ -227,7 +228,7 @@ rubyforge_project: rspec
227
228
  rubygems_version: 1.3.7
228
229
  signing_key:
229
230
  specification_version: 3
230
- summary: rspec-rails-2.0.1
231
+ summary: rspec-rails-2.1.0
231
232
  test_files:
232
233
  - features/README.markdown
233
234
  - features/controller_specs/anonymous_controller.feature
@@ -251,6 +252,7 @@ test_files:
251
252
  - features/view_specs/view_spec.feature
252
253
  - spec/autotest/rails_rspec2_spec.rb
253
254
  - spec/rspec/rails/assertion_adapter_spec.rb
255
+ - spec/rspec/rails/deprecations_spec.rb
254
256
  - spec/rspec/rails/example/controller_example_group_spec.rb
255
257
  - spec/rspec/rails/example/helper_example_group_spec.rb
256
258
  - spec/rspec/rails/example/mailer_example_group_spec.rb
@@ -259,6 +261,8 @@ test_files:
259
261
  - spec/rspec/rails/example/routing_example_group_spec.rb
260
262
  - spec/rspec/rails/example/view_example_group_spec.rb
261
263
  - spec/rspec/rails/example/view_rendering_spec.rb
264
+ - spec/rspec/rails/extensions/active_model/errors_on_spec.rb
265
+ - spec/rspec/rails/extensions/active_record/records_spec.rb
262
266
  - spec/rspec/rails/fixture_support_spec.rb
263
267
  - spec/rspec/rails/matchers/be_a_new_spec.rb
264
268
  - spec/rspec/rails/matchers/be_new_record_spec.rb