rspec-rails 2.4.1 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile-3-0-stable +6 -0
  3. data/Gemfile-3.0.0 +3 -0
  4. data/Gemfile-3.0.3 +3 -0
  5. data/{Gemfile → Gemfile-base} +4 -8
  6. data/Gemfile-master +5 -0
  7. data/History.md +1 -114
  8. data/README.md +2 -2
  9. data/Rakefile +9 -7
  10. data/Thorfile +7 -0
  11. data/Upgrade.md +1 -63
  12. data/features/.nav +5 -4
  13. data/features/Autotest.md +15 -8
  14. data/features/Changelog.md +127 -0
  15. data/features/Upgrade.md +60 -0
  16. data/features/controller_specs/README.md +3 -2
  17. data/features/controller_specs/anonymous_controller.feature +2 -2
  18. data/features/controller_specs/isolation_from_views.feature +2 -2
  19. data/features/controller_specs/render_views.feature +42 -60
  20. data/features/helper_specs/helper_spec.feature +3 -3
  21. data/features/mailer_specs/url_helpers.feature +2 -2
  22. data/features/matchers/new_record_matcher.feature +2 -2
  23. data/features/matchers/redirect_to_matcher.feature +1 -1
  24. data/features/matchers/render_template_matcher.feature +1 -1
  25. data/features/mocks/mock_model.feature +5 -5
  26. data/features/mocks/stub_model.feature +2 -2
  27. data/features/model_specs/errors_on.feature +1 -1
  28. data/features/model_specs/transactional_examples.feature +4 -4
  29. data/features/routing_specs/be_routable_matcher.feature +3 -3
  30. data/features/routing_specs/named_routes.feature +1 -1
  31. data/features/routing_specs/route_to_matcher.feature +1 -1
  32. data/features/step_definitions/{rspec_steps.rb → additional_cli_steps.rb} +1 -2
  33. data/features/view_specs/inferred_controller_path.feature +3 -3
  34. data/features/view_specs/stub_template.feature +2 -2
  35. data/features/view_specs/view_spec.feature +8 -8
  36. data/lib/generators/rspec/integration/templates/request_spec.rb +2 -2
  37. data/lib/generators/rspec/scaffold/templates/controller_spec.rb +1 -1
  38. data/lib/generators/rspec/scaffold/templates/edit_spec.rb +1 -1
  39. data/lib/generators/rspec/scaffold/templates/new_spec.rb +1 -1
  40. data/lib/rspec/rails/example.rb +5 -3
  41. data/lib/rspec/rails/example/controller_example_group.rb +10 -6
  42. data/lib/rspec/rails/example/request_example_group.rb +1 -1
  43. data/lib/rspec/rails/mocks.rb +6 -0
  44. data/lib/rspec/rails/version.rb +1 -1
  45. data/lib/rspec/rails/view_rendering.rb +1 -1
  46. data/spec/rspec/rails/mocks/ar_classes.rb +13 -25
  47. data/spec/rspec/rails/mocks/mock_model_spec.rb +6 -0
  48. data/spec/rspec/rails/mocks/stub_model_spec.rb +9 -4
  49. data/spec/rspec/rails/view_rendering_spec.rb +7 -1
  50. data/templates/Gemfile-base +17 -0
  51. metadata +21 -15
  52. data/templates/Gemfile +0 -15
data/.gitignore CHANGED
@@ -6,3 +6,4 @@ doc
6
6
  vendor
7
7
  .bundle
8
8
  Gemfile.lock
9
+ Gemfile
@@ -0,0 +1,6 @@
1
+ instance_eval(File.read("./Gemfile-base"))
2
+
3
+ gem "rails", :git => "https://github.com/rails/rails.git", :branch => "3-0-stable"
4
+ gem "arel", :git => "https://github.com/rails/arel.git"
5
+ gem "rack", :git => "git://github.com/rack/rack.git"
6
+
@@ -0,0 +1,3 @@
1
+ instance_eval(File.read("./Gemfile-base"))
2
+
3
+ gem "rails", "3.0.0"
@@ -0,0 +1,3 @@
1
+ instance_eval(File.read("./Gemfile-base"))
2
+
3
+ gem "rails", "3.0.3"
@@ -1,6 +1,6 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- %w[rspec rspec-core rspec-expectations rspec-mocks].each do |lib|
3
+ %w[rspec rspec-core rspec-expectations rspec-mocks rspec-rails].each do |lib|
4
4
  library_path = File.expand_path("../../#{lib}", __FILE__)
5
5
  if File.exist?(library_path)
6
6
  gem lib, :path => library_path
@@ -9,14 +9,16 @@ source "http://rubygems.org"
9
9
  end
10
10
  end
11
11
 
12
+ gem 'sqlite3-ruby', :require => 'sqlite3'
12
13
  gem "rake", "0.8.7"
13
- gem "cucumber", "0.9.4"
14
+ gem "cucumber", "0.10.0"
14
15
  gem "aruba", "0.2.2"
15
16
  gem "rcov", "0.9.9"
16
17
  gem "relish", "0.2.0"
17
18
  gem "guard-rspec", "0.1.9"
18
19
  gem "growl", "1.0.3"
19
20
  gem "ZenTest", "~> 4.4.2"
21
+ gem "webrat", "0.7.2"
20
22
 
21
23
  if RUBY_PLATFORM =~ /darwin/
22
24
  gem "autotest-fsevent", "~> 0.2.4"
@@ -34,9 +36,3 @@ end
34
36
  platforms :jruby do
35
37
  gem "jruby-openssl"
36
38
  end
37
-
38
- #### rspec-rails only
39
- gem "rails", :path => File.expand_path("../vendor/rails", __FILE__)
40
- gem "rack", :git => "git://github.com/rack/rack.git"
41
- gem 'webrat', "0.7.2"
42
- gem 'sqlite3-ruby', :require => 'sqlite3'
@@ -0,0 +1,5 @@
1
+ instance_eval(File.read("./Gemfile-base"))
2
+
3
+ gem "rails", :git => "https://github.com/rails/rails.git"
4
+ gem "arel", :git => "https://github.com/rails/arel.git"
5
+ gem "rack", :git => "https://github.com/rack/rack.git"
data/History.md CHANGED
@@ -1,114 +1 @@
1
- ## rspec-rails-2 release history
2
-
3
- ### 2.4.1 / 2011-01-03
4
-
5
- [full changelog](http://github.com/rspec/rspec-rails/compare/v2.4.0...2.4.1)
6
-
7
- * Bug fixes
8
- * fixed bug caused by including some Rails modules before RSpec's
9
- RailsExampleGroup
10
-
11
- ### 2.4.0 / 2011-01-02
12
-
13
- [full changelog](http://github.com/rspec/rspec-rails/compare/v2.3.1...2.4.0)
14
-
15
- * Enhancements
16
- * include ApplicationHelper in helper object in helper specs
17
- * include request spec extensions in files in spec/integration
18
- * include controller spec extensions in groups that use :type => :controller
19
- * same for :model, :view, :helper, :mailer, :request, :routing
20
-
21
- * Bug fixes
22
- * restore global config.render_views so you only need to say it once
23
- * support overriding render_views in nested groups
24
- * matchers that delegate to Rails' assertions capture
25
- ActiveSupport::TestCase::Assertion (so they work properly now with
26
- should_not in Ruby 1.8.7 and 1.9.1)
27
-
28
- * Deprecations
29
- * include_self_when_dir_matches
30
-
31
- ### 2.3.1 / 2010-12-16
32
-
33
- [full changelog](http://github.com/rspec/rspec-rails/compare/v2.3.0...v2.3.1)
34
-
35
- * Bug fixes
36
- * respond_to? correctly handles 2 args
37
- * scaffold generator no longer fails on autotest directory
38
-
39
- ### 2.3.0 / 2010-12-12
40
-
41
- [full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.1...v2.3.0)
42
-
43
- * Changes
44
- * Generator no longer generates autotest/autodiscover.rb, as it is no longer
45
- needed (as of rspec-core-2.3.0)
46
-
47
- ### 2.2.1 / 2010-12-01
48
-
49
- [full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.0...v2.2.1)
50
-
51
- * Bug fixes
52
- * Depend on railties, activesupport, and actionpack instead of rails (Piotr
53
- Solnica)
54
- * Got webrat integration working properly across different types of specs
55
-
56
- * Deprecations
57
- * --webrat-matchers flag for generators is deprecated. use --webrat instead.
58
-
59
- ### 2.2.0 / 2010-11-28
60
-
61
- [full changelog](http://github.com/rspec/rspec-rails/compare/v2.1.0...v2.2.0)
62
-
63
- * Enhancements
64
- * Added stub_template in view specs
65
-
66
- * Bug fixes
67
- * Properly include helpers in views (Jonathan del Strother)
68
- * Fix bug in which method missing led to a stack overflow
69
- * Fix stack overflow in request specs with open_session
70
- * Fix stack overflow in any spec when method_missing was invoked
71
- * Add gem dependency on rails ~> 3.0.0 (ensures bundler won't install
72
- rspec-rails-2 with rails-2 apps).
73
-
74
- ### 2.1.0 / 2010-11-07
75
-
76
- [full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.1...v2.1.0)
77
-
78
- * Enhancements
79
- * Move errors_on to ActiveModel to support other AM-compliant ORMs
80
-
81
- * Bug fixes
82
- * Check for presence of ActiveRecord instead of checking Rails config
83
- (gets rspec out of the way of multiple ORMs in the same app)
84
-
85
- ### 2.0.1 / 2010-10-15
86
-
87
- [full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.0...v2.0.1)
88
-
89
- * Enhancements
90
- * Add option to not generate request spec (--skip-request-specs)
91
-
92
- * Bug fixes
93
- * Updated the mock_[model] method generated in controller specs so it adds
94
- any stubs submitted each time it is called.
95
- * Fixed bug where view assigns weren't making it to the view in view specs in Rails-3.0.1.
96
- (Emanuele Vicentini)
97
-
98
- ### 2.0.0 / 2010-10-10
99
-
100
- [full changelog](https://github.com/rspec/rspec-rails/compare/ea6bdef...v2.0.0)
101
-
102
- * Enhancements
103
- * ControllerExampleGroup uses controller as the implicit subject by default (Paul Rosania)
104
- * autotest mapping improvements (Andreas Neuhaus)
105
- * more cucumber features (Justin Ko)
106
- * clean up spec helper (Andre Arko)
107
- * add assign(name, value) to helper specs (Justin Ko)
108
- * stub_model supports primary keys other than id (Justin Ko)
109
- * support choice between Webrat/Capybara (Justin Ko)
110
- * support specs for 'abstract' subclasses of ActionController::Base (Mike Gehard)
111
- * be_a_new matcher supports args (Justin Ko)
112
-
113
- * Bug fixes
114
- * support T::U components in mailer and request specs (Brasten Sager)
1
+ See features/Changelog.md
data/README.md CHANGED
@@ -9,7 +9,7 @@ NOTE: rspec-2 does _not_ support rails-2. Use rspec-rails-1.3.x for rails-2.
9
9
  The [Cucumber features](http://relishapp.com/rspec/rspec-rails) are the
10
10
  most comprehensive and up-to-date docs for end-users.
11
11
 
12
- The [RDoc](http://rubydoc.info/gems/rspec-rails/2.3.0/frames) provides additional
12
+ The [RDoc](http://rubydoc.info/gems/rspec-rails/2.4.0/frames) provides additional
13
13
  information for contributors and/or extenders.
14
14
 
15
15
  All of the documentation is open source and a work in progress. If you find it
@@ -34,7 +34,7 @@ This installs the following gems:
34
34
  Add `rspec-rails` to the `:test` and `:development` groups in the Gemfile:
35
35
 
36
36
  group :test, :development do
37
- gem "rspec-rails", "~> 2.0.1"
37
+ gem "rspec-rails", "~> 2.4"
38
38
  end
39
39
 
40
40
  It needs to be in the `:development` group to expose generators and rake
data/Rakefile CHANGED
@@ -1,10 +1,12 @@
1
- unless File.directory?("vendor/rails")
1
+ unless File.exist?('./Gemfile')
2
2
  raise <<-MESSAGE
3
- You need to clone the rails git repository into ./vendor before you can use any
4
- of the rake tasks.
5
-
6
- git clone git://github.com/rails/rails.git vendor/rails
3
+ Could not find a Gemfile. Please run any of:
4
+ thor rails:use 3-0-stable
5
+ thor rails:use master
6
+ thor rails:use 3.0.0
7
+ thor rails:use 3.0.3
7
8
 
9
+ And then run 'bundle install'
8
10
  MESSAGE
9
11
  end
10
12
  require "bundler"
@@ -54,8 +56,8 @@ namespace :generate do
54
56
  task :app do |t|
55
57
  unless File.directory?('./tmp/example_app')
56
58
  sh "bundle exec rails new ./tmp/example_app"
57
- sh "cp ./templates/Gemfile ./tmp/example_app/"
58
- sh "cp ./specs.watchr ./tmp/example_app/"
59
+ sh "cp ./templates/Gemfile-base ./tmp/example_app/"
60
+ sh "cp ./Gemfile ./tmp/example_app/"
59
61
  end
60
62
  end
61
63
 
data/Thorfile CHANGED
@@ -15,4 +15,11 @@ class Rails < Thor
15
15
  `git fetch`
16
16
  end
17
17
  end
18
+
19
+ desc "use VERSION", "copies the appropriate Gemfile to Gemfile"
20
+ def use(version)
21
+ `cp ./Gemfile-#{version} ./Gemfile`
22
+ `rm ./Gemfile.lock`
23
+ system "bundle install"
24
+ end
18
25
  end
data/Upgrade.md CHANGED
@@ -1,63 +1 @@
1
- # rspec-rails-2.3.0
2
-
3
- ## autotest integration
4
-
5
- Add a .rspec file to the project's root directory (if not already there) to
6
- tell RSpec to tell Autotest to use RSpec's specialized Autotest class.
7
-
8
- NOTE that rspec-core-2.0, 2.1, and 2.2 required an autotest/discover.rb file in
9
- the project's root directory. This worked with some, but not all versions of
10
- autotest and/or the autotest command that ships with ZenTest. This new approach
11
- will work regardless of which version of autotest/ZenTest you are using.
12
-
13
- ## Webrat and Capybara
14
-
15
- Earlier 2.0.0.beta versions depended on Webrat. As of
16
- rspec-rails-2.0.0.beta.20, this dependency and offers you a choice of using
17
- webrat or capybara. Just add the library of your choice to your Gemfile.
18
-
19
- ## Controller specs
20
-
21
- ### islation from view templates
22
-
23
- By default, controller specs do _not_ render view templates. This keeps
24
- controller specs isolated from the content of views and their requirements.
25
-
26
- NOTE that the template must exist, but it will not be rendered. This is
27
- different from rspec-rails-1.x, in which the template didn't need to exist, but
28
- ActionController makes a number of new decisions in Rails 3 based on the
29
- existence of the template. To keep the RSpec code free of monkey patches, and
30
- to keep the rspec user experience simpler, we decided that this would be a fair
31
- trade-off.
32
-
33
- ## View specs
34
-
35
- ### view.should render_template
36
-
37
- Rails changed the way it renders partials, so to set an expectation that a
38
- partial gets rendered, you need
39
-
40
- render
41
- view.should render_template(:partial => "widget/_row")
42
-
43
- ### stub_template
44
-
45
- Introduced in rspec-rails-2.2, simulates the presence of view templates on the
46
- file system. This supports isolation from partials rendered by the vew template
47
- that is the subject of a view example:
48
-
49
- stub_template "widgets/_widget.html.erb" => "This Content"
50
-
51
- ### as_new_record
52
-
53
- Earlier versions of the view generators generated stub_model with `:new_record?
54
- => true`. That is no longer recognized in rspec-rails-2, so you need to change
55
- this:
56
-
57
- stub_model(Widget, :new_record? => true)
58
-
59
- to this:
60
-
61
- stub_model(Widget).as_new_record
62
-
63
- Generators in 2.0.0 final release will do the latter.
1
+ See features/Upgrade.md
@@ -1,8 +1,9 @@
1
- - GettingStarted.md (Getting started)
2
- - Upgrade.md
3
- - Generators.md (Rails generators)
4
- - Autotest.md (Autotest integration)
1
+ - GettingStarted.md (Start from scratch)
2
+ - Generators.md (Generators)
5
3
  - transactional_examples.feature
4
+ - Autotest.md (Autotest integration)
5
+ - Changelog.md
6
+ - Upgrade.md
6
7
  - model_specs:
7
8
  - errors_on.feature
8
9
  - controller_specs:
@@ -1,10 +1,17 @@
1
- The rspec:install generator creates a .rspec file, which tells RSpec to tell
2
- Autotest that you're using RSpec and Rails. You'll also need to add the ZenTest
3
- gem to your Gemfile:
1
+ The `rspec:install` generator creates a `.rspec` file, which tells RSpec to
2
+ tell Autotest that you're using RSpec. You'll also need to add the ZenTest and
3
+ autotest-rails gems to your Gemfile:
4
4
 
5
- gem "ZenTest"
5
+ gem "ZenTest", "~> 4.4.2"
6
+ gem "autotest-rails", "~> 4.1.0"
7
+
8
+ If all of the gems in your Gemfile are installed in system gems, you can just
9
+ type
10
+
11
+ autotest
12
+
13
+ If Bundler is managing any gems for you directly (i.e. you've got `:git` or
14
+ `:path` attributes in the Gemfile), however, you may need to run
15
+
16
+ bundle exec autotest
6
17
 
7
- At this point, if all of the gems in your Gemfile are installed in system gems,
8
- you can just type autotest. If, however, Bundler is managing any gems for you
9
- directly (i.e. you've got :git or :path attributes in the Gemfile), you'll need
10
- to run bundle exec autotest.
@@ -0,0 +1,127 @@
1
+ ### 2.5.0 / 2011-02-05
2
+
3
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.4.1...v2.5.0)
4
+
5
+ * Enhancements
6
+ * use index_helper instead of table_name when generating specs (Reza
7
+ Primardiansyah)
8
+
9
+ * Bug fixes
10
+ * fixed bug in which `render_views` in a nested group set the value in its
11
+ parent group.
12
+ * only include MailerExampleGroup when it is defiend (Steve Sloan)
13
+ * mock_model.as_null_object.attribute.blank? returns false (Randy Schmidt)
14
+ * fix typo in request specs (Paco Guzman)
15
+
16
+ ### 2.4.1 / 2011-01-03
17
+
18
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.4.0...v2.4.1)
19
+
20
+ * Bug fixes
21
+ * fixed bug caused by including some Rails modules before RSpec's
22
+ RailsExampleGroup
23
+
24
+ ### 2.4.0 / 2011-01-02
25
+
26
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.3.1...v2.4.0)
27
+
28
+ * Enhancements
29
+ * include ApplicationHelper in helper object in helper specs
30
+ * include request spec extensions in files in spec/integration
31
+ * include controller spec extensions in groups that use :type => :controller
32
+ * same for :model, :view, :helper, :mailer, :request, :routing
33
+
34
+ * Bug fixes
35
+ * restore global config.render_views so you only need to say it once
36
+ * support overriding render_views in nested groups
37
+ * matchers that delegate to Rails' assertions capture
38
+ ActiveSupport::TestCase::Assertion (so they work properly now with
39
+ should_not in Ruby 1.8.7 and 1.9.1)
40
+
41
+ * Deprecations
42
+ * include_self_when_dir_matches
43
+
44
+ ### 2.3.1 / 2010-12-16
45
+
46
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.3.0...v2.3.1)
47
+
48
+ * Bug fixes
49
+ * respond_to? correctly handles 2 args
50
+ * scaffold generator no longer fails on autotest directory
51
+
52
+ ### 2.3.0 / 2010-12-12
53
+
54
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.1...v2.3.0)
55
+
56
+ * Changes
57
+ * Generator no longer generates autotest/autodiscover.rb, as it is no longer
58
+ needed (as of rspec-core-2.3.0)
59
+
60
+ ### 2.2.1 / 2010-12-01
61
+
62
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.0...v2.2.1)
63
+
64
+ * Bug fixes
65
+ * Depend on railties, activesupport, and actionpack instead of rails (Piotr
66
+ Solnica)
67
+ * Got webrat integration working properly across different types of specs
68
+
69
+ * Deprecations
70
+ * --webrat-matchers flag for generators is deprecated. use --webrat instead.
71
+
72
+ ### 2.2.0 / 2010-11-28
73
+
74
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.1.0...v2.2.0)
75
+
76
+ * Enhancements
77
+ * Added stub_template in view specs
78
+
79
+ * Bug fixes
80
+ * Properly include helpers in views (Jonathan del Strother)
81
+ * Fix bug in which method missing led to a stack overflow
82
+ * Fix stack overflow in request specs with open_session
83
+ * Fix stack overflow in any spec when method_missing was invoked
84
+ * Add gem dependency on rails ~> 3.0.0 (ensures bundler won't install
85
+ rspec-rails-2 with rails-2 apps).
86
+
87
+ ### 2.1.0 / 2010-11-07
88
+
89
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.1...v2.1.0)
90
+
91
+ * Enhancements
92
+ * Move errors_on to ActiveModel to support other AM-compliant ORMs
93
+
94
+ * Bug fixes
95
+ * Check for presence of ActiveRecord instead of checking Rails config
96
+ (gets rspec out of the way of multiple ORMs in the same app)
97
+
98
+ ### 2.0.1 / 2010-10-15
99
+
100
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.0...v2.0.1)
101
+
102
+ * Enhancements
103
+ * Add option to not generate request spec (--skip-request-specs)
104
+
105
+ * Bug fixes
106
+ * Updated the mock_[model] method generated in controller specs so it adds
107
+ any stubs submitted each time it is called.
108
+ * Fixed bug where view assigns weren't making it to the view in view specs in Rails-3.0.1.
109
+ (Emanuele Vicentini)
110
+
111
+ ### 2.0.0 / 2010-10-10
112
+
113
+ [full changelog](https://github.com/rspec/rspec-rails/compare/ea6bdef...v2.0.0)
114
+
115
+ * Enhancements
116
+ * ControllerExampleGroup uses controller as the implicit subject by default (Paul Rosania)
117
+ * autotest mapping improvements (Andreas Neuhaus)
118
+ * more cucumber features (Justin Ko)
119
+ * clean up spec helper (Andre Arko)
120
+ * add assign(name, value) to helper specs (Justin Ko)
121
+ * stub_model supports primary keys other than id (Justin Ko)
122
+ * support choice between Webrat/Capybara (Justin Ko)
123
+ * support specs for 'abstract' subclasses of ActionController::Base (Mike Gehard)
124
+ * be_a_new matcher supports args (Justin Ko)
125
+
126
+ * Bug fixes
127
+ * support T::U components in mailer and request specs (Brasten Sager)