rspec-rails 3.2.3 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b253eb3b0e3dec76470a3b9539138bff0a8b33c
4
- data.tar.gz: 06602ed978e71e6c85feb573bdc1e86978380cf1
3
+ metadata.gz: 9d716116d6947d7386ac5ea4728f9995b7c3663e
4
+ data.tar.gz: 13613ed86a4c02bf0f5e7804ffbcd75dc59c5a07
5
5
  SHA512:
6
- metadata.gz: d430a2897898c07a2b03f8721b60c6786793a65a90c9e3ea8b0ae8a16267e8d99dc279a6420e225fc0940e2576c96139239d14a2a43120596a28d1057ab71e09
7
- data.tar.gz: edafde8fc964cb4a06165f51c5ab8bb726f915bce743e488a036e40516cf1fe1dc9c02ab48f8ec208b9a7bead6a66b7ac4e8e8a7089b7097156fe80315be6fc8
6
+ metadata.gz: 06881e327741bb3268458ab492f432c4843b273be988c886f41a850caffe7b36e540d2d2b93a8c37de992269634fd21cb1fa7406143063c96fa17fd53920c998
7
+ data.tar.gz: 7bc993a1f2ae2d252f7018229d289ebf441656a1782f36d0587e35d30f10c7fa5e86648cab89dd85d0ad8d400644dc5e37586bdcc8c2c024759ed6d074e97819
Binary file
data.tar.gz.sig CHANGED
Binary file
data/.yardopts CHANGED
@@ -1,6 +1,8 @@
1
1
  --no-private
2
2
  --exclude features
3
3
  --exclude lib/generators/([^/]+/)*.*_spec.rb
4
+ --exclude lib/generators/([^/]+/)*templates/([^/]+/)*.rb
5
+ --exclude lib/generators/([^/]+/)*templates/.+\.rb
4
6
  --markup markdown
5
7
  --template-path yard/template/
6
8
  -
@@ -1,3 +1,21 @@
1
+ ### 3.3.0 / 2015-06-12
2
+ [Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.2.3...v3.3.0)
3
+
4
+ Enhancements:
5
+
6
+ * Add support for PATCH to route specs created via scaffold. (Igor Zubkov, #1336)
7
+ * Improve controller and routing spec calls to `routes` by using `yield`
8
+ instead of `call`. (Anton Davydov, #1308)
9
+ * Add support for `ActiveJob` specs as standard `RSpec::Rails::RailsExampleGoup`s
10
+ via both `:type => :job` and inferring type from spec directory `spec/jobs`.
11
+ (Gabe Martin-Dempesy, #1361)
12
+ * Include `RSpec::Rails::FixtureSupport` into example groups using metadata
13
+ `:use_fixtures => true`. (Aaron Kromer, #1372)
14
+ * Include `rspec:request` generator for generating request specs; this is an
15
+ alias of `rspec:integration` (Aaron Kromer, #1378)
16
+ * Update `rails_helper` generator with a default check to abort the spec run
17
+ when the Rails environment is production. (Aaron Kromer, #1383)
18
+
1
19
  ### 3.2.3 / 2015-06-06
2
20
  [Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.2.2...v3.2.3)
3
21
 
data/README.md CHANGED
@@ -518,7 +518,7 @@ expect(page).to have_http_status(:success)
518
518
 
519
519
  ## `rake` tasks
520
520
 
521
- Several rake tasks are provided as a convience for working with RSpec. To run
521
+ Several rake tasks are provided as a convenience for working with RSpec. To run
522
522
  the entire spec suite use `rake spec`. To run a subset of specs use the
523
523
  associated type task, for example `rake spec:models`.
524
524
 
@@ -1,7 +1,9 @@
1
1
  # This file is copied to spec/ when you run 'rails generate rspec:install'
2
2
  ENV['RAILS_ENV'] ||= 'test'
3
- require 'spec_helper'
4
3
  require File.expand_path('../../config/environment', __FILE__)
4
+ # Prevent database truncation if the environment is production
5
+ abort("The Rails environment is running in production mode!") if Rails.env.production?
6
+ require 'spec_helper'
5
7
  require 'rspec/rails'
6
8
  # Add additional requires below this line. Rails is not loaded until this point!
7
9
 
@@ -4,7 +4,12 @@ module Rspec
4
4
  module Generators
5
5
  # @private
6
6
  class IntegrationGenerator < Base
7
- class_option :request_specs, :type => :boolean, :default => true, :desc => "Generate request specs"
7
+ # Add a deprecation for this class, before rspec-rails 4, to use the
8
+ # `RequestGenerator` instead
9
+ class_option :request_specs,
10
+ :type => :boolean,
11
+ :default => true,
12
+ :desc => "Generate request specs"
8
13
 
9
14
  def generate_request_spec
10
15
  return unless options[:request_specs]
@@ -0,0 +1,10 @@
1
+ require 'generators/rspec/integration/integration_generator'
2
+
3
+ module Rspec
4
+ module Generators
5
+ # @private
6
+ class RequestGenerator < IntegrationGenerator
7
+ source_paths << File.expand_path("../../integration/templates", __FILE__)
8
+ end
9
+ end
10
+ end
@@ -26,10 +26,16 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:routing
26
26
  expect(:post => "/<%= ns_table_name %>").to route_to("<%= ns_table_name %>#create")
27
27
  end
28
28
 
29
- it "routes to #update" do
29
+ it "routes to #update via PUT" do
30
30
  expect(:put => "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#update", :id => "1")
31
31
  end
32
32
 
33
+ <% if Rails::VERSION::STRING > '4' -%>
34
+ it "routes to #update via PATCH" do
35
+ expect(:patch => "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#update", :id => "1")
36
+ end
37
+
38
+ <% end -%>
33
39
  it "routes to #destroy" do
34
40
  expect(:delete => "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#destroy", :id => "1")
35
41
  end
@@ -5,6 +5,7 @@ require 'active_support/core_ext/string'
5
5
 
6
6
  module RSpec
7
7
  module Rails
8
+ # @private
8
9
  def self.disable_testunit_autorun
9
10
  # `Test::Unit::AutoRunner.need_auto_run=` was introduced to the test-unit
10
11
  # gem in version 2.4.9. Previous to this version `Test::Unit.run=` was
@@ -27,6 +27,7 @@ module RSpec
27
27
  DIRECTORY_MAPPINGS = {
28
28
  :controller => %w[spec controllers],
29
29
  :helper => %w[spec helpers],
30
+ :job => %w[spec jobs],
30
31
  :mailer => %w[spec mailers],
31
32
  :model => %w[spec models],
32
33
  :request => %w[spec (requests|integration|api)],
@@ -52,6 +53,10 @@ module RSpec
52
53
  config.include RSpec::Rails::MailerExampleGroup, :type => :mailer
53
54
  end
54
55
 
56
+ if defined?(ActiveJob)
57
+ config.include RSpec::Rails::JobExampleGroup, :type => :job
58
+ end
59
+
55
60
  # controller settings
56
61
  config.add_setting :infer_base_class_for_anonymous_controllers, :default => true
57
62
 
@@ -60,10 +65,10 @@ module RSpec
60
65
  config.add_setting :use_instantiated_fixtures
61
66
  config.add_setting :global_fixtures
62
67
  config.add_setting :fixture_path
68
+ config.include RSpec::Rails::FixtureSupport, :use_fixtures
63
69
 
64
- # TODO: We'll need to create a deprecated module in order to properly
65
- # report to gems / projects which are relying on this being loaded
66
- # globally.
70
+ # We'll need to create a deprecated module in order to properly report to
71
+ # gems / projects which are relying on this being loaded globally.
67
72
  #
68
73
  # See rspec/rspec-rails#1355 for history
69
74
  #
@@ -79,23 +84,25 @@ module RSpec
79
84
  # but requires this workaround:
80
85
  config.add_setting :rendering_views, :default => false
81
86
 
82
- def config.render_views=(val)
83
- self.rendering_views = val
84
- end
87
+ config.instance_exec do
88
+ def render_views=(val)
89
+ self.rendering_views = val
90
+ end
85
91
 
86
- def config.render_views
87
- self.rendering_views = true
88
- end
92
+ def render_views
93
+ self.rendering_views = true
94
+ end
89
95
 
90
- def config.render_views?
91
- rendering_views
92
- end
96
+ def render_views?
97
+ rendering_views
98
+ end
93
99
 
94
- def config.infer_spec_type_from_file_location!
95
- DIRECTORY_MAPPINGS.each do |type, dir_parts|
96
- escaped_path = Regexp.compile(dir_parts.join('[\\\/]') + '[\\\/]')
97
- define_derived_metadata(:file_path => escaped_path) do |metadata|
98
- metadata[:type] ||= type
100
+ def infer_spec_type_from_file_location!
101
+ DIRECTORY_MAPPINGS.each do |type, dir_parts|
102
+ escaped_path = Regexp.compile(dir_parts.join('[\\\/]') + '[\\\/]')
103
+ define_derived_metadata(:file_path => escaped_path) do |metadata|
104
+ metadata[:type] ||= type
105
+ end
99
106
  end
100
107
  end
101
108
  end
@@ -6,4 +6,5 @@ require 'rspec/rails/example/view_example_group'
6
6
  require 'rspec/rails/example/mailer_example_group'
7
7
  require 'rspec/rails/example/routing_example_group'
8
8
  require 'rspec/rails/example/model_example_group'
9
+ require 'rspec/rails/example/job_example_group'
9
10
  require 'rspec/rails/example/feature_example_group'
@@ -1,5 +1,10 @@
1
1
  module RSpec
2
2
  module Rails
3
+ # @private
4
+ ControllerAssertionDelegator = RSpec::Rails::AssertionDelegator.new(
5
+ ActionDispatch::Assertions::RoutingAssertions
6
+ )
7
+
3
8
  # Container module for controller spec functionality.
4
9
  module ControllerExampleGroup
5
10
  extend ActiveSupport::Concern
@@ -9,7 +14,7 @@ module RSpec
9
14
  include RSpec::Rails::Matchers::RedirectTo
10
15
  include RSpec::Rails::Matchers::RenderTemplate
11
16
  include RSpec::Rails::Matchers::RoutingMatchers
12
- include RSpec::Rails::AssertionDelegator.new(ActionDispatch::Assertions::RoutingAssertions)
17
+ include ControllerAssertionDelegator
13
18
 
14
19
  # Class-level DSL for controller specs.
15
20
  module ClassMethods
@@ -110,14 +115,20 @@ module RSpec
110
115
  #
111
116
  # # ...
112
117
  # end
113
- def routes(&blk)
118
+ def routes
114
119
  before do
115
- self.routes = blk.call
120
+ self.routes = yield
116
121
  end
117
122
  end
118
123
  end
119
124
 
120
- attr_reader :controller, :routes
125
+ # @!attribute [r]
126
+ # Returns the controller object instance under test.
127
+ attr_reader :controller
128
+
129
+ # @!attribute [r]
130
+ # Returns the Rails routes used for the spec.
131
+ attr_reader :routes
121
132
 
122
133
  # @private
123
134
  #
@@ -0,0 +1,22 @@
1
+ module RSpec
2
+ module Rails
3
+ # Container module for job spec functionality. It is only available if
4
+ # ActiveJob has been loaded before it.
5
+ module JobExampleGroup
6
+ # This blank module is only necessary for YARD processing. It doesn't
7
+ # handle the conditional `defined?` check below very well.
8
+ end
9
+ end
10
+ end
11
+
12
+ if defined?(ActiveJob)
13
+ module RSpec
14
+ module Rails
15
+ # Container module for job spec functionality.
16
+ module JobExampleGroup
17
+ extend ActiveSupport::Concern
18
+ include RSpec::Rails::RailsExampleGroup
19
+ end
20
+ end
21
+ end
22
+ end
@@ -11,6 +11,7 @@ module RSpec
11
11
  include RSpec::Rails::MinitestLifecycleAdapter if ::Rails::VERSION::STRING >= '4'
12
12
  include RSpec::Rails::MinitestAssertionAdapter
13
13
  include RSpec::Rails::Matchers
14
+ include RSpec::Rails::FixtureSupport
14
15
  end
15
16
  end
16
17
  end
@@ -2,13 +2,18 @@ require "action_dispatch/testing/assertions/routing"
2
2
 
3
3
  module RSpec
4
4
  module Rails
5
+ # @private
6
+ RoutingAssertionDelegator = RSpec::Rails::AssertionDelegator.new(
7
+ ActionDispatch::Assertions::RoutingAssertions
8
+ )
9
+
5
10
  # Container module for routing spec functionality.
6
11
  module RoutingExampleGroup
7
12
  extend ActiveSupport::Concern
8
13
  include RSpec::Rails::RailsExampleGroup
9
14
  include RSpec::Rails::Matchers::RoutingMatchers
10
15
  include RSpec::Rails::Matchers::RoutingMatchers::RouteHelpers
11
- include RSpec::Rails::AssertionDelegator.new(ActionDispatch::Assertions::RoutingAssertions)
16
+ include RSpec::Rails::RoutingAssertionDelegator
12
17
 
13
18
  # Class-level DSL for route specs.
14
19
  module ClassMethods
@@ -24,9 +29,9 @@ module RSpec
24
29
  # route_to(:controller => "my_engine/posts", :action => "index")
25
30
  # end
26
31
  # end
27
- def routes(&blk)
32
+ def routes
28
33
  before do
29
- self.routes = blk.call
34
+ self.routes = yield
30
35
  end
31
36
  end
32
37
  end
@@ -37,6 +42,8 @@ module RSpec
37
42
  end
38
43
  end
39
44
 
45
+ # @!attribute [r]
46
+ # @private
40
47
  attr_reader :routes
41
48
 
42
49
  # @private
@@ -1,6 +1,7 @@
1
1
  # @api private
2
2
  module RSpec
3
3
  module Rails
4
+ # @private
4
5
  # Disable some cops until https://github.com/bbatsov/rubocop/issues/1310
5
6
  # rubocop:disable Style/IndentationConsistency
6
7
  module FeatureCheck
@@ -3,7 +3,7 @@ module RSpec
3
3
  # Version information for RSpec Rails.
4
4
  module Version
5
5
  # Current version of RSpec Rails, in semantic versioning format.
6
- STRING = '3.2.3'
6
+ STRING = '3.3.0'
7
7
  end
8
8
  end
9
9
  end
@@ -6,7 +6,13 @@ module RSpec
6
6
  module ViewRendering
7
7
  extend ActiveSupport::Concern
8
8
 
9
- attr_accessor :controller
9
+ # @!attribute [r]
10
+ # Returns the controller object instance under test.
11
+ attr_reader :controller
12
+
13
+ # @private
14
+ attr_writer :controller
15
+ private :controller=
10
16
 
11
17
  # DSL methods
12
18
  module ClassMethods
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.3
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chelimsky
@@ -44,7 +44,7 @@ cert_chain:
44
44
  ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
45
45
  F3MdtaDehhjC
46
46
  -----END CERTIFICATE-----
47
- date: 2015-06-06 00:00:00.000000000 Z
47
+ date: 2015-06-12 00:00:00.000000000 Z
48
48
  dependencies:
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: activesupport
@@ -112,56 +112,56 @@ dependencies:
112
112
  requirements:
113
113
  - - "~>"
114
114
  - !ruby/object:Gem::Version
115
- version: 3.2.0
115
+ version: 3.3.0
116
116
  type: :runtime
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - "~>"
121
121
  - !ruby/object:Gem::Version
122
- version: 3.2.0
122
+ version: 3.3.0
123
123
  - !ruby/object:Gem::Dependency
124
124
  name: rspec-expectations
125
125
  requirement: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: 3.2.0
129
+ version: 3.3.0
130
130
  type: :runtime
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - "~>"
135
135
  - !ruby/object:Gem::Version
136
- version: 3.2.0
136
+ version: 3.3.0
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: rspec-mocks
139
139
  requirement: !ruby/object:Gem::Requirement
140
140
  requirements:
141
141
  - - "~>"
142
142
  - !ruby/object:Gem::Version
143
- version: 3.2.0
143
+ version: 3.3.0
144
144
  type: :runtime
145
145
  prerelease: false
146
146
  version_requirements: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - "~>"
149
149
  - !ruby/object:Gem::Version
150
- version: 3.2.0
150
+ version: 3.3.0
151
151
  - !ruby/object:Gem::Dependency
152
152
  name: rspec-support
153
153
  requirement: !ruby/object:Gem::Requirement
154
154
  requirements:
155
155
  - - "~>"
156
156
  - !ruby/object:Gem::Version
157
- version: 3.2.0
157
+ version: 3.3.0
158
158
  type: :runtime
159
159
  prerelease: false
160
160
  version_requirements: !ruby/object:Gem::Requirement
161
161
  requirements:
162
162
  - - "~>"
163
163
  - !ruby/object:Gem::Version
164
- version: 3.2.0
164
+ version: 3.3.0
165
165
  - !ruby/object:Gem::Dependency
166
166
  name: rake
167
167
  requirement: !ruby/object:Gem::Requirement
@@ -218,7 +218,7 @@ dependencies:
218
218
  - - '='
219
219
  - !ruby/object:Gem::Version
220
220
  version: 1.1.2
221
- description: RSpec for Rails
221
+ description: rspec-rails is a testing framework for Rails 3.x and 4.x.
222
222
  email: rspec@googlegroups.com
223
223
  executables: []
224
224
  extensions: []
@@ -253,6 +253,7 @@ files:
253
253
  - lib/generators/rspec/model/templates/model_spec.rb
254
254
  - lib/generators/rspec/observer/observer_generator.rb
255
255
  - lib/generators/rspec/observer/templates/observer_spec.rb
256
+ - lib/generators/rspec/request/request_generator.rb
256
257
  - lib/generators/rspec/scaffold/scaffold_generator.rb
257
258
  - lib/generators/rspec/scaffold/templates/controller_spec.rb
258
259
  - lib/generators/rspec/scaffold/templates/edit_spec.rb
@@ -271,6 +272,7 @@ files:
271
272
  - lib/rspec/rails/example/controller_example_group.rb
272
273
  - lib/rspec/rails/example/feature_example_group.rb
273
274
  - lib/rspec/rails/example/helper_example_group.rb
275
+ - lib/rspec/rails/example/job_example_group.rb
274
276
  - lib/rspec/rails/example/mailer_example_group.rb
275
277
  - lib/rspec/rails/example/model_example_group.rb
276
278
  - lib/rspec/rails/example/rails_example_group.rb
@@ -315,10 +317,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
315
317
  - !ruby/object:Gem::Version
316
318
  version: '0'
317
319
  requirements: []
318
- rubyforge_project: rspec
320
+ rubyforge_project:
319
321
  rubygems_version: 2.2.2
320
322
  signing_key:
321
323
  specification_version: 4
322
- summary: rspec-rails-3.2.3
324
+ summary: RSpec for Rails
323
325
  test_files: []
324
326
  has_rdoc:
metadata.gz.sig CHANGED
Binary file