shoulda-matchers 1.4.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. data/.travis.yml +11 -3
  2. data/Appraisals +3 -3
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +69 -70
  5. data/MIT-LICENSE +1 -1
  6. data/NEWS.md +22 -4
  7. data/README.md +3 -1
  8. data/Rakefile +9 -5
  9. data/features/step_definitions/rails_steps.rb +7 -7
  10. data/features/support/env.rb +1 -1
  11. data/gemfiles/3.0.gemfile +1 -1
  12. data/gemfiles/3.0.gemfile.lock +25 -22
  13. data/gemfiles/3.1.gemfile +1 -1
  14. data/gemfiles/3.1.gemfile.lock +27 -24
  15. data/gemfiles/3.2.gemfile +1 -1
  16. data/gemfiles/3.2.gemfile.lock +56 -52
  17. data/lib/shoulda/matchers/action_controller.rb +3 -2
  18. data/lib/shoulda/matchers/action_controller/assign_to_matcher.rb +10 -8
  19. data/lib/shoulda/matchers/action_controller/filter_param_matcher.rb +2 -4
  20. data/lib/shoulda/matchers/action_controller/redirect_to_matcher.rb +3 -4
  21. data/lib/shoulda/matchers/action_controller/render_template_matcher.rb +3 -4
  22. data/lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb +6 -6
  23. data/lib/shoulda/matchers/action_controller/respond_with_content_type_matcher.rb +5 -2
  24. data/lib/shoulda/matchers/action_controller/respond_with_matcher.rb +2 -2
  25. data/lib/shoulda/matchers/action_controller/route_matcher.rb +12 -12
  26. data/lib/shoulda/matchers/action_controller/set_session_matcher.rb +3 -4
  27. data/lib/shoulda/matchers/action_controller/set_the_flash_matcher.rb +10 -11
  28. data/lib/shoulda/matchers/action_controller/strong_parameters_matcher.rb +121 -0
  29. data/lib/shoulda/matchers/action_mailer/have_sent_email_matcher.rb +7 -4
  30. data/lib/shoulda/matchers/active_model.rb +1 -1
  31. data/lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb +8 -8
  32. data/lib/shoulda/matchers/active_model/allow_value_matcher.rb +5 -4
  33. data/lib/shoulda/matchers/active_model/disallow_value_matcher.rb +3 -3
  34. data/lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb +2 -2
  35. data/lib/shoulda/matchers/active_model/exception_message_finder.rb +0 -1
  36. data/lib/shoulda/matchers/active_model/helpers.rb +16 -7
  37. data/lib/shoulda/matchers/active_model/only_integer_matcher.rb +3 -3
  38. data/lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb +8 -6
  39. data/lib/shoulda/matchers/active_model/validate_format_of_matcher.rb +19 -10
  40. data/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +4 -4
  41. data/lib/shoulda/matchers/active_model/validate_uniqueness_of_matcher.rb +19 -21
  42. data/lib/shoulda/matchers/active_model/validation_matcher.rb +7 -7
  43. data/lib/shoulda/matchers/active_model/validation_message_finder.rb +1 -1
  44. data/lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb +5 -5
  45. data/lib/shoulda/matchers/active_record/association_matcher.rb +3 -3
  46. data/lib/shoulda/matchers/active_record/have_db_column_matcher.rb +11 -7
  47. data/lib/shoulda/matchers/active_record/have_db_index_matcher.rb +2 -2
  48. data/lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb +5 -5
  49. data/lib/shoulda/matchers/active_record/query_the_database_matcher.rb +5 -2
  50. data/lib/shoulda/matchers/active_record/serialize_matcher.rb +3 -3
  51. data/lib/shoulda/matchers/assertion_error.rb +4 -1
  52. data/lib/shoulda/matchers/independent/delegate_matcher.rb +17 -7
  53. data/lib/shoulda/matchers/integrations/rspec.rb +19 -33
  54. data/lib/shoulda/matchers/version.rb +1 -1
  55. data/shoulda-matchers.gemspec +6 -4
  56. data/spec/shoulda/matchers/action_controller/assign_to_matcher_spec.rb +66 -0
  57. data/spec/shoulda/matchers/action_controller/filter_param_matcher_spec.rb +22 -0
  58. data/spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb +42 -0
  59. data/spec/shoulda/matchers/action_controller/render_template_matcher_spec.rb +78 -0
  60. data/spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb +58 -0
  61. data/spec/shoulda/matchers/action_controller/respond_with_content_type_matcher_spec.rb +31 -0
  62. data/spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb +31 -0
  63. data/spec/shoulda/matchers/action_controller/route_matcher_spec.rb +65 -0
  64. data/spec/shoulda/matchers/action_controller/set_session_matcher_spec.rb +51 -0
  65. data/spec/shoulda/matchers/action_controller/set_the_flash_matcher_spec.rb +153 -0
  66. data/spec/shoulda/matchers/action_controller/strong_parameters_matcher_spec.rb +142 -0
  67. data/spec/shoulda/matchers/action_mailer/have_sent_email_spec.rb +324 -0
  68. data/spec/shoulda/matchers/active_model/allow_mass_assignment_of_matcher_spec.rb +111 -0
  69. data/spec/shoulda/matchers/active_model/allow_value_matcher_spec.rb +124 -0
  70. data/spec/shoulda/matchers/active_model/disallow_value_matcher_spec.rb +43 -0
  71. data/spec/shoulda/matchers/active_model/ensure_exclusion_of_matcher_spec.rb +74 -0
  72. data/spec/shoulda/matchers/active_model/ensure_inclusion_of_matcher_spec.rb +171 -0
  73. data/spec/shoulda/matchers/active_model/ensure_length_of_matcher_spec.rb +113 -0
  74. data/spec/shoulda/{active_model → matchers/active_model}/exception_message_finder_spec.rb +2 -2
  75. data/spec/shoulda/matchers/active_model/helpers_spec.rb +158 -0
  76. data/spec/shoulda/matchers/active_model/only_integer_matcher_spec.rb +52 -0
  77. data/spec/shoulda/matchers/active_model/validate_acceptance_of_matcher_spec.rb +41 -0
  78. data/spec/shoulda/matchers/active_model/validate_confirmation_of_matcher_spec.rb +41 -0
  79. data/spec/shoulda/matchers/active_model/validate_format_of_matcher_spec.rb +75 -0
  80. data/spec/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb +73 -0
  81. data/spec/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb +127 -0
  82. data/spec/shoulda/matchers/active_model/validate_uniqueness_of_matcher_spec.rb +175 -0
  83. data/spec/shoulda/{active_model → matchers/active_model}/validation_message_finder_spec.rb +0 -1
  84. data/spec/shoulda/matchers/active_record/accept_nested_attributes_for_matcher_spec.rb +106 -0
  85. data/spec/shoulda/matchers/active_record/association_matcher_spec.rb +534 -0
  86. data/spec/shoulda/matchers/active_record/have_db_column_matcher_spec.rb +111 -0
  87. data/spec/shoulda/matchers/active_record/have_db_index_matcher_spec.rb +78 -0
  88. data/spec/shoulda/matchers/active_record/have_readonly_attributes_matcher_spec.rb +41 -0
  89. data/spec/shoulda/{active_record → matchers/active_record}/query_the_database_matcher_spec.rb +10 -10
  90. data/spec/shoulda/matchers/active_record/serialize_matcher_spec.rb +86 -0
  91. data/spec/shoulda/{independent → matchers/independent}/delegate_matcher_spec.rb +55 -34
  92. data/spec/spec_helper.rb +1 -2
  93. data/spec/support/active_model_versions.rb +4 -0
  94. data/spec/support/activemodel_helpers.rb +19 -0
  95. data/spec/support/controller_builder.rb +38 -12
  96. data/spec/support/model_builder.rb +8 -2
  97. metadata +106 -98
  98. data/spec/fixtures/addresses.yml +0 -3
  99. data/spec/fixtures/friendships.yml +0 -0
  100. data/spec/fixtures/posts.yml +0 -5
  101. data/spec/fixtures/products.yml +0 -0
  102. data/spec/fixtures/taggings.yml +0 -0
  103. data/spec/fixtures/tags.yml +0 -9
  104. data/spec/fixtures/users.yml +0 -6
  105. data/spec/shoulda/action_controller/assign_to_matcher_spec.rb +0 -63
  106. data/spec/shoulda/action_controller/filter_param_matcher_spec.rb +0 -20
  107. data/spec/shoulda/action_controller/redirect_to_matcher_spec.rb +0 -40
  108. data/spec/shoulda/action_controller/render_template_matcher_spec.rb +0 -69
  109. data/spec/shoulda/action_controller/render_with_layout_matcher_spec.rb +0 -55
  110. data/spec/shoulda/action_controller/respond_with_content_type_matcher_spec.rb +0 -28
  111. data/spec/shoulda/action_controller/respond_with_matcher_spec.rb +0 -83
  112. data/spec/shoulda/action_controller/route_matcher_spec.rb +0 -65
  113. data/spec/shoulda/action_controller/set_session_matcher_spec.rb +0 -46
  114. data/spec/shoulda/action_controller/set_the_flash_matcher_spec.rb +0 -130
  115. data/spec/shoulda/action_mailer/have_sent_email_spec.rb +0 -333
  116. data/spec/shoulda/active_model/allow_mass_assignment_of_matcher_spec.rb +0 -115
  117. data/spec/shoulda/active_model/allow_value_matcher_spec.rb +0 -131
  118. data/spec/shoulda/active_model/disallow_value_matcher_spec.rb +0 -65
  119. data/spec/shoulda/active_model/ensure_exclusion_of_matcher_spec.rb +0 -79
  120. data/spec/shoulda/active_model/ensure_inclusion_of_matcher_spec.rb +0 -181
  121. data/spec/shoulda/active_model/ensure_length_of_matcher_spec.rb +0 -138
  122. data/spec/shoulda/active_model/helpers_spec.rb +0 -129
  123. data/spec/shoulda/active_model/only_integer_matcher_spec.rb +0 -69
  124. data/spec/shoulda/active_model/validate_acceptance_of_matcher_spec.rb +0 -43
  125. data/spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb +0 -48
  126. data/spec/shoulda/active_model/validate_format_of_matcher_spec.rb +0 -79
  127. data/spec/shoulda/active_model/validate_numericality_of_matcher_spec.rb +0 -112
  128. data/spec/shoulda/active_model/validate_presence_of_matcher_spec.rb +0 -135
  129. data/spec/shoulda/active_model/validate_uniqueness_of_matcher_spec.rb +0 -154
  130. data/spec/shoulda/active_record/accept_nested_attributes_for_matcher_spec.rb +0 -84
  131. data/spec/shoulda/active_record/association_matcher_spec.rb +0 -642
  132. data/spec/shoulda/active_record/have_db_column_matcher_spec.rb +0 -185
  133. data/spec/shoulda/active_record/have_db_index_matcher_spec.rb +0 -105
  134. data/spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb +0 -46
  135. data/spec/shoulda/active_record/serialize_matcher_spec.rb +0 -81
@@ -1,3 +0,0 @@
1
- first:
2
- title: Home
3
- addressable: first (User)
File without changes
@@ -1,5 +0,0 @@
1
- first:
2
- id: 1
3
- title: My Cute Kitten!
4
- body: This is totally a cute kitten
5
- user_id: 1
File without changes
File without changes
@@ -1,9 +0,0 @@
1
- first:
2
- id: 1
3
- name: Stuff
4
- second:
5
- id: 2
6
- name: Rails
7
- third:
8
- id: 3
9
- name: Nothing
@@ -1,6 +0,0 @@
1
- first:
2
- id: 1
3
- name: Some dude
4
- age: 2
5
- email: none@none.com
6
- ssn: 123456789
@@ -1,63 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoulda::Matchers::ActionController::AssignToMatcher do
4
- it "should include the actual class in the failure message" do
5
- define_class(:WrongClass) do
6
- def to_s
7
- 'wrong class'
8
- end
9
- end
10
-
11
- controller = build_response { @var = WrongClass.new }
12
- matcher = assign_to(:var).with_kind_of(Fixnum)
13
- matcher.matches?(controller)
14
-
15
- matcher.failure_message.should =~ /but got wrong class \(WrongClass\)$/
16
- end
17
-
18
- context "a controller that assigns to an instance variable" do
19
- let(:controller) { build_response { @var = 'value' } }
20
-
21
- it "should accept assigning to that variable" do
22
- controller.should assign_to(:var)
23
- end
24
-
25
- it "should accept assigning to that variable with the correct class" do
26
- controller.should assign_to(:var).with_kind_of(String)
27
- end
28
-
29
- it "should reject assigning to that variable with another class" do
30
- controller.should_not assign_to(:var).with_kind_of(Fixnum)
31
- end
32
-
33
- it "should accept assigning the correct value to that variable" do
34
- controller.should assign_to(:var).with('value')
35
- end
36
-
37
- it "should reject assigning another value to that variable" do
38
- controller.should_not assign_to(:var).with('other')
39
- end
40
-
41
- it "should reject assigning to another variable" do
42
- controller.should_not assign_to(:other)
43
- end
44
-
45
- it "should accept assigning to the same value in the test context" do
46
- expected = 'value'
47
- controller.should assign_to(:var).in_context(self).with { expected }
48
- end
49
-
50
- it "should reject assigning to the another value in the test context" do
51
- expected = 'other'
52
- controller.should_not assign_to(:var).in_context(self).with { expected }
53
- end
54
- end
55
-
56
- context "a controller that assigns a nil value to an instance variable" do
57
- let(:controller) { build_response { @var = nil } }
58
-
59
- it "should accept assigning to that variable" do
60
- controller.should assign_to(:var)
61
- end
62
- end
63
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoulda::Matchers::ActionController::FilterParamMatcher do
4
- context "given parameter filters" do
5
- before do
6
- Rails.application.config.filter_parameters = [:secret]
7
- end
8
-
9
- it "should accept filtering that parameter" do
10
- nil.should filter_param(:secret)
11
- end
12
-
13
- it "should reject filtering another parameter" do
14
- matcher = filter_param(:other)
15
- matcher.matches?(nil).should be_false
16
- matcher.failure_message.should include("Expected other to be filtered")
17
- matcher.failure_message.should =~ /secret/
18
- end
19
- end
20
- end
@@ -1,40 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoulda::Matchers::ActionController::RedirectToMatcher do
4
- context "a controller that redirects" do
5
- let(:controller) do
6
- build_response { redirect_to '/some/url' }
7
- end
8
-
9
- it "accepts redirecting to that url" do
10
- controller.should redirect_to('/some/url')
11
- end
12
-
13
- it "rejects redirecting to a different url" do
14
- controller.should_not redirect_to('/some/other/url')
15
- end
16
-
17
- it "accepts redirecting to that url in a block" do
18
- controller.should redirect_to('somewhere') { '/some/url' }
19
- end
20
-
21
- it "rejects redirecting to a different url in a block" do
22
- controller.should_not redirect_to('somewhere else') { '/some/other/url' }
23
- end
24
- end
25
-
26
- context "a controller that doesn't redirect" do
27
- let(:controller) do
28
- build_response { render :text => 'hello' }
29
- end
30
-
31
- it "rejects redirecting to a url" do
32
- controller.should_not redirect_to('/some/url')
33
- end
34
- end
35
-
36
- it "provides the correct description when provided a block" do
37
- matcher = redirect_to('somewhere else') { '/some/other/url' }
38
- matcher.description.should == 'redirect to somewhere else'
39
- end
40
- end
@@ -1,69 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoulda::Matchers::ActionController::RenderTemplateMatcher do
4
- include ActionController::TemplateAssertions
5
-
6
- context "a controller that renders a template" do
7
- let(:controller) { build_response(:action => 'show') { render } }
8
-
9
- it "accepts rendering that template" do
10
- controller.should render_template(:show)
11
- end
12
-
13
- it "rejects rendering a different template" do
14
- controller.should_not render_template(:index)
15
- end
16
-
17
- it "accepts rendering that template in the given context" do
18
- controller.should render_template(:show).in_context(self)
19
- end
20
-
21
- it "rejects rendering a different template in the given context" do
22
- controller.should_not render_template(:index).in_context(self)
23
- end
24
- end
25
-
26
- context "a controller that renders a partial" do
27
- let(:controller) { build_response(:partial => '_customer') { render :partial => 'customer' } }
28
-
29
- it "accepts rendering that partial" do
30
- controller.should render_template(:partial => '_customer')
31
- end
32
-
33
- it "rejects rendering a different template" do
34
- controller.should_not render_template(:partial => '_client')
35
- end
36
-
37
- it "accepts rendering that template in the given context" do
38
- controller.should render_template(:partial => '_customer').in_context(self)
39
- end
40
-
41
- it "rejects rendering a different template in the given context" do
42
- controller.should_not render_template(:partial => '_client').in_context(self)
43
- end
44
- end
45
-
46
- context "a controller that doesn't render partials" do
47
- let(:controller) { build_response(:action => 'show') { render } }
48
-
49
- it "should not render a partial" do
50
- controller.should render_template(:partial => false)
51
- end
52
- end
53
-
54
- context "a controller that renders a partial several times" do
55
- let(:controller) { build_response(:partial => '_customer') { render :partial => 'customer', :collection => [1,2] } }
56
-
57
- it "accepts rendering that partial twice" do
58
- controller.should render_template(:partial => '_customer', :count => 2)
59
- end
60
- end
61
-
62
- context "a controller that doesn't render a template" do
63
- let(:controller) { build_response { render :nothing => true } }
64
-
65
- it "rejects rendering a template" do
66
- controller.should_not render_template(:show)
67
- end
68
- end
69
- end
@@ -1,55 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoulda::Matchers::ActionController::RenderWithLayoutMatcher do
4
- include ActionController::TemplateAssertions
5
-
6
- context "a controller that renders with a layout" do
7
- let(:controller) { build_response { render :layout => 'wide' } }
8
-
9
- before do
10
- create_view('layouts/wide.html.erb', 'some content, <%= yield %>')
11
- end
12
-
13
- it "should accept rendering with any layout" do
14
- controller.should render_with_layout
15
- end
16
-
17
- it "should accept rendering with that layout" do
18
- controller.should render_with_layout(:wide)
19
- end
20
-
21
- it "should reject rendering with another layout" do
22
- controller.should_not render_with_layout(:other)
23
- end
24
- end
25
-
26
- context "a controller that renders without a layout" do
27
- let(:controller) { build_response { render :layout => false } }
28
-
29
- it "should reject rendering with a layout" do
30
- controller.should_not render_with_layout
31
- end
32
- end
33
-
34
- context "a controller that renders a partial" do
35
- let(:controller) { build_response { render :partial => 'partial' } }
36
-
37
- it "should reject rendering with a layout" do
38
- controller.should_not render_with_layout
39
- end
40
- end
41
-
42
- context "given a context with layouts" do
43
- let(:layout) { 'happy' }
44
- let(:controller) { build_response { render :layout => false } }
45
-
46
- before do
47
- @layouts = Hash.new(0)
48
- @layouts[layout] = 1
49
- end
50
-
51
- it "should accept that layout in that context" do
52
- controller.should render_with_layout(layout).in_context(self)
53
- end
54
- end
55
- end
@@ -1,28 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoulda::Matchers::ActionController::RespondWithContentTypeMatcher do
4
- context "a controller responding with content type :xml" do
5
- let(:controller) { build_response { render :xml => { :user => "thoughtbot" }.to_xml } }
6
-
7
- it "should accept responding with content type :xml" do
8
- controller.should respond_with_content_type(:xml)
9
- end
10
-
11
- it "should accept responding with content type 'application/xml'" do
12
- controller.should respond_with_content_type('application/xml')
13
- end
14
-
15
- it "should accept responding with content type /xml/" do
16
- controller.should respond_with_content_type(/xml/)
17
- end
18
-
19
- it "should reject responding with another content type" do
20
- controller.should_not respond_with_content_type(:json)
21
- end
22
- end
23
-
24
- it "should generate the correct test name" do
25
- respond_with_content_type(:xml).description.
26
- should == "respond with content type of application/xml"
27
- end
28
- end
@@ -1,83 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoulda::Matchers::ActionController::RespondWithMatcher do
4
- context "a controller responding with success" do
5
- let(:controller) { build_response { render :text => "text", :status => 200 } }
6
-
7
- it "should accept responding with 200" do
8
- controller.should respond_with(200)
9
- end
10
-
11
- it "should accept responding with :success" do
12
- controller.should respond_with(:success)
13
- end
14
-
15
- it "should reject responding with another status" do
16
- controller.should_not respond_with(:error)
17
- end
18
- end
19
-
20
- context "a controller responding with redirect" do
21
- let(:controller) { build_response { render :text => "text", :status => 301 } }
22
-
23
- it "should accept responding with 301" do
24
- controller.should respond_with(301)
25
- end
26
-
27
- it "should accept responding with :redirect" do
28
- controller.should respond_with(:redirect)
29
- end
30
-
31
- it "should reject responding with another status" do
32
- controller.should_not respond_with(:error)
33
- end
34
- end
35
-
36
- context "a controller responding with missing" do
37
- let(:controller) { build_response { render :text => "text", :status => 404 } }
38
-
39
- it "should accept responding with 404" do
40
- controller.should respond_with(404)
41
- end
42
-
43
- it "should accept responding with :missing" do
44
- controller.should respond_with(:missing)
45
- end
46
-
47
- it "should reject responding with another status" do
48
- controller.should_not respond_with(:success)
49
- end
50
- end
51
-
52
- context "a controller responding with error" do
53
- let(:controller) { build_response { render :text => "text", :status => 500 } }
54
-
55
- it "should accept responding with 500" do
56
- controller.should respond_with(500)
57
- end
58
-
59
- it "should accept responding with :error" do
60
- controller.should respond_with(:error)
61
- end
62
-
63
- it "should reject responding with another status" do
64
- controller.should_not respond_with(:success)
65
- end
66
- end
67
-
68
- context "a controller responding with not implemented" do
69
- let(:controller) { build_response { render :text => "text", :status => 501 } }
70
-
71
- it "should accept responding with 501" do
72
- controller.should respond_with(501)
73
- end
74
-
75
- it "should accept responding with :not_implemented" do
76
- controller.should respond_with(:not_implemented)
77
- end
78
-
79
- it "should reject responding with another status" do
80
- controller.should_not respond_with(:success)
81
- end
82
- end
83
- end
@@ -1,65 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoulda::Matchers::ActionController::RouteMatcher do
4
- context "given a controller with a defined glob url" do
5
- let(:controller) { define_controller('Examples').new }
6
-
7
- before do
8
- define_routes do
9
- match 'examples/*id', :to => 'examples#example'
10
- end
11
- end
12
-
13
- it "should accept glob route" do
14
- controller.should route(:get, '/examples/foo/bar').
15
- to(:action => 'example', :id => 'foo/bar')
16
- end
17
- end
18
-
19
- context "given a controller with a defined route" do
20
- let!(:controller) { define_controller('Examples').new }
21
-
22
- before do
23
- define_routes do
24
- match 'examples/:id', :to => 'examples#example'
25
- end
26
- end
27
-
28
- it "should accept routing the correct path to the correct parameters" do
29
- controller.should route(:get, '/examples/1').
30
- to(:action => 'example', :id => '1')
31
- end
32
-
33
- it "should accept a symbol controller" do
34
- Object.new.should route(:get, '/examples/1').
35
- to(:controller => :examples,
36
- :action => 'example',
37
- :id => '1')
38
- end
39
-
40
- it "should accept a symbol action" do
41
- controller.should route(:get, '/examples/1').
42
- to(:action => :example, :id => '1')
43
- end
44
-
45
- it "should accept a non-string parameter" do
46
- controller.should route(:get, '/examples/1').
47
- to(:action => 'example', :id => 1)
48
- end
49
-
50
- it "should reject an undefined route" do
51
- controller.should_not route(:get, '/bad_route').to(:var => 'value')
52
- end
53
-
54
- it "should reject a route for another controller" do
55
- other = define_controller('Other').new
56
- other.should_not route(:get, '/examples/1').
57
- to(:action => 'example', :id => '1')
58
- end
59
-
60
- it "should reject a route for different parameters" do
61
- controller.should_not route(:get, '/examples/1').
62
- to(:action => 'other', :id => '1')
63
- end
64
- end
65
- end