rspec-rails 4.0.0.beta3 → 4.0.2
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Capybara.md +5 -54
- data/Changelog.md +61 -7
- data/README.md +20 -19
- data/lib/generators/rspec.rb +0 -6
- data/lib/generators/rspec/controller/controller_generator.rb +13 -5
- data/lib/generators/rspec/controller/templates/request_spec.rb +14 -0
- data/lib/generators/rspec/controller/templates/routing_spec.rb +1 -1
- data/lib/generators/rspec/feature/feature_generator.rb +2 -2
- data/lib/generators/rspec/{generators → generator}/generator_generator.rb +2 -2
- data/lib/generators/rspec/{generators → generator}/templates/generator_spec.rb +0 -0
- data/lib/generators/rspec/helper/helper_generator.rb +1 -1
- data/lib/generators/rspec/install/install_generator.rb +4 -4
- data/lib/generators/rspec/install/templates/spec/rails_helper.rb +17 -16
- data/lib/generators/rspec/integration/integration_generator.rb +3 -3
- data/lib/generators/rspec/mailer/mailer_generator.rb +1 -1
- data/lib/generators/rspec/model/model_generator.rb +4 -4
- data/lib/generators/rspec/scaffold/scaffold_generator.rb +26 -18
- data/lib/generators/rspec/scaffold/templates/api_controller_spec.rb +0 -36
- data/lib/generators/rspec/scaffold/templates/api_request_spec.rb +131 -0
- data/lib/generators/rspec/scaffold/templates/controller_spec.rb +10 -10
- data/lib/generators/rspec/scaffold/templates/edit_spec.rb +1 -1
- data/lib/generators/rspec/scaffold/templates/index_spec.rb +2 -2
- data/lib/generators/rspec/scaffold/templates/new_spec.rb +1 -1
- data/lib/generators/rspec/scaffold/templates/request_spec.rb +133 -0
- data/lib/generators/rspec/scaffold/templates/routing_spec.rb +8 -10
- data/lib/generators/rspec/scaffold/templates/show_spec.rb +1 -1
- data/lib/generators/rspec/system/system_generator.rb +1 -1
- data/lib/generators/rspec/view/view_generator.rb +2 -2
- data/lib/rspec-rails.rb +6 -9
- data/lib/rspec/rails/adapters.rb +10 -76
- data/lib/rspec/rails/configuration.rb +72 -36
- data/lib/rspec/rails/example/channel_example_group.rb +2 -2
- data/lib/rspec/rails/example/controller_example_group.rb +4 -4
- data/lib/rspec/rails/example/feature_example_group.rb +6 -26
- data/lib/rspec/rails/example/helper_example_group.rb +2 -10
- data/lib/rspec/rails/example/mailbox_example_group.rb +1 -1
- data/lib/rspec/rails/example/mailer_example_group.rb +2 -2
- data/lib/rspec/rails/example/rails_example_group.rb +1 -1
- data/lib/rspec/rails/example/system_example_group.rb +14 -7
- data/lib/rspec/rails/example/view_example_group.rb +38 -48
- data/lib/rspec/rails/extensions/active_record/proxy.rb +5 -10
- data/lib/rspec/rails/feature_check.rb +1 -28
- data/lib/rspec/rails/fixture_file_upload_support.rb +8 -13
- data/lib/rspec/rails/fixture_support.rb +37 -31
- data/lib/rspec/rails/matchers/action_cable.rb +1 -1
- data/lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb +3 -3
- data/lib/rspec/rails/matchers/active_job.rb +132 -18
- data/lib/rspec/rails/matchers/base_matcher.rb +4 -10
- data/lib/rspec/rails/matchers/have_enqueued_mail.rb +9 -6
- data/lib/rspec/rails/matchers/have_http_status.rb +7 -7
- data/lib/rspec/rails/matchers/relation_match_array.rb +1 -1
- data/lib/rspec/rails/matchers/routing_matchers.rb +11 -11
- data/lib/rspec/rails/tasks/rspec.rake +7 -17
- data/lib/rspec/rails/vendor/capybara.rb +10 -15
- data/lib/rspec/rails/version.rb +1 -1
- data/lib/rspec/rails/view_path_builder.rb +1 -1
- data/lib/rspec/rails/view_rendering.rb +3 -3
- metadata +34 -33
- metadata.gz.sig +0 -0
- data/lib/generators/rspec/observer/observer_generator.rb +0 -13
- data/lib/generators/rspec/observer/templates/observer_spec.rb +0 -7
@@ -48,7 +48,7 @@ module RSpec
|
|
48
48
|
def have_broadcasted_to(target = nil)
|
49
49
|
check_action_cable_adapter
|
50
50
|
|
51
|
-
ActionCable::HaveBroadcastedTo.new(target, :
|
51
|
+
ActionCable::HaveBroadcastedTo.new(target, channel: described_class)
|
52
52
|
end
|
53
53
|
alias_method :broadcast_to, :have_broadcasted_to
|
54
54
|
|
@@ -8,15 +8,15 @@ module RSpec
|
|
8
8
|
def initialize(target, channel:)
|
9
9
|
@target = target
|
10
10
|
@channel = channel
|
11
|
-
@block =
|
11
|
+
@block = proc { }
|
12
12
|
@data = nil
|
13
13
|
set_expected_number(:exactly, 1)
|
14
14
|
end
|
15
15
|
|
16
|
-
def with(data = nil)
|
16
|
+
def with(data = nil, &block)
|
17
17
|
@data = data
|
18
18
|
@data = @data.with_indifferent_access if @data.is_a?(Hash)
|
19
|
-
@block =
|
19
|
+
@block = block if block
|
20
20
|
self
|
21
21
|
end
|
22
22
|
|
@@ -15,7 +15,7 @@ module RSpec
|
|
15
15
|
@args = []
|
16
16
|
@queue = nil
|
17
17
|
@at = nil
|
18
|
-
@block =
|
18
|
+
@block = proc { }
|
19
19
|
set_expected_number(:exactly, 1)
|
20
20
|
end
|
21
21
|
|
@@ -26,12 +26,16 @@ module RSpec
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def on_queue(queue)
|
29
|
-
@queue = queue
|
29
|
+
@queue = queue.to_s
|
30
30
|
self
|
31
31
|
end
|
32
32
|
|
33
|
-
def at(
|
34
|
-
|
33
|
+
def at(time_or_date)
|
34
|
+
case time_or_date
|
35
|
+
when Time then @at = Time.at(time_or_date.to_f)
|
36
|
+
else
|
37
|
+
@at = time_or_date
|
38
|
+
end
|
35
39
|
self
|
36
40
|
end
|
37
41
|
|
@@ -67,7 +71,7 @@ module RSpec
|
|
67
71
|
end
|
68
72
|
|
69
73
|
def failure_message
|
70
|
-
"expected to
|
74
|
+
"expected to #{self.class::FAILURE_MESSAGE_EXPECTATION_ACTION} #{base_message}".tap do |msg|
|
71
75
|
if @unmatching_jobs.any?
|
72
76
|
msg << "\nQueued jobs:"
|
73
77
|
@unmatching_jobs.each do |job|
|
@@ -78,7 +82,7 @@ module RSpec
|
|
78
82
|
end
|
79
83
|
|
80
84
|
def failure_message_when_negated
|
81
|
-
"expected not to
|
85
|
+
"expected not to #{self.class::FAILURE_MESSAGE_EXPECTATION_ACTION} #{base_message}"
|
82
86
|
end
|
83
87
|
|
84
88
|
def message_expectation_modifier
|
@@ -97,7 +101,7 @@ module RSpec
|
|
97
101
|
|
98
102
|
def check(jobs)
|
99
103
|
@matching_jobs, @unmatching_jobs = jobs.partition do |job|
|
100
|
-
if job_match?(job) && arguments_match?(job) &&
|
104
|
+
if job_match?(job) && arguments_match?(job) && queue_match?(job) && at_match?(job)
|
101
105
|
args = deserialize_arguments(job)
|
102
106
|
@block.call(*args)
|
103
107
|
true
|
@@ -119,7 +123,7 @@ module RSpec
|
|
119
123
|
msg << " with #{@args}," if @args.any?
|
120
124
|
msg << " on queue #{@queue}," if @queue
|
121
125
|
msg << " at #{@at.inspect}," if @at
|
122
|
-
msg << " but
|
126
|
+
msg << " but #{self.class::MESSAGE_EXPECTATION_ACTION} #{@matching_jobs_count}"
|
123
127
|
end
|
124
128
|
end
|
125
129
|
|
@@ -148,19 +152,18 @@ module RSpec
|
|
148
152
|
end
|
149
153
|
end
|
150
154
|
|
151
|
-
def
|
152
|
-
|
153
|
-
end
|
155
|
+
def queue_match?(job)
|
156
|
+
return true unless @queue
|
154
157
|
|
155
|
-
|
156
|
-
{}.tap do |attributes|
|
157
|
-
attributes[:at] = serialized_at if @at
|
158
|
-
attributes[:queue] = @queue if @queue
|
159
|
-
end
|
158
|
+
@queue == job[:queue]
|
160
159
|
end
|
161
160
|
|
162
|
-
def
|
163
|
-
|
161
|
+
def at_match?(job)
|
162
|
+
return true unless @at
|
163
|
+
return job[:at].nil? if @at == :no_wait
|
164
|
+
return false unless job[:at]
|
165
|
+
|
166
|
+
values_match?(@at, Time.at(job[:at]))
|
164
167
|
end
|
165
168
|
|
166
169
|
def set_expected_number(relativity, count)
|
@@ -194,6 +197,9 @@ module RSpec
|
|
194
197
|
|
195
198
|
# @private
|
196
199
|
class HaveEnqueuedJob < Base
|
200
|
+
FAILURE_MESSAGE_EXPECTATION_ACTION = 'enqueue'.freeze
|
201
|
+
MESSAGE_EXPECTATION_ACTION = 'enqueued'.freeze
|
202
|
+
|
197
203
|
def initialize(job)
|
198
204
|
super()
|
199
205
|
@job = job
|
@@ -218,6 +224,9 @@ module RSpec
|
|
218
224
|
|
219
225
|
# @private
|
220
226
|
class HaveBeenEnqueued < Base
|
227
|
+
FAILURE_MESSAGE_EXPECTATION_ACTION = 'enqueue'.freeze
|
228
|
+
MESSAGE_EXPECTATION_ACTION = 'enqueued'.freeze
|
229
|
+
|
221
230
|
def matches?(job)
|
222
231
|
@job = job
|
223
232
|
check(queue_adapter.enqueued_jobs)
|
@@ -229,6 +238,38 @@ module RSpec
|
|
229
238
|
!matches?(proc)
|
230
239
|
end
|
231
240
|
end
|
241
|
+
|
242
|
+
# @private
|
243
|
+
class HavePerformedJob < Base
|
244
|
+
FAILURE_MESSAGE_EXPECTATION_ACTION = 'perform'.freeze
|
245
|
+
MESSAGE_EXPECTATION_ACTION = 'performed'.freeze
|
246
|
+
|
247
|
+
def initialize(job)
|
248
|
+
super()
|
249
|
+
@job = job
|
250
|
+
end
|
251
|
+
|
252
|
+
def matches?(proc)
|
253
|
+
raise ArgumentError, "have_performed_job only supports block expectations" unless Proc === proc
|
254
|
+
|
255
|
+
original_performed_jobs_count = queue_adapter.performed_jobs.count
|
256
|
+
proc.call
|
257
|
+
in_block_jobs = queue_adapter.performed_jobs.drop(original_performed_jobs_count)
|
258
|
+
|
259
|
+
check(in_block_jobs)
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
# @private
|
264
|
+
class HaveBeenPerformed < Base
|
265
|
+
FAILURE_MESSAGE_EXPECTATION_ACTION = 'perform'.freeze
|
266
|
+
MESSAGE_EXPECTATION_ACTION = 'performed'.freeze
|
267
|
+
|
268
|
+
def matches?(job)
|
269
|
+
@job = job
|
270
|
+
check(queue_adapter.performed_jobs)
|
271
|
+
end
|
272
|
+
end
|
232
273
|
end
|
233
274
|
|
234
275
|
# @api public
|
@@ -316,6 +357,79 @@ module RSpec
|
|
316
357
|
ActiveJob::HaveBeenEnqueued.new
|
317
358
|
end
|
318
359
|
|
360
|
+
# @api public
|
361
|
+
# Passes if a job has been performed inside block. May chain at_least, at_most or exactly to specify a number of times.
|
362
|
+
#
|
363
|
+
# @example
|
364
|
+
# expect {
|
365
|
+
# perform_jobs { HeavyLiftingJob.perform_later }
|
366
|
+
# }.to have_performed_job
|
367
|
+
#
|
368
|
+
# expect {
|
369
|
+
# perform_jobs {
|
370
|
+
# HelloJob.perform_later
|
371
|
+
# HeavyLiftingJob.perform_later
|
372
|
+
# }
|
373
|
+
# }.to have_performed_job(HelloJob).exactly(:once)
|
374
|
+
#
|
375
|
+
# expect {
|
376
|
+
# perform_jobs { 3.times { HelloJob.perform_later } }
|
377
|
+
# }.to have_performed_job(HelloJob).at_least(2).times
|
378
|
+
#
|
379
|
+
# expect {
|
380
|
+
# perform_jobs { HelloJob.perform_later }
|
381
|
+
# }.to have_performed_job(HelloJob).at_most(:twice)
|
382
|
+
#
|
383
|
+
# expect {
|
384
|
+
# perform_jobs {
|
385
|
+
# HelloJob.perform_later
|
386
|
+
# HeavyLiftingJob.perform_later
|
387
|
+
# }
|
388
|
+
# }.to have_performed_job(HelloJob).and have_performed_job(HeavyLiftingJob)
|
389
|
+
#
|
390
|
+
# expect {
|
391
|
+
# perform_jobs {
|
392
|
+
# HelloJob.set(wait_until: Date.tomorrow.noon, queue: "low").perform_later(42)
|
393
|
+
# }
|
394
|
+
# }.to have_performed_job.with(42).on_queue("low").at(Date.tomorrow.noon)
|
395
|
+
def have_performed_job(job = nil)
|
396
|
+
check_active_job_adapter
|
397
|
+
ActiveJob::HavePerformedJob.new(job)
|
398
|
+
end
|
399
|
+
alias_method :perform_job, :have_performed_job
|
400
|
+
|
401
|
+
# @api public
|
402
|
+
# Passes if a job has been performed. May chain at_least, at_most or exactly to specify a number of times.
|
403
|
+
#
|
404
|
+
# @example
|
405
|
+
# before do
|
406
|
+
# ActiveJob::Base.queue_adapter.performed_jobs.clear
|
407
|
+
# ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true
|
408
|
+
# ActiveJob::Base.queue_adapter.perform_enqueued_at_jobs = true
|
409
|
+
# end
|
410
|
+
#
|
411
|
+
# HeavyLiftingJob.perform_later
|
412
|
+
# expect(HeavyLiftingJob).to have_been_performed
|
413
|
+
#
|
414
|
+
# HelloJob.perform_later
|
415
|
+
# HeavyLiftingJob.perform_later
|
416
|
+
# expect(HeavyLiftingJob).to have_been_performed.exactly(:once)
|
417
|
+
#
|
418
|
+
# 3.times { HelloJob.perform_later }
|
419
|
+
# expect(HelloJob).to have_been_performed.at_least(2).times
|
420
|
+
#
|
421
|
+
# HelloJob.perform_later
|
422
|
+
# HeavyLiftingJob.perform_later
|
423
|
+
# expect(HelloJob).to have_been_performed
|
424
|
+
# expect(HeavyLiftingJob).to have_been_performed
|
425
|
+
#
|
426
|
+
# HelloJob.set(wait_until: Date.tomorrow.noon, queue: "low").perform_later(42)
|
427
|
+
# expect(HelloJob).to have_been_performed.with(42).on_queue("low").at(Date.tomorrow.noon)
|
428
|
+
def have_been_performed
|
429
|
+
check_active_job_adapter
|
430
|
+
ActiveJob::HaveBeenPerformed.new
|
431
|
+
end
|
432
|
+
|
319
433
|
private
|
320
434
|
|
321
435
|
# @private
|
@@ -1,7 +1,9 @@
|
|
1
1
|
module RSpec
|
2
2
|
module Rails
|
3
3
|
module Matchers
|
4
|
-
# @
|
4
|
+
# @api private
|
5
|
+
#
|
6
|
+
# Base class to build matchers. Should not be instantiated directly.
|
5
7
|
class BaseMatcher
|
6
8
|
include RSpec::Matchers::Composable
|
7
9
|
|
@@ -119,15 +121,7 @@ module RSpec
|
|
119
121
|
raise "#{self.class.name} needs to supply#{ivar_list}"
|
120
122
|
end
|
121
123
|
|
122
|
-
|
123
|
-
# :nocov:
|
124
|
-
def present_ivars
|
125
|
-
instance_variables.map(&:to_sym)
|
126
|
-
end
|
127
|
-
# :nocov:
|
128
|
-
else
|
129
|
-
alias present_ivars instance_variables
|
130
|
-
end
|
124
|
+
alias present_ivars instance_variables
|
131
125
|
|
132
126
|
# @private
|
133
127
|
module HashFormatting
|
@@ -1,4 +1,7 @@
|
|
1
|
-
require
|
1
|
+
# We require the minimum amount of rspec-mocks possible to avoid
|
2
|
+
# conflicts with other mocking frameworks.
|
3
|
+
# See: https://github.com/rspec/rspec-rails/issues/2252
|
4
|
+
require "rspec/mocks/argument_matchers"
|
2
5
|
require "rspec/rails/matchers/active_job"
|
3
6
|
|
4
7
|
module RSpec
|
@@ -11,7 +14,7 @@ module RSpec
|
|
11
14
|
class HaveEnqueuedMail < ActiveJob::HaveEnqueuedJob
|
12
15
|
MAILER_JOB_METHOD = 'deliver_now'.freeze
|
13
16
|
|
14
|
-
include RSpec::Mocks::
|
17
|
+
include RSpec::Mocks::ArgumentMatchers
|
15
18
|
|
16
19
|
def initialize(mailer_class, method_name)
|
17
20
|
super(nil)
|
@@ -90,7 +93,7 @@ module RSpec
|
|
90
93
|
end
|
91
94
|
|
92
95
|
def yield_mail_args(block)
|
93
|
-
|
96
|
+
proc { |*job_args| block.call(*(job_args - base_mailer_args)) }
|
94
97
|
end
|
95
98
|
|
96
99
|
def check_active_job_adapter
|
@@ -128,15 +131,15 @@ module RSpec
|
|
128
131
|
end
|
129
132
|
|
130
133
|
def legacy_mail?(job)
|
131
|
-
job[:job]
|
134
|
+
job[:job] <= ActionMailer::DeliveryJob
|
132
135
|
end
|
133
136
|
|
134
137
|
def parameterized_mail?(job)
|
135
|
-
RSpec::Rails::FeatureCheck.has_action_mailer_parameterized? && job[:job]
|
138
|
+
RSpec::Rails::FeatureCheck.has_action_mailer_parameterized? && job[:job] <= ActionMailer::Parameterized::DeliveryJob
|
136
139
|
end
|
137
140
|
|
138
141
|
def unified_mail?(job)
|
139
|
-
RSpec::Rails::FeatureCheck.has_action_mailer_unified_delivery? && job[:job]
|
142
|
+
RSpec::Rails::FeatureCheck.has_action_mailer_unified_delivery? && job[:job] <= ActionMailer::MailDeliveryJob
|
140
143
|
end
|
141
144
|
end
|
142
145
|
# @api public
|
@@ -73,7 +73,7 @@ module RSpec
|
|
73
73
|
# @example
|
74
74
|
# expect(response).to have_http_status(404)
|
75
75
|
#
|
76
|
-
# @see RSpec::Rails::Matchers
|
76
|
+
# @see RSpec::Rails::Matchers#have_http_status
|
77
77
|
class NumericCode < RSpec::Rails::Matchers::BaseMatcher
|
78
78
|
include HaveHttpStatus
|
79
79
|
|
@@ -123,7 +123,7 @@ module RSpec
|
|
123
123
|
# @example
|
124
124
|
# expect(response).to have_http_status(:created)
|
125
125
|
#
|
126
|
-
# @see RSpec::Rails::Matchers
|
126
|
+
# @see RSpec::Rails::Matchers#have_http_status
|
127
127
|
# @see https://github.com/rack/rack/blob/master/lib/rack/utils.rb `Rack::Utils::SYMBOL_TO_STATUS_CODE`
|
128
128
|
class SymbolicStatus < RSpec::Rails::Matchers::BaseMatcher
|
129
129
|
include HaveHttpStatus
|
@@ -236,8 +236,8 @@ module RSpec
|
|
236
236
|
# expect(response).to have_http_status(:missing)
|
237
237
|
# expect(response).to have_http_status(:redirect)
|
238
238
|
#
|
239
|
-
# @see RSpec::Rails::Matchers
|
240
|
-
# @see ActionDispatch::TestResponse
|
239
|
+
# @see RSpec::Rails::Matchers#have_http_status
|
240
|
+
# @see https://github.com/rails/rails/blob/6-0-stable/actionpack/lib/action_dispatch/testing/test_response.rb `ActionDispatch::TestResponse`
|
241
241
|
class GenericStatus < RSpec::Rails::Matchers::BaseMatcher
|
242
242
|
include HaveHttpStatus
|
243
243
|
|
@@ -293,9 +293,9 @@ module RSpec
|
|
293
293
|
protected
|
294
294
|
|
295
295
|
RESPONSE_METHODS = {
|
296
|
-
:
|
297
|
-
:
|
298
|
-
:
|
296
|
+
success: 'successful',
|
297
|
+
error: 'server_error',
|
298
|
+
missing: 'not_found'
|
299
299
|
}.freeze
|
300
300
|
|
301
301
|
def check_expected_status(test_response, expected)
|
@@ -1,3 +1,3 @@
|
|
1
|
-
if defined?(ActiveRecord::Relation)
|
1
|
+
if defined?(ActiveRecord::Relation) && defined?(RSpec::Matchers::BuiltIn::OperatorMatcher) # RSpec 4 removed OperatorMatcher
|
2
2
|
RSpec::Matchers::BuiltIn::OperatorMatcher.register(ActiveRecord::Relation, '=~', RSpec::Matchers::BuiltIn::ContainExactly)
|
3
3
|
end
|
@@ -14,7 +14,7 @@ module RSpec
|
|
14
14
|
@expected.merge!(expected[0])
|
15
15
|
else
|
16
16
|
controller, action = expected[0].split('#')
|
17
|
-
@expected.merge!(:
|
17
|
+
@expected.merge!(controller: controller, action: action)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -26,7 +26,7 @@ module RSpec
|
|
26
26
|
path, query = *verb_to_path_map.values.first.split('?')
|
27
27
|
@scope.assert_recognizes(
|
28
28
|
@expected,
|
29
|
-
{
|
29
|
+
{method: verb_to_path_map.keys.first, path: path},
|
30
30
|
Rack::Utils.parse_nested_query(query)
|
31
31
|
)
|
32
32
|
end
|
@@ -50,12 +50,12 @@ module RSpec
|
|
50
50
|
#
|
51
51
|
# @example
|
52
52
|
#
|
53
|
-
# expect(:
|
54
|
-
# :
|
55
|
-
# :
|
53
|
+
# expect(get: "/things/special").to route_to(
|
54
|
+
# controller: "things",
|
55
|
+
# action: "special"
|
56
56
|
# )
|
57
57
|
#
|
58
|
-
# expect(:
|
58
|
+
# expect(get: "/things/special").to route_to("things#special")
|
59
59
|
#
|
60
60
|
# @see https://api.rubyonrails.org/classes/ActionDispatch/Assertions/RoutingAssertions.html#method-i-assert_recognizes
|
61
61
|
def route_to(*expected)
|
@@ -72,7 +72,7 @@ module RSpec
|
|
72
72
|
@actual = path
|
73
73
|
match_unless_raises ActionController::RoutingError do
|
74
74
|
@routing_options = @scope.routes.recognize_path(
|
75
|
-
path.values.first, :
|
75
|
+
path.values.first, method: path.keys.first
|
76
76
|
)
|
77
77
|
end
|
78
78
|
end
|
@@ -95,9 +95,9 @@ module RSpec
|
|
95
95
|
# `RouteSet#recognize_path`.
|
96
96
|
#
|
97
97
|
# @example You can use route helpers provided by rspec-rails.
|
98
|
-
# expect(:
|
99
|
-
# expect(:
|
100
|
-
# expect(:
|
98
|
+
# expect(get: "/a/path").to be_routable
|
99
|
+
# expect(post: "/another/path").to be_routable
|
100
|
+
# expect(put: "/yet/another/path").to be_routable
|
101
101
|
def be_routable
|
102
102
|
BeRoutableMatcher.new(self)
|
103
103
|
end
|
@@ -115,7 +115,7 @@ module RSpec
|
|
115
115
|
# Shorthand method for matching this type of route.
|
116
116
|
%w[get post put patch delete options head].each do |method|
|
117
117
|
define_method method do |path|
|
118
|
-
{
|
118
|
+
{method.to_sym => path}
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|
@@ -3,19 +3,19 @@ if default = Rake.application.instance_variable_get('@tasks')['default']
|
|
3
3
|
default.prerequisites.delete('test')
|
4
4
|
end
|
5
5
|
|
6
|
-
task :
|
6
|
+
task default: :spec
|
7
7
|
|
8
|
-
task :
|
8
|
+
task stats: "spec:statsetup"
|
9
9
|
|
10
10
|
desc "Run all specs in spec directory (excluding plugin specs)"
|
11
|
-
RSpec::Core::RakeTask.new(:
|
11
|
+
RSpec::Core::RakeTask.new(spec: "spec:prepare")
|
12
12
|
|
13
13
|
namespace :spec do
|
14
14
|
types = begin
|
15
|
-
dirs = Dir['./spec/**/*_spec.rb']
|
16
|
-
map { |f| f.sub(/^\.\/(spec\/\w+)\/.*/, '\\1') }
|
17
|
-
uniq
|
18
|
-
select { |f| File.directory?(f) }
|
15
|
+
dirs = Dir['./spec/**/*_spec.rb']
|
16
|
+
.map { |f| f.sub(/^\.\/(spec\/\w+)\/.*/, '\\1') }
|
17
|
+
.uniq
|
18
|
+
.select { |f| File.directory?(f) }
|
19
19
|
Hash[dirs.map { |d| [d.split('/').last, d] }]
|
20
20
|
end
|
21
21
|
|
@@ -35,16 +35,6 @@ namespace :spec do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
# RCov task only enabled for Ruby 1.8
|
39
|
-
if RUBY_VERSION < '1.9'
|
40
|
-
desc "Run all specs with rcov"
|
41
|
-
RSpec::Core::RakeTask.new(:rcov => "spec:prepare") do |t|
|
42
|
-
t.rcov = true
|
43
|
-
t.pattern = "./spec/**/*_spec.rb"
|
44
|
-
t.rcov_opts = '--exclude /gems/,/Library/,/usr/,lib/tasks,.bundle,config,/lib/rspec/,/lib/rspec-,spec'
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
38
|
task :statsetup do
|
49
39
|
require 'rails/code_statistics'
|
50
40
|
types.each do |type, dir|
|