shoulda-matchers 2.5.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. data/.gitignore +8 -7
  2. data/.travis.yml +4 -0
  3. data/Appraisals +8 -0
  4. data/CONTRIBUTING.md +1 -1
  5. data/Gemfile +1 -1
  6. data/Gemfile.lock +77 -66
  7. data/MIT-LICENSE +1 -1
  8. data/NEWS.md +63 -1
  9. data/README.md +189 -33
  10. data/Rakefile +6 -5
  11. data/features/rails_integration.feature +1 -1
  12. data/features/step_definitions/rails_steps.rb +7 -6
  13. data/gemfiles/3.0.gemfile +2 -2
  14. data/gemfiles/3.0.gemfile.lock +14 -5
  15. data/gemfiles/3.1.gemfile +2 -2
  16. data/gemfiles/3.1.gemfile.lock +14 -5
  17. data/gemfiles/3.2.gemfile +2 -2
  18. data/gemfiles/3.2.gemfile.lock +16 -7
  19. data/gemfiles/4.0.0.gemfile +2 -2
  20. data/gemfiles/4.0.0.gemfile.lock +15 -6
  21. data/gemfiles/4.0.1.gemfile +2 -2
  22. data/gemfiles/4.0.1.gemfile.lock +15 -6
  23. data/gemfiles/4.1.gemfile +19 -0
  24. data/gemfiles/4.1.gemfile.lock +176 -0
  25. data/lib/shoulda/matchers.rb +17 -1
  26. data/lib/shoulda/matchers/action_controller.rb +4 -2
  27. data/lib/shoulda/matchers/action_controller/callback_matcher.rb +100 -0
  28. data/lib/shoulda/matchers/action_controller/redirect_to_matcher.rb +1 -1
  29. data/lib/shoulda/matchers/action_controller/render_template_matcher.rb +4 -4
  30. data/lib/shoulda/matchers/action_controller/rescue_from_matcher.rb +1 -1
  31. data/lib/shoulda/matchers/action_controller/route_matcher.rb +12 -12
  32. data/lib/shoulda/matchers/action_controller/route_params.rb +1 -1
  33. data/lib/shoulda/matchers/action_controller/set_the_flash_matcher.rb +2 -1
  34. data/lib/shoulda/matchers/action_controller/strong_parameters_matcher.rb +167 -0
  35. data/lib/shoulda/matchers/active_model.rb +4 -2
  36. data/lib/shoulda/matchers/active_model/allow_value_matcher.rb +23 -5
  37. data/lib/shoulda/matchers/active_model/disallow_value_matcher.rb +0 -4
  38. data/lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb +66 -14
  39. data/lib/shoulda/matchers/active_model/ensure_length_of_matcher.rb +8 -8
  40. data/lib/shoulda/matchers/active_model/errors.rb +40 -0
  41. data/lib/shoulda/matchers/active_model/helpers.rb +6 -6
  42. data/lib/shoulda/matchers/active_model/numericality_matchers/comparison_matcher.rb +33 -14
  43. data/lib/shoulda/matchers/active_model/numericality_matchers/even_number_matcher.rb +26 -0
  44. data/lib/shoulda/matchers/active_model/numericality_matchers/{odd_even_number_matcher.rb → numeric_type_matcher.rb} +9 -20
  45. data/lib/shoulda/matchers/active_model/numericality_matchers/odd_number_matcher.rb +26 -0
  46. data/lib/shoulda/matchers/active_model/numericality_matchers/only_integer_matcher.rb +5 -21
  47. data/lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb +1 -1
  48. data/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +71 -22
  49. data/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb +6 -1
  50. data/lib/shoulda/matchers/active_model/validate_uniqueness_of_matcher.rb +25 -6
  51. data/lib/shoulda/matchers/active_record.rb +1 -0
  52. data/lib/shoulda/matchers/active_record/association_matcher.rb +67 -13
  53. data/lib/shoulda/matchers/active_record/association_matchers/inverse_of_matcher.rb +40 -0
  54. data/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb +24 -1
  55. data/lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb +1 -1
  56. data/lib/shoulda/matchers/active_record/have_db_column_matcher.rb +1 -1
  57. data/lib/shoulda/matchers/active_record/have_db_index_matcher.rb +1 -1
  58. data/lib/shoulda/matchers/assertion_error.rb +7 -2
  59. data/lib/shoulda/matchers/error.rb +24 -0
  60. data/lib/shoulda/matchers/independent.rb +10 -0
  61. data/lib/shoulda/matchers/independent/delegate_matcher.rb +157 -0
  62. data/lib/shoulda/matchers/independent/delegate_matcher/stubbed_target.rb +34 -0
  63. data/lib/shoulda/matchers/integrations/nunit_test_case_detection.rb +36 -0
  64. data/lib/shoulda/matchers/integrations/rspec.rb +13 -14
  65. data/lib/shoulda/matchers/integrations/test_unit.rb +11 -9
  66. data/lib/shoulda/matchers/version.rb +1 -1
  67. data/lib/shoulda/matchers/warn.rb +7 -0
  68. data/shoulda-matchers.gemspec +2 -1
  69. data/spec/shoulda/matchers/action_controller/callback_matcher_spec.rb +79 -0
  70. data/spec/shoulda/matchers/action_controller/filter_param_matcher_spec.rb +3 -3
  71. data/spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb +11 -11
  72. data/spec/shoulda/matchers/action_controller/render_template_matcher_spec.rb +21 -21
  73. data/spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb +10 -10
  74. data/spec/shoulda/matchers/action_controller/rescue_from_matcher_spec.rb +45 -18
  75. data/spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb +8 -8
  76. data/spec/shoulda/matchers/action_controller/route_matcher_spec.rb +19 -19
  77. data/spec/shoulda/matchers/action_controller/route_params_spec.rb +6 -6
  78. data/spec/shoulda/matchers/action_controller/set_session_matcher_spec.rb +11 -11
  79. data/spec/shoulda/matchers/action_controller/set_the_flash_matcher_spec.rb +44 -44
  80. data/spec/shoulda/matchers/action_controller/strong_parameters_matcher_spec.rb +205 -0
  81. data/spec/shoulda/matchers/active_model/allow_mass_assignment_of_matcher_spec.rb +24 -24
  82. data/spec/shoulda/matchers/active_model/allow_value_matcher_spec.rb +37 -37
  83. data/spec/shoulda/matchers/active_model/disallow_value_matcher_spec.rb +17 -21
  84. data/spec/shoulda/matchers/active_model/ensure_exclusion_of_matcher_spec.rb +24 -24
  85. data/spec/shoulda/matchers/active_model/ensure_inclusion_of_matcher_spec.rb +173 -67
  86. data/spec/shoulda/matchers/active_model/ensure_length_of_matcher_spec.rb +40 -40
  87. data/spec/shoulda/matchers/active_model/exception_message_finder_spec.rb +20 -20
  88. data/spec/shoulda/matchers/active_model/helpers_spec.rb +27 -25
  89. data/spec/shoulda/matchers/active_model/numericality_matchers/comparison_matcher_spec.rb +126 -13
  90. data/spec/shoulda/matchers/active_model/numericality_matchers/even_number_matcher_spec.rb +59 -0
  91. data/spec/shoulda/matchers/active_model/numericality_matchers/odd_number_matcher_spec.rb +59 -0
  92. data/spec/shoulda/matchers/active_model/numericality_matchers/only_integer_matcher_spec.rb +27 -26
  93. data/spec/shoulda/matchers/active_model/validate_absence_of_matcher_spec.rb +15 -15
  94. data/spec/shoulda/matchers/active_model/validate_acceptance_of_matcher_spec.rb +8 -8
  95. data/spec/shoulda/matchers/active_model/validate_confirmation_of_matcher_spec.rb +9 -9
  96. data/spec/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb +229 -44
  97. data/spec/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb +44 -25
  98. data/spec/shoulda/matchers/active_model/validate_uniqueness_of_matcher_spec.rb +110 -62
  99. data/spec/shoulda/matchers/active_model/validation_message_finder_spec.rb +19 -19
  100. data/spec/shoulda/matchers/active_record/accept_nested_attributes_for_matcher_spec.rb +30 -30
  101. data/spec/shoulda/matchers/active_record/association_matcher_spec.rb +378 -192
  102. data/spec/shoulda/matchers/active_record/association_matchers/model_reflection_spec.rb +4 -0
  103. data/spec/shoulda/matchers/active_record/have_db_column_matcher_spec.rb +33 -33
  104. data/spec/shoulda/matchers/active_record/have_db_index_matcher_spec.rb +21 -17
  105. data/spec/shoulda/matchers/active_record/have_readonly_attributes_matcher_spec.rb +8 -8
  106. data/spec/shoulda/matchers/active_record/serialize_matcher_spec.rb +14 -14
  107. data/spec/shoulda/matchers/independent/delegate_matcher/stubbed_target_spec.rb +43 -0
  108. data/spec/shoulda/matchers/independent/delegate_matcher_spec.rb +184 -0
  109. data/spec/spec_helper.rb +4 -0
  110. data/spec/support/activemodel_helpers.rb +2 -2
  111. data/spec/support/capture_helpers.rb +19 -0
  112. data/spec/support/controller_builder.rb +22 -3
  113. data/spec/support/fail_with_message_including_matcher.rb +33 -0
  114. data/spec/support/model_builder.rb +1 -1
  115. data/spec/support/shared_examples/numerical_submatcher.rb +19 -0
  116. data/spec/support/shared_examples/numerical_type_submatcher.rb +17 -0
  117. data/spec/support/test_application.rb +23 -0
  118. metadata +90 -22
  119. checksums.yaml +0 -7
  120. data/spec/shoulda/matchers/active_model/numericality_matchers/odd_even_number_matcher_spec.rb +0 -97
  121. data/spec/support/shared_examples/numerical_submatcher_spec.rb +0 -23
@@ -0,0 +1,157 @@
1
+ module Shoulda # :nodoc:
2
+ module Matchers
3
+ module Independent # :nodoc:
4
+
5
+ # Ensure that a given method is delegated properly.
6
+ #
7
+ # Basic Syntax:
8
+ # it { should delegate_method(:deliver_mail).to(:mailman) }
9
+ #
10
+ # Options:
11
+ # * <tt>:as</tt> - tests that the object being delegated to is called
12
+ # with a certain method (defaults to same name as delegating method)
13
+ # * <tt>:with_arguments</tt> - tests that the method on the object being
14
+ # delegated to is called with certain arguments
15
+ #
16
+ # Examples:
17
+ # it { should delegate_method(:deliver_mail).to(:mailman).
18
+ # as(:deliver_with_haste) }
19
+ # it { should delegate_method(:deliver_mail).to(:mailman).
20
+ # with_arguments('221B Baker St.', :hastily => true) }
21
+ #
22
+ def delegate_method(delegating_method)
23
+ DelegateMatcher.new(delegating_method)
24
+ end
25
+
26
+ class DelegateMatcher
27
+ def initialize(delegating_method)
28
+ @delegating_method = delegating_method
29
+ @delegated_arguments = []
30
+ end
31
+
32
+ def matches?(_subject)
33
+ @subject = _subject
34
+ ensure_target_method_is_present!
35
+ stub_target
36
+
37
+ begin
38
+ subject.send(delegating_method, *delegated_arguments)
39
+ target_has_received_delegated_method? && target_has_received_arguments?
40
+ rescue NoMethodError
41
+ false
42
+ end
43
+ end
44
+
45
+ def description
46
+ add_clarifications_to(
47
+ "delegate method ##{delegating_method} to :#{target_method}"
48
+ )
49
+ end
50
+
51
+ def does_not_match?(subject)
52
+ raise InvalidDelegateMatcher
53
+ end
54
+
55
+ def to(target_method)
56
+ @target_method = target_method
57
+ self
58
+ end
59
+
60
+ def as(method_on_target)
61
+ @method_on_target = method_on_target
62
+ self
63
+ end
64
+
65
+ def with_arguments(*arguments)
66
+ @delegated_arguments = arguments
67
+ self
68
+ end
69
+
70
+ def failure_message
71
+ base = "Expected #{delegating_method_name} to delegate to #{target_method_name}"
72
+ add_clarifications_to(base)
73
+ end
74
+ alias failure_message_for_should failure_message
75
+
76
+ private
77
+
78
+ attr_reader :delegated_arguments, :delegating_method, :method, :subject,
79
+ :target_method, :method_on_target
80
+
81
+ def add_clarifications_to(message)
82
+ if delegated_arguments.present?
83
+ message << " with arguments: #{delegated_arguments.inspect}"
84
+ end
85
+
86
+ if method_on_target.present?
87
+ message << " as ##{method_on_target}"
88
+ end
89
+
90
+ message
91
+ end
92
+
93
+ def delegating_method_name
94
+ method_name_with_class(delegating_method)
95
+ end
96
+
97
+ def target_method_name
98
+ method_name_with_class(target_method)
99
+ end
100
+
101
+ def method_name_with_class(method)
102
+ if Class === subject
103
+ subject.name + '.' + method.to_s
104
+ else
105
+ subject.class.name + '#' + method.to_s
106
+ end
107
+ end
108
+
109
+ def target_has_received_delegated_method?
110
+ stubbed_target.has_received_method?
111
+ end
112
+
113
+ def target_has_received_arguments?
114
+ stubbed_target.has_received_arguments?(*delegated_arguments)
115
+ end
116
+
117
+ def stubbed_method
118
+ method_on_target || delegating_method
119
+ end
120
+
121
+ def stub_target
122
+ local_stubbed_target = stubbed_target
123
+ local_target_method = target_method
124
+
125
+ subject.instance_eval do
126
+ define_singleton_method local_target_method do
127
+ local_stubbed_target
128
+ end
129
+ end
130
+ end
131
+
132
+ def stubbed_target
133
+ @stubbed_target ||= StubbedTarget.new(stubbed_method)
134
+ end
135
+
136
+ def ensure_target_method_is_present!
137
+ if target_method.blank?
138
+ raise TargetNotDefinedError
139
+ end
140
+ end
141
+ end
142
+
143
+ class DelegateMatcher::TargetNotDefinedError < StandardError
144
+ def message
145
+ 'Delegation needs a target. Use the #to method to define one, e.g.
146
+ `post_office.should delegate(:deliver_mail).to(:mailman)`'.squish
147
+ end
148
+ end
149
+
150
+ class DelegateMatcher::InvalidDelegateMatcher < StandardError
151
+ def message
152
+ '#delegate_to does not support #should_not syntax.'
153
+ end
154
+ end
155
+ end
156
+ end
157
+ end
@@ -0,0 +1,34 @@
1
+ module Shoulda # :nodoc:
2
+ module Matchers
3
+ module Independent # :nodoc:
4
+ class DelegateMatcher::StubbedTarget # :nodoc:
5
+ def initialize(method)
6
+ @received_method = false
7
+ @received_arguments = []
8
+ stub_method(method)
9
+ end
10
+
11
+ def has_received_method?
12
+ received_method
13
+ end
14
+
15
+ def has_received_arguments?(*args)
16
+ args == received_arguments
17
+ end
18
+
19
+ private
20
+
21
+ def stub_method(method)
22
+ class_eval do
23
+ define_method method do |*args|
24
+ @received_method = true
25
+ @received_arguments = args
26
+ end
27
+ end
28
+ end
29
+
30
+ attr_reader :received_method, :received_arguments
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,36 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ module NUnitTestCaseDetection
5
+ def self.possible_test_case_constants
6
+ [
7
+ -> { ActiveSupport::TestCase },
8
+ -> { Minitest::Test },
9
+ -> { MiniTest::Unit::TestCase },
10
+ -> { Test::Unit::TestCase }
11
+ ]
12
+ end
13
+
14
+ def self.resolve_constant(future_constant)
15
+ future_constant.call
16
+ rescue NameError
17
+ nil
18
+ end
19
+
20
+ def self.detected_test_case_constants
21
+ possible_test_case_constants.
22
+ map { |future_constant| resolve_constant(future_constant) }.
23
+ compact
24
+ end
25
+
26
+ def self.test_case_constants
27
+ @_test_case_constants ||= detected_test_case_constants
28
+ end
29
+ end
30
+ end
31
+
32
+ def self.nunit_test_case_constants
33
+ Integrations::NUnitTestCaseDetection.test_case_constants
34
+ end
35
+ end
36
+ end
@@ -1,20 +1,19 @@
1
1
  # :enddoc:
2
- require 'rspec/core'
3
2
 
4
- RSpec.configure do |config|
5
- if defined?(::ActiveRecord)
6
- require 'shoulda/matchers/active_record'
7
- require 'shoulda/matchers/active_model'
8
- config.include Shoulda::Matchers::ActiveRecord
9
- config.include Shoulda::Matchers::ActiveModel
3
+ if RSpec.respond_to?(:configure)
4
+ RSpec.configure do |config|
5
+ config.include Shoulda::Matchers::Independent
10
6
 
11
- elsif defined?(::ActiveModel)
12
- require 'shoulda/matchers/active_model'
13
- config.include Shoulda::Matchers::ActiveModel
14
- end
7
+ if defined?(ActiveRecord)
8
+ config.include Shoulda::Matchers::ActiveRecord
9
+ end
10
+
11
+ if defined?(ActiveModel)
12
+ config.include Shoulda::Matchers::ActiveModel
13
+ end
15
14
 
16
- if defined?(::ActionController)
17
- require 'shoulda/matchers/action_controller'
18
- config.include Shoulda::Matchers::ActionController
15
+ if defined?(ActionController)
16
+ config.include Shoulda::Matchers::ActionController
17
+ end
19
18
  end
20
19
  end
@@ -1,6 +1,14 @@
1
- if defined?(ActionController) && defined?(ActionController::TestCase)
2
- require 'shoulda/matchers/action_controller'
1
+ # :enddoc:
2
+ require 'shoulda/matchers/integrations/nunit_test_case_detection'
3
3
 
4
+ Shoulda::Matchers.nunit_test_case_constants.each do |constant|
5
+ constant.class_eval do
6
+ include Shoulda::Matchers::Independent
7
+ extend Shoulda::Matchers::Independent
8
+ end
9
+ end
10
+
11
+ if defined?(ActionController::TestCase)
4
12
  ActionController::TestCase.class_eval do
5
13
  include Shoulda::Matchers::ActionController
6
14
  extend Shoulda::Matchers::ActionController
@@ -11,17 +19,11 @@ if defined?(ActionController) && defined?(ActionController::TestCase)
11
19
  end
12
20
  end
13
21
 
14
- if defined?(ActiveRecord) && defined?(ActiveSupport::TestCase)
15
- require 'shoulda/matchers/active_record'
16
-
22
+ if defined?(ActiveSupport::TestCase)
17
23
  ActiveSupport::TestCase.class_eval do
18
24
  include Shoulda::Matchers::ActiveRecord
19
25
  extend Shoulda::Matchers::ActiveRecord
20
26
  end
21
- end
22
-
23
- if defined?(ActiveModel) && defined?(ActiveSupport::TestCase)
24
- require 'shoulda/matchers/active_model'
25
27
 
26
28
  ActiveSupport::TestCase.class_eval do
27
29
  include Shoulda::Matchers::ActiveModel
@@ -1,5 +1,5 @@
1
1
  module Shoulda
2
2
  module Matchers
3
- VERSION = '2.5.0'.freeze
3
+ VERSION = '2.6.0'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,7 @@
1
+ module Shoulda
2
+ module Matchers
3
+ def self.warn(msg)
4
+ Kernel.warn "Warning from shoulda-matchers:\n\n#{msg}"
5
+ end
6
+ end
7
+ end
@@ -21,8 +21,9 @@ Gem::Specification.new do |s|
21
21
  s.required_ruby_version = '>= 1.9.2'
22
22
  s.add_dependency('activesupport', '>= 3.0.0')
23
23
 
24
- s.add_development_dependency('appraisal', '~> 0.4')
24
+ s.add_development_dependency('appraisal', '~> 1.0.0.beta2')
25
25
  s.add_development_dependency('aruba')
26
+ s.add_development_dependency('pry')
26
27
  s.add_development_dependency('bourne', '~> 1.3')
27
28
  s.add_development_dependency('bundler', '~> 1.1')
28
29
  s.add_development_dependency('cucumber', '~> 1.1')
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+
3
+ describe Shoulda::Matchers::ActionController::CallbackMatcher do
4
+ shared_examples 'CallbackMatcher' do |kind, callback_type|
5
+ let(:matcher) { described_class.new(:authenticate_user!, kind, callback_type) }
6
+ let(:controller) { define_controller('HookController') }
7
+
8
+ describe '#matches?' do
9
+ it "matches when a #{kind} hook is in place" do
10
+ add_callback(kind, callback_type, :authenticate_user!)
11
+
12
+ expect(matcher.matches?(controller)).to be_true
13
+ end
14
+
15
+ it "does not match when a #{kind} hook is missing" do
16
+ expect(matcher.matches?(controller)).to be_false
17
+ end
18
+ end
19
+
20
+ describe 'description' do
21
+ it 'includes the filter kind and name' do
22
+ expect(matcher.description).to eq "have :authenticate_user! as a #{kind}_#{callback_type}"
23
+ end
24
+ end
25
+
26
+ describe 'failure message' do
27
+ it 'includes the filter kind and name that was expected' do
28
+ message = "Expected that HookController would have :authenticate_user! as a #{kind}_#{callback_type}"
29
+
30
+ expect {
31
+ expect(controller).to send("use_#{kind}_#{callback_type}", :authenticate_user!)
32
+ }.to fail_with_message(message)
33
+ end
34
+ end
35
+
36
+ describe 'failure message when negated' do
37
+ it 'includes the filter kind and name that was expected' do
38
+ add_callback(kind, callback_type, :authenticate_user!)
39
+ message = "Expected that HookController would not have :authenticate_user! as a #{kind}_#{callback_type}"
40
+
41
+ expect {
42
+ expect(controller).not_to send("use_#{kind}_#{callback_type}", :authenticate_user!)
43
+ }.to fail_with_message(message)
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def add_callback(kind, callback_type, callback)
50
+ controller.send("#{kind}_#{callback_type}", callback)
51
+ end
52
+ end
53
+
54
+ describe '#use_before_filter' do
55
+ it_behaves_like 'CallbackMatcher', :before, :filter
56
+ end
57
+
58
+ describe '#use_after_filter' do
59
+ it_behaves_like 'CallbackMatcher', :after, :filter
60
+ end
61
+
62
+ describe '#use_around_filter' do
63
+ it_behaves_like 'CallbackMatcher', :around, :filter
64
+ end
65
+
66
+ if rails_4_x?
67
+ describe '#use_before_action' do
68
+ it_behaves_like 'CallbackMatcher', :before, :action
69
+ end
70
+
71
+ describe '#use_after_action' do
72
+ it_behaves_like 'CallbackMatcher', :after, :action
73
+ end
74
+
75
+ describe '#use_around_action' do
76
+ it_behaves_like 'CallbackMatcher', :around, :action
77
+ end
78
+ end
79
+ end
@@ -4,16 +4,16 @@ describe Shoulda::Matchers::ActionController::FilterParamMatcher do
4
4
  it 'accepts filtering a filtered parameter' do
5
5
  filter(:secret)
6
6
 
7
- nil.should filter_param(:secret)
7
+ expect(nil).to filter_param(:secret)
8
8
  end
9
9
 
10
10
  it 'rejects filtering an unfiltered parameter' do
11
11
  filter(:secret)
12
12
  matcher = filter_param(:other)
13
13
 
14
- matcher.matches?(nil).should be_false
14
+ expect(matcher.matches?(nil)).to eq false
15
15
 
16
- matcher.failure_message.should =~ /Expected other to be filtered.*secret/
16
+ expect(matcher.failure_message).to match(/Expected other to be filtered.*secret/)
17
17
  end
18
18
 
19
19
  def filter(param)
@@ -3,40 +3,40 @@ require 'spec_helper'
3
3
  describe Shoulda::Matchers::ActionController::RedirectToMatcher do
4
4
  context 'a controller that redirects' do
5
5
  it 'accepts redirecting to that url' do
6
- controller_redirecting_to('/some/url').should redirect_to('/some/url')
6
+ expect(controller_redirecting_to('/some/url')).to redirect_to('/some/url')
7
7
  end
8
8
 
9
9
  it 'rejects redirecting to a different url' do
10
- controller_redirecting_to('/some/url').
11
- should_not redirect_to('/some/other/url')
10
+ expect(controller_redirecting_to('/some/url')).
11
+ not_to redirect_to('/some/other/url')
12
12
  end
13
13
 
14
14
  it 'accepts redirecting to that url in a block' do
15
- controller_redirecting_to('/some/url').
16
- should redirect_to('somewhere') { '/some/url' }
15
+ expect(controller_redirecting_to('/some/url')).
16
+ to redirect_to('somewhere') { '/some/url' }
17
17
  end
18
18
 
19
19
  it 'rejects redirecting to a different url in a block' do
20
- controller_redirecting_to('/some/url').
21
- should_not redirect_to('somewhere else') { '/some/other/url' }
20
+ expect(controller_redirecting_to('/some/url')).
21
+ not_to redirect_to('somewhere else') { '/some/other/url' }
22
22
  end
23
23
 
24
24
  def controller_redirecting_to(url)
25
- build_response { redirect_to url }
25
+ build_fake_response { redirect_to url }
26
26
  end
27
27
  end
28
28
 
29
29
  context 'a controller that does not redirect' do
30
30
  it 'rejects redirecting to a url' do
31
- controller = build_response { render :text => 'hello' }
31
+ controller = build_fake_response { render text: 'hello' }
32
32
 
33
- controller.should_not redirect_to('/some/url')
33
+ expect(controller).not_to redirect_to('/some/url')
34
34
  end
35
35
  end
36
36
 
37
37
  it 'provides the correct description when provided a block' do
38
38
  matcher = redirect_to('somewhere else') { '/some/other/url' }
39
39
 
40
- matcher.description.should eq 'redirect to somewhere else'
40
+ expect(matcher.description).to eq 'redirect to somewhere else'
41
41
  end
42
42
  end