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
@@ -5,74 +5,74 @@ describe Shoulda::Matchers::ActionController::RenderTemplateMatcher do
5
5
 
6
6
  context 'a controller that renders a template' do
7
7
  it 'accepts rendering that template' do
8
- controller_with_show.should render_template(:show)
8
+ expect(controller_with_show).to render_template(:show)
9
9
  end
10
10
 
11
11
  it 'rejects rendering a different template' do
12
- controller_with_show.should_not render_template(:index)
12
+ expect(controller_with_show).not_to render_template(:index)
13
13
  end
14
14
 
15
15
  it 'accepts rendering that template in the given context' do
16
- controller_with_show.should render_template(:show).in_context(self)
16
+ expect(controller_with_show).to render_template(:show).in_context(self)
17
17
  end
18
18
 
19
19
  it 'rejects rendering a different template in the given context' do
20
- controller_with_show.should_not render_template(:index).in_context(self)
20
+ expect(controller_with_show).not_to render_template(:index).in_context(self)
21
21
  end
22
22
 
23
23
  def controller_with_show
24
- build_response(:action => 'show') { render }
24
+ build_fake_response(action: 'show') { render }
25
25
  end
26
26
  end
27
27
 
28
28
  context 'a controller that renders a partial' do
29
29
  it 'accepts rendering that partial' do
30
- controller_with_customer_partial.
31
- should render_template(:partial => '_customer')
30
+ expect(controller_with_customer_partial).
31
+ to render_template(partial: '_customer')
32
32
  end
33
33
 
34
34
  it 'rejects rendering a different template' do
35
- controller_with_customer_partial.
36
- should_not render_template(:partial => '_client')
35
+ expect(controller_with_customer_partial).
36
+ not_to render_template(partial: '_client')
37
37
  end
38
38
 
39
39
  it 'accepts rendering that template in the given context' do
40
- controller_with_customer_partial.
41
- should render_template(:partial => '_customer').in_context(self)
40
+ expect(controller_with_customer_partial).
41
+ to render_template(partial: '_customer').in_context(self)
42
42
  end
43
43
 
44
44
  it 'rejects rendering a different template in the given context' do
45
- controller_with_customer_partial.
46
- should_not render_template(:partial => '_client').in_context(self)
45
+ expect(controller_with_customer_partial).
46
+ not_to render_template(partial: '_client').in_context(self)
47
47
  end
48
48
 
49
49
  def controller_with_customer_partial
50
- build_response(:partial => '_customer') { render :partial => 'customer' }
50
+ build_fake_response(partial: '_customer') { render partial: 'customer' }
51
51
  end
52
52
  end
53
53
 
54
54
  context 'a controller that does not render partials' do
55
55
  it 'accepts not rendering a partial' do
56
- controller = build_response(:action => 'show') { render }
56
+ controller = build_fake_response(action: 'show') { render }
57
57
 
58
- controller.should render_template(:partial => false)
58
+ expect(controller).to render_template(partial: false)
59
59
  end
60
60
  end
61
61
 
62
62
  context 'a controller that renders a partial several times' do
63
63
  it 'accepts rendering that partial twice' do
64
- controller = build_response(:partial => '_customer') do
65
- render :partial => 'customer', :collection => [1,2]
64
+ controller = build_fake_response(partial: '_customer') do
65
+ render partial: 'customer', collection: [1,2]
66
66
  end
67
67
 
68
- controller.should render_template(:partial => '_customer', :count => 2)
68
+ expect(controller).to render_template(partial: '_customer', count: 2)
69
69
  end
70
70
  end
71
71
 
72
72
  context 'a controller that does not render a template' do
73
73
  it 'rejects rendering a template' do
74
- build_response { render :nothing => true }.
75
- should_not render_template(:show)
74
+ expect(build_fake_response { render nothing: true }).
75
+ not_to render_template(:show)
76
76
  end
77
77
  end
78
78
  end
@@ -5,37 +5,37 @@ describe Shoulda::Matchers::ActionController::RenderWithLayoutMatcher do
5
5
 
6
6
  context 'a controller that renders with a layout' do
7
7
  it 'accepts rendering with any layout' do
8
- controller_with_wide_layout.should render_with_layout
8
+ expect(controller_with_wide_layout).to render_with_layout
9
9
  end
10
10
 
11
11
  it 'accepts rendering with that layout' do
12
- controller_with_wide_layout.should render_with_layout(:wide)
12
+ expect(controller_with_wide_layout).to render_with_layout(:wide)
13
13
  end
14
14
 
15
15
  it 'rejects rendering with another layout' do
16
- controller_with_wide_layout.should_not render_with_layout(:other)
16
+ expect(controller_with_wide_layout).not_to render_with_layout(:other)
17
17
  end
18
18
 
19
19
  def controller_with_wide_layout
20
20
  create_view('layouts/wide.html.erb', 'some content, <%= yield %>')
21
- build_response { render :layout => 'wide' }
21
+ build_fake_response { render layout: 'wide' }
22
22
  end
23
23
  end
24
24
 
25
25
  context 'a controller that renders without a layout' do
26
26
 
27
27
  it 'rejects rendering with a layout' do
28
- controller_without_layout = build_response { render :layout => false }
28
+ controller_without_layout = build_fake_response { render layout: false }
29
29
 
30
- controller_without_layout.should_not render_with_layout
30
+ expect(controller_without_layout).not_to render_with_layout
31
31
  end
32
32
  end
33
33
 
34
34
  context 'a controller that renders a partial' do
35
35
  it 'rejects rendering with a layout' do
36
- controller_with_partial = build_response { render :partial => 'partial' }
36
+ controller_with_partial = build_fake_response { render partial: 'partial' }
37
37
 
38
- controller_with_partial.should_not render_with_layout
38
+ expect(controller_with_partial).not_to render_with_layout
39
39
  end
40
40
  end
41
41
 
@@ -43,7 +43,7 @@ describe Shoulda::Matchers::ActionController::RenderWithLayoutMatcher do
43
43
  it 'accepts that layout in that context' do
44
44
  set_in_context_layout('happy')
45
45
 
46
- controller_without_layout.should render_with_layout('happy').in_context(self)
46
+ expect(controller_without_layout).to render_with_layout('happy').in_context(self)
47
47
  end
48
48
 
49
49
  def set_in_context_layout(layout)
@@ -57,7 +57,7 @@ describe Shoulda::Matchers::ActionController::RenderWithLayoutMatcher do
57
57
  end
58
58
 
59
59
  def controller_without_layout
60
- build_response { render :layout => false }
60
+ build_fake_response { render layout: false }
61
61
  end
62
62
  end
63
63
  end
@@ -2,62 +2,89 @@ require 'spec_helper'
2
2
 
3
3
  describe Shoulda::Matchers::ActionController::RescueFromMatcher do
4
4
  context 'a controller that rescues from RuntimeError' do
5
- it "asserts controller is setup with rescue_from" do
6
- controller_with_rescue_from.should rescue_from RuntimeError
5
+ it 'asserts controller is setup with rescue_from' do
6
+ expect(controller_with_rescue_from).to rescue_from RuntimeError
7
7
  end
8
8
 
9
9
  context 'with a handler method' do
10
- it "asserts rescue_from was set up with handler method" do
11
- controller_with_rescue_from_and_method.should rescue_from(RuntimeError).with(:error_method)
10
+ it 'asserts rescue_from can find the handler when it is public' do
11
+ controller = controller_with_rescue_from_and_method(:public)
12
+ check_rescue_with_method_for(controller)
12
13
  end
13
14
 
14
- it "asserts rescue_from was not set up with incorrect handler method" do
15
- controller_with_rescue_from_and_method.should_not rescue_from(RuntimeError).with(:other_method)
15
+ it 'asserts rescue_from can find the handler when it is protected' do
16
+ controller = controller_with_rescue_from_and_method(:protected)
17
+ check_rescue_with_method_for(controller)
16
18
  end
17
19
 
18
- it "asserts the controller responds to the handler method" do
20
+ it 'asserts rescue_from can find the handler when it is private' do
21
+ controller = controller_with_rescue_from_and_method(:private)
22
+ check_rescue_with_method_for(controller)
23
+ end
24
+
25
+ it 'asserts rescue_from was not set up with incorrect handler method' do
26
+ expect(controller_with_rescue_from_and_method).not_to rescue_from(RuntimeError).with(:other_method)
27
+ end
28
+
29
+ it 'asserts the controller responds to the handler method' do
19
30
  matcher = rescue_from(RuntimeError).with(:error_method)
20
- matcher.matches?(controller_with_rescue_from_and_invalid_method).should be_false
21
- matcher.failure_message.should =~ /does not respond to/
31
+ expect(matcher.matches?(controller_with_rescue_from_and_invalid_method)).to eq false
32
+ expect(matcher.failure_message).to match(/does not respond to/)
22
33
  end
23
34
  end
24
35
 
25
36
  context 'without a handler method' do
26
- it "the handler method is not included in the description" do
37
+ it 'the handler method is not included in the description' do
27
38
  matcher = rescue_from(RuntimeError)
28
- matcher.matches?(controller_with_rescue_from).should be_true
29
- matcher.description.should_not =~ /with #/
39
+ expect(matcher.matches?(controller_with_rescue_from)).to eq true
40
+ expect(matcher.description).not_to match(/with #/)
30
41
  end
31
42
  end
32
43
  end
33
44
 
34
45
  context 'a controller that does not rescue from RuntimeError' do
35
- it "asserts controller is not setup with rescue_from" do
46
+ it 'asserts controller is not setup with rescue_from' do
36
47
  matcher = rescue_from RuntimeError
37
- define_controller("RandomController").should_not matcher
38
- matcher.failure_message_when_negated.should =~ /Did not expect \w+ to rescue from/
48
+ expect(define_controller('RandomController')).not_to matcher
49
+ expect(matcher.failure_message_when_negated).to match(/Did not expect \w+ to rescue from/)
39
50
  end
40
51
  end
41
52
 
53
+ def check_rescue_with_method_for(controller)
54
+ expect(controller).to rescue_from(RuntimeError).with(:error_method)
55
+ end
56
+
42
57
  def controller_with_rescue_from
43
- define_controller "RescueRuntimeError" do
58
+ define_controller 'RescueRuntimeError' do
44
59
  rescue_from(RuntimeError) {}
45
60
  end
46
61
  end
47
62
 
48
63
  def controller_with_rescue_from_and_invalid_method
49
- define_controller "RescueRuntimeErrorWithMethod" do
64
+ define_controller 'RescueRuntimeErrorWithMethod' do
50
65
  rescue_from RuntimeError, with: :error_method
51
66
  end
52
67
  end
53
68
 
54
- def controller_with_rescue_from_and_method
69
+ def controller_with_rescue_from_and_method(access = :public)
55
70
  controller = controller_with_rescue_from_and_invalid_method
56
71
  class << controller
57
72
  def error_method
58
73
  true
59
74
  end
60
75
  end
76
+
77
+ case access
78
+ when :protected
79
+ class << controller
80
+ protected :error_method
81
+ end
82
+ when :private
83
+ class << controller
84
+ private :error_method
85
+ end
86
+ end
87
+
61
88
  controller
62
89
  end
63
90
  end
@@ -1,31 +1,31 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Shoulda::Matchers::ActionController::RespondWithMatcher do
4
- statuses = { :success => 200, :redirect => 301, :missing => 404, :error => 500,
5
- :not_implemented => 501 }
4
+ statuses = { success: 200, redirect: 301, missing: 404, error: 500,
5
+ not_implemented: 501 }
6
6
 
7
7
  statuses.each do |human_name, numeric_code|
8
8
  context "a controller responding with #{human_name}" do
9
9
  it 'accepts responding with a numeric response code' do
10
- controller_with_status(numeric_code).should respond_with(numeric_code)
10
+ expect(controller_with_status(numeric_code)).to respond_with(numeric_code)
11
11
  end
12
12
 
13
13
  it 'accepts responding with a symbol response code' do
14
- controller_with_status(numeric_code).should respond_with(human_name)
14
+ expect(controller_with_status(numeric_code)).to respond_with(human_name)
15
15
  end
16
16
 
17
17
  it 'rejects responding with another status' do
18
18
  another_status = statuses.except(human_name).keys.first
19
19
 
20
- controller_with_status(numeric_code).
21
- should_not respond_with(another_status)
20
+ expect(controller_with_status(numeric_code)).
21
+ not_to respond_with(another_status)
22
22
  end
23
23
  end
24
24
  end
25
25
 
26
26
  def controller_with_status(status)
27
- build_response do
28
- render :text => 'text', :status => status
27
+ build_fake_response do
28
+ render text: 'text', status: status
29
29
  end
30
30
  end
31
31
  end
@@ -6,62 +6,62 @@ describe Shoulda::Matchers::ActionController::RouteMatcher, type: :controller do
6
6
  controller = define_controller('Examples').new
7
7
 
8
8
  define_routes do
9
- get 'examples/*id', :to => 'examples#example'
9
+ get 'examples/*id', to: 'examples#example'
10
10
  end
11
11
 
12
- controller.should route(:get, '/examples/foo/bar').
13
- to(:action => 'example', :id => 'foo/bar')
12
+ expect(controller).to route(:get, '/examples/foo/bar').
13
+ to(action: 'example', id: 'foo/bar')
14
14
  end
15
15
  end
16
16
 
17
17
  context 'given a controller with a defined route' do
18
18
 
19
19
  it 'accepts routing the correct path to the correct parameters' do
20
- route_examples_to_examples.should route(:get, '/examples/1').
21
- to(:action => 'example', :id => '1')
20
+ expect(route_examples_to_examples).to route(:get, '/examples/1').
21
+ to(action: 'example', id: '1')
22
22
  end
23
23
 
24
24
  it 'accepts a symbol controller' do
25
25
  route_examples_to_examples
26
- Object.new.should route(:get, '/examples/1').
27
- to(:controller => :examples, :action => 'example', :id => '1')
26
+ expect(Object.new).to route(:get, '/examples/1').
27
+ to(controller: :examples, action: 'example', id: '1')
28
28
  end
29
29
 
30
30
  it 'accepts a symbol action' do
31
- route_examples_to_examples.should route(:get, '/examples/1').
32
- to(:action => :example, :id => '1')
31
+ expect(route_examples_to_examples).to route(:get, '/examples/1').
32
+ to(action: :example, id: '1')
33
33
  end
34
34
 
35
35
  it 'accepts a non-string parameter' do
36
- route_examples_to_examples.should route(:get, '/examples/1').
37
- to(:action => 'example', :id => 1)
36
+ expect(route_examples_to_examples).to route(:get, '/examples/1').
37
+ to(action: 'example', id: 1)
38
38
  end
39
39
 
40
40
  it 'rejects an undefined route' do
41
- route_examples_to_examples.
42
- should_not route(:get, '/bad_route').to(:var => 'value')
41
+ expect(route_examples_to_examples).
42
+ not_to route(:get, '/bad_route').to(var: 'value')
43
43
  end
44
44
 
45
45
  it 'rejects a route for another controller' do
46
46
  route_examples_to_examples
47
47
  other = define_controller('Other').new
48
- other.should_not route(:get, '/examples/1').
49
- to(:action => 'example', :id => '1')
48
+ expect(other).not_to route(:get, '/examples/1').
49
+ to(action: 'example', id: '1')
50
50
  end
51
51
 
52
52
  it 'rejects a route for different parameters' do
53
- route_examples_to_examples.should_not route(:get, '/examples/1').
54
- to(:action => 'other', :id => '1')
53
+ expect(route_examples_to_examples).not_to route(:get, '/examples/1').
54
+ to(action: 'other', id: '1')
55
55
  end
56
56
 
57
57
  it "accepts a string as first parameter" do
58
- route_examples_to_examples.should route(:get, '/examples/1').
58
+ expect(route_examples_to_examples).to route(:get, '/examples/1').
59
59
  to("examples#example", id: '1')
60
60
  end
61
61
 
62
62
  def route_examples_to_examples
63
63
  define_routes do
64
- get 'examples/:id', :to => 'examples#example'
64
+ get 'examples/:id', to: 'examples#example'
65
65
  end
66
66
 
67
67
  define_controller('Examples').new
@@ -4,22 +4,22 @@ describe Shoulda::Matchers::ActionController::RouteParams do
4
4
  describe "#normalize" do
5
5
  context "when the route parameters is a hash" do
6
6
  it "stringifies the values in the hash" do
7
- build_route_params(:controller => :examples, :action => 'example', :id => '1').normalize.
8
- should eq({ :controller => "examples", :action => "example", :id => "1" })
7
+ expect(build_route_params(controller: :examples, action: 'example', id: '1').normalize).
8
+ to eq({ controller: "examples", action: "example", id: "1" })
9
9
  end
10
10
  end
11
11
 
12
12
  context "when the route parameters is a string and a hash" do
13
13
  it "produces a hash of route parameters" do
14
- build_route_params("examples#example", id: '1').normalize.
15
- should eq({ :controller => "examples", :action => "example", :id => "1" })
14
+ expect(build_route_params("examples#example", id: '1').normalize).
15
+ to eq({ controller: "examples", action: "example", id: "1" })
16
16
  end
17
17
  end
18
18
 
19
19
  context "when the route params is a string" do
20
20
  it "produces a hash of route params" do
21
- build_route_params("examples#index").normalize.
22
- should eq({ :controller => "examples", :action => "index"})
21
+ expect(build_route_params("examples#index").normalize).
22
+ to eq({ controller: "examples", action: "index"})
23
23
  end
24
24
  end
25
25
  end
@@ -3,45 +3,45 @@ require 'spec_helper'
3
3
  describe Shoulda::Matchers::ActionController::SetSessionMatcher do
4
4
  context 'a controller that sets a session variable' do
5
5
  it 'accepts assigning to that variable' do
6
- controller_with_session(:var => 'hi').should set_session(:var)
6
+ expect(controller_with_session(var: 'hi')).to set_session(:var)
7
7
  end
8
8
 
9
9
  it 'accepts assigning the correct value to that variable' do
10
- controller_with_session(:var => 'hi').should set_session(:var).to('hi')
10
+ expect(controller_with_session(var: 'hi')).to set_session(:var).to('hi')
11
11
  end
12
12
 
13
13
  it 'rejects assigning another value to that variable' do
14
- controller_with_session(:var => 'hi').should_not set_session(:var).to('other')
14
+ expect(controller_with_session(var: 'hi')).not_to set_session(:var).to('other')
15
15
  end
16
16
 
17
17
  it 'rejects assigning to another variable' do
18
- controller_with_session(:var => 'hi').should_not set_session(:other)
18
+ expect(controller_with_session(var: 'hi')).not_to set_session(:other)
19
19
  end
20
20
 
21
21
  it 'accepts assigning nil to another variable' do
22
- controller_with_session(:var => 'hi').should set_session(:other).to(nil)
22
+ expect(controller_with_session(var: 'hi')).to set_session(:other).to(nil)
23
23
  end
24
24
 
25
25
  it 'accepts assigning false to that variable' do
26
- controller_with_session(:var => false).should set_session(:var).to(false)
26
+ expect(controller_with_session(var: false)).to set_session(:var).to(false)
27
27
  end
28
28
 
29
29
  it 'accepts assigning to the same value in the test context' do
30
30
  expected = 'value'
31
31
 
32
- controller_with_session(:var => expected).
33
- should set_session(:var).in_context(self).to { expected }
32
+ expect(controller_with_session(var: expected)).
33
+ to set_session(:var).in_context(self).to { expected }
34
34
  end
35
35
 
36
36
  it 'rejects assigning to the another value in the test context' do
37
37
  expected = 'other'
38
38
 
39
- controller_with_session(:var => 'unexpected').
40
- should_not set_session(:var).in_context(self).to { expected }
39
+ expect(controller_with_session(var: 'unexpected')).
40
+ not_to set_session(:var).in_context(self).to { expected }
41
41
  end
42
42
 
43
43
  def controller_with_session(session_hash)
44
- build_response do
44
+ build_fake_response do
45
45
  session_hash.each do |key, value|
46
46
  session[key] = value
47
47
  end