rspec-rails 2.6.1 → 2.7.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. data/README.md +5 -5
  2. data/features/Transactions.md +84 -0
  3. data/features/controller_specs/Cookies.md +57 -0
  4. data/features/controller_specs/anonymous_controller.feature +104 -61
  5. data/features/controller_specs/bypass_rescue.feature +75 -0
  6. data/features/matchers/relation_match_array.feature +20 -0
  7. data/features/mocks/mock_model.feature +6 -6
  8. data/features/support/env.rb +2 -2
  9. data/features/view_specs/view_spec.feature +2 -8
  10. data/lib/autotest/rails_rspec2.rb +1 -1
  11. data/lib/generators/rspec/controller/templates/controller_spec.rb +1 -1
  12. data/lib/generators/rspec/install/templates/spec/spec_helper.rb +6 -0
  13. data/lib/generators/rspec/scaffold/templates/controller_spec.rb +6 -6
  14. data/lib/generators/rspec/view/templates/view_spec.rb +1 -1
  15. data/lib/rspec/rails/example/controller_example_group.rb +19 -1
  16. data/lib/rspec/rails/fixture_support.rb +11 -0
  17. data/lib/rspec/rails/matchers.rb +1 -0
  18. data/lib/rspec/rails/matchers/relation_match_array.rb +3 -0
  19. data/lib/rspec/rails/matchers/routing_matchers.rb +16 -14
  20. data/lib/rspec/rails/mocks.rb +12 -7
  21. data/lib/rspec/rails/version.rb +1 -1
  22. data/spec/generators/rspec/controller/controller_generator_spec.rb +86 -0
  23. data/spec/generators/rspec/helper/helper_generator_spec.rb +30 -0
  24. data/spec/generators/rspec/install/install_generator_spec.rb +18 -0
  25. data/spec/generators/rspec/integration/integration_generator_spec.rb +44 -0
  26. data/spec/generators/rspec/mailer/mailer_generator_spec.rb +48 -0
  27. data/spec/generators/rspec/model/model_generator_spec.rb +52 -0
  28. data/spec/generators/rspec/observer/observer_generator_spec.rb +21 -0
  29. data/spec/generators/rspec/scaffold/scaffold_generator_spec.rb +113 -0
  30. data/spec/generators/rspec/view/view_generator_spec.rb +41 -0
  31. data/spec/rspec/rails/example/controller_example_group_spec.rb +39 -3
  32. data/spec/rspec/rails/matchers/relation_match_array_spec.rb +19 -0
  33. data/spec/rspec/rails/matchers/route_to_spec.rb +25 -3
  34. data/spec/rspec/rails/mocks/mock_model_spec.rb +62 -2
  35. data/spec/rspec/rails/mocks/stub_model_spec.rb +0 -1
  36. data/spec/spec_helper.rb +2 -1
  37. data/spec/{rspec/rails/mocks → support}/ar_classes.rb +5 -2
  38. metadata +102 -99
  39. data/.document +0 -5
  40. data/.gitignore +0 -14
  41. data/.rspec +0 -1
  42. data/.travis.yml +0 -11
  43. data/History.md +0 -1
  44. data/License.txt +0 -23
  45. data/README_DEV.md +0 -43
  46. data/Rakefile +0 -152
  47. data/Thorfile +0 -45
  48. data/Upgrade.md +0 -1
  49. data/cucumber.yml +0 -3
  50. data/features/.nav +0 -35
  51. data/features/Changelog.md +0 -162
  52. data/gemfiles/.bundle/config +0 -2
  53. data/gemfiles/base.rb +0 -60
  54. data/gemfiles/rails-3-0-stable +0 -6
  55. data/gemfiles/rails-3.0.0 +0 -5
  56. data/gemfiles/rails-3.0.1 +0 -5
  57. data/gemfiles/rails-3.0.2 +0 -5
  58. data/gemfiles/rails-3.0.3 +0 -5
  59. data/gemfiles/rails-3.0.4 +0 -5
  60. data/gemfiles/rails-3.0.5 +0 -5
  61. data/gemfiles/rails-3.0.6 +0 -5
  62. data/gemfiles/rails-3.0.7 +0 -5
  63. data/gemfiles/rails-3.1.0.rc1 +0 -5
  64. data/gemfiles/rails-master +0 -5
  65. data/rspec-rails.gemspec +0 -34
  66. data/templates/generate_stuff.rb +0 -21
  67. data/templates/run_specs.rb +0 -9
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.markdown
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- License.txt
data/.gitignore DELETED
@@ -1,14 +0,0 @@
1
- tmp
2
- doc
3
- pkg
4
- vendor
5
- !lib/rspec/rails/vendor
6
- *.gem
7
- Gemfile
8
- Gemfile.lock
9
- gemfiles/*.lock
10
- gemfiles/bin/*
11
- bin
12
- .rvmrc
13
- *.rbc
14
- .gemfile
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --color
@@ -1,11 +0,0 @@
1
- script: "gemfiles/bin/rake --trace 2>&1"
2
- rvm:
3
- - 1.8.7
4
- - 1.9.2
5
- gemfile:
6
- - gemfiles/rails-3.0.7
7
- - gemfiles/rails-3.1.0.rc1
8
- - gemfiles/rails-master
9
- bundler_args: "--binstubs"
10
- env:
11
- - CI=true
data/History.md DELETED
@@ -1 +0,0 @@
1
- See features/Changelog.md
@@ -1,23 +0,0 @@
1
- (The MIT License)
2
-
3
- Copyright (c) 2009 David Chelimsky
4
- Copyright (c) 2005 The RSpec Development Team
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining
7
- a copy of this software and associated documentation files (the
8
- "Software"), to deal in the Software without restriction, including
9
- without limitation the rights to use, copy, modify, merge, publish,
10
- distribute, sublicense, and/or sell copies of the Software, and to
11
- permit persons to whom the Software is furnished to do so, subject to
12
- the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be
15
- included in all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,43 +0,0 @@
1
- # Information for rspec-rails developers
2
-
3
- rspec-rails lives in a complicated ecosystem. We need to run it against
4
- multiple versions of rails and multiple versions of Ruby as well. There are
5
- several tools already available to manage running against multiple versions of
6
- Ruby (e.g. rvm), and there are even some multi-rails tools (e.g. multi-rails)
7
- but we haven't found one that does exactly what we need here, so we've rolled
8
- our own.
9
-
10
- ## The short version
11
-
12
- thor rails:use 3.0.6
13
- rake
14
-
15
- ## The long version
16
-
17
- ### thor rails:use
18
-
19
- The `thor rails:use` task accepts any released version of rails, or either the
20
- 3-0-stable or master branches.
21
-
22
- thor rails:use master
23
- thor rails:use 3-0-stable
24
- thor rails:use 3.0.6
25
- thor rails:use 3.0.5
26
- thor rails:use 3.0.4
27
- thor rails:use 3.0.3
28
- thor rails:use 3.0.2
29
- thor rails:use 3.0.1
30
- thor rails:use 3.0.0
31
-
32
- It then does several things:
33
-
34
- * generates a .gemfile file with the version listed. This is used internally by
35
- assorted rake tasks.
36
- * installs the bundle using the appropriate file in the gemfiles directory
37
- ** this includes binstubs, which are stored in ./gemfiles/bin
38
- * symlinks the gemfiles/bin directory to ./bin (in the project root) to support
39
- running bin/rspec from the project root
40
-
41
- At any time, if you want to change rails versions, run `thor rails:use` with a
42
- new version number. To play it safe, you probably want to also run `rake
43
- clobber` to delete all the code generated by the previous rails version.
data/Rakefile DELETED
@@ -1,152 +0,0 @@
1
- require 'pathname'
2
- ENV["BUNDLE_GEMFILE"] ||= begin
3
- version = if File.exist?("./.gemfile")
4
- File.read("./.gemfile").chomp
5
- else
6
- "rails-3.0.7"
7
- end
8
- File.expand_path("../gemfiles/#{version}", __FILE__)
9
- end
10
- puts "Using gemfile: #{ENV["BUNDLE_GEMFILE"].gsub(Pathname.new(__FILE__).dirname.to_s,'').sub(/^\//,'')}"
11
- require "bundler"
12
- begin
13
- Bundler.setup
14
- rescue
15
- if ENV["CI"]
16
- sh "bundle install"
17
- Bundler.setup
18
- else
19
- raise "You need to install a bundle first. Try 'thor gemfile:use 3.0.7'"
20
- end
21
- end
22
- Bundler::GemHelper.install_tasks
23
-
24
- task :build => :raise_if_psych_is_defined
25
-
26
- task :raise_if_psych_is_defined do
27
- if defined?(Psych)
28
- raise <<-MSG
29
- ===============================================================================
30
- Gems compiled in Ruby environments with Psych loaded are incompatible with Ruby
31
- environments that don't have Psych loaded. Try building this gem in Ruby 1.8.7
32
- instead.
33
- ===============================================================================
34
- MSG
35
- end
36
- end
37
-
38
- require 'yaml'
39
- require 'rspec'
40
- require 'rspec/core/rake_task'
41
-
42
- begin
43
- require 'cucumber/rake/task'
44
-
45
- Cucumber::Rake::Task.new(:cucumber)
46
-
47
- namespace :cucumber do
48
- desc "Run cucumber features using rcov"
49
- Cucumber::Rake::Task.new :rcov => :cleanup_rcov_files do |t|
50
- t.cucumber_opts = %w{--format progress}
51
- t.rcov = true
52
- t.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,features"]
53
- t.rcov_opts << %[--text-report --sort coverage --aggregate coverage.data]
54
- end
55
- end
56
- rescue LoadError
57
- puts "unable to load cucumber, some tasks unavailable"
58
- task :cucumber do
59
- # no-op
60
- end
61
- end
62
- task :cleanup_rcov_files do
63
- rm_rf 'coverage.data'
64
- end
65
-
66
- desc "Run all examples"
67
- RSpec::Core::RakeTask.new(:spec) do |t|
68
- t.rspec_opts = %w[--color]
69
- end
70
-
71
-
72
- namespace :spec do
73
- desc "Run all examples using rcov"
74
- RSpec::Core::RakeTask.new :rcov => :cleanup_rcov_files do |t|
75
- t.rcov = true
76
- t.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,features"]
77
- t.rcov_opts << %[--text-report --sort coverage --no-html --aggregate coverage.data]
78
- end
79
- end
80
-
81
- namespace :generate do
82
- desc "generate a fresh app with rspec installed"
83
- task :app do |t|
84
- unless File.directory?('./tmp/example_app')
85
- sh "rails new ./tmp/example_app --skip-javascript --skip-gemfile --skip-git"
86
- bindir = File.expand_path("gemfiles/bin")
87
- if test ?d, bindir
88
- Dir.chdir("./tmp/example_app") do
89
- sh "rm -rf test"
90
- sh "ln -s #{bindir}"
91
- application_file = File.read("config/application.rb")
92
- sh "rm config/application.rb"
93
- File.open("config/application.rb","w") do |f|
94
- f.write application_file.gsub("config.assets.enabled = true","config.assets.enabled = false")
95
- end
96
- end
97
- end
98
- end
99
- end
100
-
101
- desc "generate a bunch of stuff with generators"
102
- task :stuff do
103
- in_example_app "bin/rake rails:template LOCATION='../../templates/generate_stuff.rb'"
104
- end
105
- end
106
-
107
- def in_example_app(command)
108
- Dir.chdir("./tmp/example_app/") do
109
- Bundler.with_clean_env do
110
- sh command
111
- end
112
- end
113
- end
114
-
115
- namespace :db do
116
- task :migrate do
117
- in_example_app "bin/rake db:migrate"
118
- end
119
-
120
- namespace :test do
121
- task :prepare do
122
- in_example_app "bin/rake db:test:prepare"
123
- end
124
- end
125
- end
126
-
127
- desc "run a variety of specs against the generated app"
128
- task :smoke do
129
- in_example_app "bin/rake rails:template --trace LOCATION='../../templates/run_specs.rb'"
130
- end
131
-
132
- desc 'clobber generated files'
133
- task :clobber do
134
- rm_rf "pkg"
135
- rm_rf "tmp"
136
- rm "Gemfile.lock" if File.exist?("Gemfile.lock")
137
- end
138
-
139
- namespace :clobber do
140
- desc "clobber the generated app"
141
- task :app do
142
- rm_rf "tmp/example_app"
143
- end
144
- end
145
-
146
- desc "Push docs/cukes to relishapp using the relish-client-gem"
147
- task :relish, :version do |t, args|
148
- raise "rake relish[VERSION]" unless args[:version]
149
- sh "relish push rspec/rspec-rails:#{args[:version]}"
150
- end
151
-
152
- task :default => [:spec, "clobber:app", "generate:app", "generate:stuff", :smoke, :cucumber]
data/Thorfile DELETED
@@ -1,45 +0,0 @@
1
- class Gemfile < Thor
2
- desc "use VERSION", "installs the bundle using gemfiles/rails-VERSION"
3
- def use(version)
4
- with(version, %w[bundle install --binstubs])
5
- unless version =~ /^\d\.\d\.\d/
6
- "bundle update rails".tap do |m|
7
- say m
8
- system m
9
- end
10
- end
11
- say `ln -s gemfiles/bin` unless File.exist?('bin')
12
- `echo rails-#{version} > ./.gemfile`
13
- end
14
-
15
- desc "with VERSION COMMAND", "executes COMMAND with the gemfile for VERSION"
16
- def with(version, *command)
17
- "gemfiles/rails-#{version}".tap do |gemfile|
18
- ENV["BUNDLE_GEMFILE"] = File.expand_path(gemfile)
19
- say "BUNDLE_GEMFILE=#{gemfile}"
20
- end
21
- command.join(' ').tap do |m|
22
- say m
23
- system m
24
- end
25
- end
26
-
27
- desc "which", "print out the configured gemfile"
28
- def which
29
- say `cat ./.gemfile`
30
- end
31
-
32
- desc "list", "list the available options for 'thor gemfile:use'"
33
- def list
34
- all = `ls gemfiles`.chomp.split.grep(/^rails/).reject {|i| i =~ /lock$/}
35
-
36
- versions = all.grep(/^rails-\d\.\d/)
37
- branches = all - versions
38
-
39
- puts "releases:"
40
- versions.sort.reverse.each {|i| puts i}
41
- puts
42
- puts "branches:"
43
- branches.sort.reverse.each {|i| puts i}
44
- end
45
- end
data/Upgrade.md DELETED
@@ -1 +0,0 @@
1
- See features/Upgrade.md
@@ -1,3 +0,0 @@
1
- default: --require features --format progress --tags ~@wip
2
- pretty: --require features --format pretty --tags ~@wip
3
- wip: --require features --tags @wip
@@ -1,35 +0,0 @@
1
- - GettingStarted.md (Start from scratch)
2
- - Generators.md (Generators)
3
- - transactional_examples.feature
4
- - Autotest.md (Autotest integration)
5
- - Changelog.md
6
- - Upgrade.md
7
- - RailsVersions.md (Rails versions)
8
- - request_specs:
9
- - request_spec.feature
10
- - model_specs:
11
- - errors_on.feature
12
- - controller_specs:
13
- - controller_spec.feature
14
- - isolation_from_views.feature
15
- - render_views.feature
16
- - anonymous_controller.feature
17
- - helper_specs:
18
- - helper_spec.feature
19
- - mailer_specs:
20
- - url_helpers.feature
21
- - routing_specs:
22
- - route_to_matcher.feature
23
- - be_routable_matcher.feature
24
- - named_routes.feature
25
- - view_specs:
26
- - view_spec.feature
27
- - stub_template.feature
28
- - inferred_controller_path.feature
29
- - matchers:
30
- - new_record_matcher.feature
31
- - render_template_matcher.feature
32
- - redirect_to_matcher.feature
33
- - mocks:
34
- - mock_model.feature
35
- - stub_model.feature
@@ -1,162 +0,0 @@
1
- ### 2.6.1 / 2011-05-25
2
-
3
- [full changelog](http://github.com/rspec/rspec-rails/compare/v2.6.0...v2.6.1)
4
-
5
- This release is compatible with rails-3.1.0.rc1, but not rails-3.1.0.beta1
6
-
7
- * Bug fixes
8
- * fix controller specs with anonymous controllers with around filters
9
- * exclude spec directory from rcov metrics
10
- * guard against calling prerequisites on nil default rake task (Jack Dempsey)
11
-
12
- ### 2.6.0 / 2011-05-12
13
-
14
- [full changelog](http://github.com/rspec/rspec-rails/compare/v2.5.0...v2.6.0)
15
-
16
- * Enhancements
17
- * rails 3 shortcuts for routing specs (Joe Fiorini)
18
- * support nested resources in generators (Tim McEwan)
19
- * require 'rspec/rails/mocks' to use `mock_model` without requiring the whole
20
- rails framework
21
- * Update the controller spec generated by the rails scaffold generator:
22
- * Add documentation to the generated spec
23
- * Use `any_instance` to avoid stubbing finders
24
- * Use real objects instead of `mock_model`
25
- * Update capybara integration to work with capy 0.4 and 1.0.0.beta
26
- * Decorate paths passed to `[append|prepend]_view_paths` with empty templates
27
- unless rendering views. (Mark Turner)
28
-
29
- * Bug fixes
30
- * fix typo in "rake spec:statsetup" (Curtis Schofield)
31
- * expose named routes in anonymous controller specs (Andy Lindeman)
32
- * error when generating namespaced scaffold resources (Andy Lindeman)
33
- * Fix load order issue w/ Capybara (oleg dashevskii)
34
- * Fix monkey patches that broke due to internal changes in rails-3.1.0.beta1
35
-
36
- ### 2.5.0 / 2011-02-05
37
-
38
- [full changelog](http://github.com/rspec/rspec-rails/compare/v2.4.1...v2.5.0)
39
-
40
- * Enhancements
41
- * use index_helper instead of table_name when generating specs (Reza
42
- Primardiansyah)
43
-
44
- * Bug fixes
45
- * fixed bug in which `render_views` in a nested group set the value in its
46
- parent group.
47
- * only include MailerExampleGroup when it is defined (Steve Sloan)
48
- * mock_model.as_null_object.attribute.blank? returns false (Randy Schmidt)
49
- * fix typo in request specs (Paco Guzman)
50
-
51
- ### 2.4.1 / 2011-01-03
52
-
53
- [full changelog](http://github.com/rspec/rspec-rails/compare/v2.4.0...v2.4.1)
54
-
55
- * Bug fixes
56
- * fixed bug caused by including some Rails modules before RSpec's
57
- RailsExampleGroup
58
-
59
- ### 2.4.0 / 2011-01-02
60
-
61
- [full changelog](http://github.com/rspec/rspec-rails/compare/v2.3.1...v2.4.0)
62
-
63
- * Enhancements
64
- * include ApplicationHelper in helper object in helper specs
65
- * include request spec extensions in files in spec/integration
66
- * include controller spec extensions in groups that use :type => :controller
67
- * same for :model, :view, :helper, :mailer, :request, :routing
68
-
69
- * Bug fixes
70
- * restore global config.render_views so you only need to say it once
71
- * support overriding render_views in nested groups
72
- * matchers that delegate to Rails' assertions capture
73
- ActiveSupport::TestCase::Assertion (so they work properly now with
74
- should_not in Ruby 1.8.7 and 1.9.1)
75
-
76
- * Deprecations
77
- * include_self_when_dir_matches
78
-
79
- ### 2.3.1 / 2010-12-16
80
-
81
- [full changelog](http://github.com/rspec/rspec-rails/compare/v2.3.0...v2.3.1)
82
-
83
- * Bug fixes
84
- * respond_to? correctly handles 2 args
85
- * scaffold generator no longer fails on autotest directory
86
-
87
- ### 2.3.0 / 2010-12-12
88
-
89
- [full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.1...v2.3.0)
90
-
91
- * Changes
92
- * Generator no longer generates autotest/autodiscover.rb, as it is no longer
93
- needed (as of rspec-core-2.3.0)
94
-
95
- ### 2.2.1 / 2010-12-01
96
-
97
- [full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.0...v2.2.1)
98
-
99
- * Bug fixes
100
- * Depend on railties, activesupport, and actionpack instead of rails (Piotr
101
- Solnica)
102
- * Got webrat integration working properly across different types of specs
103
-
104
- * Deprecations
105
- * --webrat-matchers flag for generators is deprecated. use --webrat instead.
106
-
107
- ### 2.2.0 / 2010-11-28
108
-
109
- [full changelog](http://github.com/rspec/rspec-rails/compare/v2.1.0...v2.2.0)
110
-
111
- * Enhancements
112
- * Added stub_template in view specs
113
-
114
- * Bug fixes
115
- * Properly include helpers in views (Jonathan del Strother)
116
- * Fix bug in which method missing led to a stack overflow
117
- * Fix stack overflow in request specs with open_session
118
- * Fix stack overflow in any spec when method_missing was invoked
119
- * Add gem dependency on rails ~> 3.0.0 (ensures bundler won't install
120
- rspec-rails-2 with rails-2 apps).
121
-
122
- ### 2.1.0 / 2010-11-07
123
-
124
- [full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.1...v2.1.0)
125
-
126
- * Enhancements
127
- * Move errors_on to ActiveModel to support other AM-compliant ORMs
128
-
129
- * Bug fixes
130
- * Check for presence of ActiveRecord instead of checking Rails config
131
- (gets rspec out of the way of multiple ORMs in the same app)
132
-
133
- ### 2.0.1 / 2010-10-15
134
-
135
- [full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.0...v2.0.1)
136
-
137
- * Enhancements
138
- * Add option to not generate request spec (--skip-request-specs)
139
-
140
- * Bug fixes
141
- * Updated the mock_[model] method generated in controller specs so it adds
142
- any stubs submitted each time it is called.
143
- * Fixed bug where view assigns weren't making it to the view in view specs in Rails-3.0.1.
144
- (Emanuele Vicentini)
145
-
146
- ### 2.0.0 / 2010-10-10
147
-
148
- [full changelog](https://github.com/rspec/rspec-rails/compare/ea6bdef...v2.0.0)
149
-
150
- * Enhancements
151
- * ControllerExampleGroup uses controller as the implicit subject by default (Paul Rosania)
152
- * autotest mapping improvements (Andreas Neuhaus)
153
- * more cucumber features (Justin Ko)
154
- * clean up spec helper (Andre Arko)
155
- * add assign(name, value) to helper specs (Justin Ko)
156
- * stub_model supports primary keys other than id (Justin Ko)
157
- * support choice between Webrat/Capybara (Justin Ko)
158
- * support specs for 'abstract' subclasses of ActionController::Base (Mike Gehard)
159
- * be_a_new matcher supports args (Justin Ko)
160
-
161
- * Bug fixes
162
- * support T::U components in mailer and request specs (Brasten Sager)