rspec-rails 2.6.1 → 2.7.0.rc1
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.
- data/README.md +5 -5
- data/features/Transactions.md +84 -0
- data/features/controller_specs/Cookies.md +57 -0
- data/features/controller_specs/anonymous_controller.feature +104 -61
- data/features/controller_specs/bypass_rescue.feature +75 -0
- data/features/matchers/relation_match_array.feature +20 -0
- data/features/mocks/mock_model.feature +6 -6
- data/features/support/env.rb +2 -2
- data/features/view_specs/view_spec.feature +2 -8
- data/lib/autotest/rails_rspec2.rb +1 -1
- data/lib/generators/rspec/controller/templates/controller_spec.rb +1 -1
- data/lib/generators/rspec/install/templates/spec/spec_helper.rb +6 -0
- data/lib/generators/rspec/scaffold/templates/controller_spec.rb +6 -6
- data/lib/generators/rspec/view/templates/view_spec.rb +1 -1
- data/lib/rspec/rails/example/controller_example_group.rb +19 -1
- data/lib/rspec/rails/fixture_support.rb +11 -0
- data/lib/rspec/rails/matchers.rb +1 -0
- data/lib/rspec/rails/matchers/relation_match_array.rb +3 -0
- data/lib/rspec/rails/matchers/routing_matchers.rb +16 -14
- data/lib/rspec/rails/mocks.rb +12 -7
- data/lib/rspec/rails/version.rb +1 -1
- data/spec/generators/rspec/controller/controller_generator_spec.rb +86 -0
- data/spec/generators/rspec/helper/helper_generator_spec.rb +30 -0
- data/spec/generators/rspec/install/install_generator_spec.rb +18 -0
- data/spec/generators/rspec/integration/integration_generator_spec.rb +44 -0
- data/spec/generators/rspec/mailer/mailer_generator_spec.rb +48 -0
- data/spec/generators/rspec/model/model_generator_spec.rb +52 -0
- data/spec/generators/rspec/observer/observer_generator_spec.rb +21 -0
- data/spec/generators/rspec/scaffold/scaffold_generator_spec.rb +113 -0
- data/spec/generators/rspec/view/view_generator_spec.rb +41 -0
- data/spec/rspec/rails/example/controller_example_group_spec.rb +39 -3
- data/spec/rspec/rails/matchers/relation_match_array_spec.rb +19 -0
- data/spec/rspec/rails/matchers/route_to_spec.rb +25 -3
- data/spec/rspec/rails/mocks/mock_model_spec.rb +62 -2
- data/spec/rspec/rails/mocks/stub_model_spec.rb +0 -1
- data/spec/spec_helper.rb +2 -1
- data/spec/{rspec/rails/mocks → support}/ar_classes.rb +5 -2
- metadata +102 -99
- data/.document +0 -5
- data/.gitignore +0 -14
- data/.rspec +0 -1
- data/.travis.yml +0 -11
- data/History.md +0 -1
- data/License.txt +0 -23
- data/README_DEV.md +0 -43
- data/Rakefile +0 -152
- data/Thorfile +0 -45
- data/Upgrade.md +0 -1
- data/cucumber.yml +0 -3
- data/features/.nav +0 -35
- data/features/Changelog.md +0 -162
- data/gemfiles/.bundle/config +0 -2
- data/gemfiles/base.rb +0 -60
- data/gemfiles/rails-3-0-stable +0 -6
- data/gemfiles/rails-3.0.0 +0 -5
- data/gemfiles/rails-3.0.1 +0 -5
- data/gemfiles/rails-3.0.2 +0 -5
- data/gemfiles/rails-3.0.3 +0 -5
- data/gemfiles/rails-3.0.4 +0 -5
- data/gemfiles/rails-3.0.5 +0 -5
- data/gemfiles/rails-3.0.6 +0 -5
- data/gemfiles/rails-3.0.7 +0 -5
- data/gemfiles/rails-3.1.0.rc1 +0 -5
- data/gemfiles/rails-master +0 -5
- data/rspec-rails.gemspec +0 -34
- data/templates/generate_stuff.rb +0 -21
- data/templates/run_specs.rb +0 -9
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'generators/rspec/install/install_generator'
|
3
|
+
|
4
|
+
describe Rspec::Generators::InstallGenerator do
|
5
|
+
destination File.expand_path("../../../../../tmp", __FILE__)
|
6
|
+
|
7
|
+
before { prepare_destination }
|
8
|
+
|
9
|
+
it "generates .rspec" do
|
10
|
+
run_generator
|
11
|
+
file('.rspec').should exist
|
12
|
+
end
|
13
|
+
|
14
|
+
it "generates spec/spec_helper.rb" do
|
15
|
+
run_generator
|
16
|
+
File.read( file('spec/spec_helper.rb') ).should =~ /^require 'rspec\/autorun'$/m
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Generators are not automatically loaded by Rails
|
4
|
+
require 'generators/rspec/integration/integration_generator'
|
5
|
+
|
6
|
+
describe Rspec::Generators::IntegrationGenerator do
|
7
|
+
# Tell the generator where to put its output (what it thinks of as Rails.root)
|
8
|
+
destination File.expand_path("../../../../../tmp", __FILE__)
|
9
|
+
|
10
|
+
before { prepare_destination }
|
11
|
+
|
12
|
+
describe 'are not generated' do
|
13
|
+
before do
|
14
|
+
run_generator %w(posts --no-request-specs)
|
15
|
+
end
|
16
|
+
describe 'index.html.erb' do
|
17
|
+
subject { file('spec/requests/posts_spec.rb') }
|
18
|
+
it { should_not exist }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'are generated' do
|
23
|
+
describe 'without webrat matchers by default' do
|
24
|
+
before do
|
25
|
+
run_generator %w(posts)
|
26
|
+
end
|
27
|
+
subject { file('spec/requests/posts_spec.rb') }
|
28
|
+
it { should exist }
|
29
|
+
it { should contain /require 'spec_helper'/ }
|
30
|
+
it { should contain /describe "GET \/posts"/ }
|
31
|
+
it { should contain /get posts_index_path/ }
|
32
|
+
end
|
33
|
+
describe 'with webrat matchers' do
|
34
|
+
before do
|
35
|
+
run_generator %w(posts --webrat)
|
36
|
+
end
|
37
|
+
subject { file('spec/requests/posts_spec.rb') }
|
38
|
+
it { should exist }
|
39
|
+
it { should contain /require 'spec_helper'/ }
|
40
|
+
it { should contain /describe "GET \/posts"/ }
|
41
|
+
it { should contain /visit posts_index_path/ }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Generators are not automatically loaded by Rails
|
4
|
+
require 'generators/rspec/mailer/mailer_generator'
|
5
|
+
|
6
|
+
describe Rspec::Generators::MailerGenerator do
|
7
|
+
# Tell the generator where to put its output (what it thinks of as Rails.root)
|
8
|
+
destination File.expand_path("../../../../../tmp", __FILE__)
|
9
|
+
|
10
|
+
before { prepare_destination }
|
11
|
+
|
12
|
+
describe 'mailer spec' do
|
13
|
+
subject { file('spec/mailers/posts_spec.rb') }
|
14
|
+
describe 'a spec is created for each action' do
|
15
|
+
before do
|
16
|
+
run_generator %w(posts index show)
|
17
|
+
end
|
18
|
+
it { should exist }
|
19
|
+
it { should contain /require "spec_helper"/ }
|
20
|
+
it { should contain /describe "index" do/ }
|
21
|
+
it { should contain /describe "show" do/ }
|
22
|
+
end
|
23
|
+
describe 'creates placeholder when no actions specified' do
|
24
|
+
before do
|
25
|
+
run_generator %w(posts)
|
26
|
+
end
|
27
|
+
it { should exist }
|
28
|
+
it { should contain /require "spec_helper"/ }
|
29
|
+
it { should contain /pending "add some examples to \(or delete\)/ }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'a fixture is generated for each action' do
|
34
|
+
before do
|
35
|
+
run_generator %w(posts index show)
|
36
|
+
end
|
37
|
+
describe 'index' do
|
38
|
+
subject { file('spec/fixtures/posts/index') }
|
39
|
+
it { should exist }
|
40
|
+
it { should contain /Posts#index/ }
|
41
|
+
end
|
42
|
+
describe 'show' do
|
43
|
+
subject { file('spec/fixtures/posts/show') }
|
44
|
+
it { should exist }
|
45
|
+
it { should contain /Posts#show/ }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Generators are not automatically loaded by Rails
|
4
|
+
require 'generators/rspec/model/model_generator'
|
5
|
+
|
6
|
+
describe Rspec::Generators::ModelGenerator do
|
7
|
+
# Tell the generator where to put its output (what it thinks of as Rails.root)
|
8
|
+
destination File.expand_path("../../../../../tmp", __FILE__)
|
9
|
+
|
10
|
+
before { prepare_destination }
|
11
|
+
|
12
|
+
it 'should run both the model and fixture tasks' do
|
13
|
+
gen = generator %w(posts)
|
14
|
+
gen.should_receive :create_model_spec
|
15
|
+
gen.should_receive :create_fixture_file
|
16
|
+
capture(:stdout) { gen.invoke_all }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'the generated files' do
|
20
|
+
describe 'with fixtures' do
|
21
|
+
before do
|
22
|
+
run_generator %w(posts --fixture)
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'the spec' do
|
26
|
+
subject { file('spec/models/posts_spec.rb') }
|
27
|
+
|
28
|
+
it { should exist }
|
29
|
+
it { should contain /require 'spec_helper'/ }
|
30
|
+
it { should contain /describe Posts/ }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'the fixtures' do
|
34
|
+
subject { file('spec/fixtures/posts.yml') }
|
35
|
+
|
36
|
+
it { should contain Regexp.new '# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html' }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'without fixtures' do
|
41
|
+
before do
|
42
|
+
run_generator %w(posts)
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'the fixtures' do
|
46
|
+
subject { file('spec/fixtures/posts.yml') }
|
47
|
+
|
48
|
+
it { should_not exist }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Generators are not automatically loaded by Rails
|
4
|
+
require 'generators/rspec/observer/observer_generator'
|
5
|
+
|
6
|
+
describe Rspec::Generators::ObserverGenerator do
|
7
|
+
# Tell the generator where to put its output (what it thinks of as Rails.root)
|
8
|
+
destination File.expand_path("../../../../../tmp", __FILE__)
|
9
|
+
|
10
|
+
subject { file('spec/models/posts_observer_spec.rb') }
|
11
|
+
before do
|
12
|
+
prepare_destination
|
13
|
+
run_generator %w(posts)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'the spec' do
|
17
|
+
it { should exist }
|
18
|
+
it { should contain /require 'spec_helper'/ }
|
19
|
+
it { should contain /describe PostsObserver/ }
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Generators are not automatically loaded by Rails
|
4
|
+
require 'generators/rspec/scaffold/scaffold_generator'
|
5
|
+
|
6
|
+
describe Rspec::Generators::ScaffoldGenerator do
|
7
|
+
# Tell the generator where to put its output (what it thinks of as Rails.root)
|
8
|
+
destination File.expand_path("../../../../../tmp", __FILE__)
|
9
|
+
|
10
|
+
before { prepare_destination }
|
11
|
+
|
12
|
+
describe 'controller specs' do
|
13
|
+
subject { file('spec/controllers/posts_controller_spec.rb') }
|
14
|
+
describe 'generated by default' do
|
15
|
+
before do
|
16
|
+
run_generator %w(posts)
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'the spec' do
|
20
|
+
it { should exist }
|
21
|
+
it { should contain /require 'spec_helper'/ }
|
22
|
+
it { should contain /describe PostsController/ }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
describe 'skipped with a flag' do
|
26
|
+
before do
|
27
|
+
run_generator %w(posts --no-controller_specs)
|
28
|
+
end
|
29
|
+
it { should_not exist }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'view specs' do
|
34
|
+
describe 'generated by default' do
|
35
|
+
before do
|
36
|
+
run_generator %w(posts)
|
37
|
+
end
|
38
|
+
describe 'edit' do
|
39
|
+
subject { file("spec/views/posts/edit.html.erb_spec.rb") }
|
40
|
+
it { should exist }
|
41
|
+
it { should contain /require 'spec_helper'/ }
|
42
|
+
it { should contain /describe "(.*)\/edit.html.erb"/ }
|
43
|
+
it { should contain /it "renders the edit (.*) form"/ }
|
44
|
+
end
|
45
|
+
describe 'index' do
|
46
|
+
subject { file("spec/views/posts/index.html.erb_spec.rb") }
|
47
|
+
it { should exist }
|
48
|
+
it { should contain /require 'spec_helper'/ }
|
49
|
+
it { should contain /describe "(.*)\/index.html.erb"/ }
|
50
|
+
it { should contain /it "renders a list of (.*)"/ }
|
51
|
+
end
|
52
|
+
describe 'new' do
|
53
|
+
subject { file("spec/views/posts/new.html.erb_spec.rb") }
|
54
|
+
it { should exist }
|
55
|
+
it { should contain /require 'spec_helper'/ }
|
56
|
+
it { should contain /describe "(.*)\/new.html.erb"/ }
|
57
|
+
it { should contain /it "renders new (.*) form"/ }
|
58
|
+
end
|
59
|
+
describe 'show' do
|
60
|
+
subject { file("spec/views/posts/show.html.erb_spec.rb") }
|
61
|
+
it { should exist }
|
62
|
+
it { should contain /require 'spec_helper'/ }
|
63
|
+
it { should contain /describe "(.*)\/show.html.erb"/ }
|
64
|
+
it { should contain /it "renders attributes in <p>"/ }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe 'skipped with a flag' do
|
69
|
+
before do
|
70
|
+
run_generator %w(posts --no-view-specs)
|
71
|
+
end
|
72
|
+
describe 'edit' do
|
73
|
+
subject { file("spec/views/posts/edit.html.erb_spec.rb") }
|
74
|
+
it { should_not exist }
|
75
|
+
end
|
76
|
+
describe 'index' do
|
77
|
+
subject { file("spec/views/posts/index.html.erb_spec.rb") }
|
78
|
+
it { should_not exist }
|
79
|
+
end
|
80
|
+
describe 'new' do
|
81
|
+
subject { file("spec/views/posts/new.html.erb_spec.rb") }
|
82
|
+
it { should_not exist }
|
83
|
+
end
|
84
|
+
describe 'show' do
|
85
|
+
subject { file("spec/views/posts/show.html.erb_spec.rb") }
|
86
|
+
it { should_not exist }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe 'routing specs' do
|
92
|
+
subject { file('spec/routing/posts_routing_spec.rb') }
|
93
|
+
describe 'generated by default' do
|
94
|
+
before do
|
95
|
+
run_generator %w(posts)
|
96
|
+
end
|
97
|
+
|
98
|
+
describe 'the spec' do
|
99
|
+
it { should exist }
|
100
|
+
it { should contain /require "spec_helper"/ }
|
101
|
+
it { should contain /describe PostsController/ }
|
102
|
+
it { should contain /describe "routing"/ }
|
103
|
+
end
|
104
|
+
end
|
105
|
+
describe 'skipped with a flag' do
|
106
|
+
before do
|
107
|
+
run_generator %w(posts --no-routing_specs)
|
108
|
+
end
|
109
|
+
it { should_not exist }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Generators are not automatically loaded by Rails
|
4
|
+
require 'generators/rspec/view/view_generator'
|
5
|
+
|
6
|
+
describe Rspec::Generators::ViewGenerator do
|
7
|
+
# Tell the generator where to put its output (what it thinks of as Rails.root)
|
8
|
+
destination File.expand_path("../../../../../tmp", __FILE__)
|
9
|
+
|
10
|
+
before { prepare_destination }
|
11
|
+
|
12
|
+
describe 'with default template engine' do
|
13
|
+
it 'generates a spec for the supplied action' do
|
14
|
+
run_generator %w(posts index)
|
15
|
+
file('spec/views/posts/index.html.erb_spec.rb').tap do |f|
|
16
|
+
f.should contain /require 'spec_helper'/
|
17
|
+
f.should contain /describe "posts\/index.html.erb"/
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'with a nested resource' do
|
22
|
+
it 'generates a spec for the supplied action' do
|
23
|
+
run_generator %w(admin/posts index)
|
24
|
+
file('spec/views/admin/posts/index.html.erb_spec.rb').tap do |f|
|
25
|
+
f.should contain /require 'spec_helper'/
|
26
|
+
f.should contain /describe "admin\/posts\/index.html.erb"/
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'haml' do
|
33
|
+
it 'generates a spec for the supplied action' do
|
34
|
+
run_generator %w(posts index --template_engine haml)
|
35
|
+
file('spec/views/posts/index.html.haml_spec.rb').tap do |f|
|
36
|
+
f.should contain /require 'spec_helper'/
|
37
|
+
f.should contain /describe "posts\/index.html.haml"/
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,5 +1,8 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
+
class ::ApplicationController
|
4
|
+
end
|
5
|
+
|
3
6
|
module RSpec::Rails
|
4
7
|
describe ControllerExampleGroup do
|
5
8
|
it { should be_included_in_files_in('./spec/controllers/') }
|
@@ -28,15 +31,15 @@ module RSpec::Rails
|
|
28
31
|
end
|
29
32
|
end
|
30
33
|
|
31
|
-
|
32
|
-
it "
|
34
|
+
context "with explicit subject" do
|
35
|
+
it "uses the specified subject instead of the controller" do
|
33
36
|
group.subject { 'explicit' }
|
34
37
|
example = group.new
|
35
38
|
example.subject.should == 'explicit'
|
36
39
|
end
|
37
40
|
end
|
38
41
|
|
39
|
-
describe "
|
42
|
+
describe "#controller" do
|
40
43
|
before do
|
41
44
|
group.class_eval do
|
42
45
|
controller(Class.new) { }
|
@@ -60,5 +63,38 @@ module RSpec::Rails
|
|
60
63
|
example.foos_url.should eq('http://test.host/foos')
|
61
64
|
end
|
62
65
|
end
|
66
|
+
|
67
|
+
describe "#bypass_rescue" do
|
68
|
+
it "overrides the rescue_with_handler method on the controller to raise submitted error" do
|
69
|
+
example = group.new
|
70
|
+
example.instance_variable_set("@controller", Class.new { def rescue_with_handler(e); end }.new)
|
71
|
+
example.bypass_rescue
|
72
|
+
expect do
|
73
|
+
example.controller.rescue_with_handler(RuntimeError.new("foo"))
|
74
|
+
end.to raise_error("foo")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "with inferred anonymous controller" do
|
79
|
+
before do
|
80
|
+
group.stub(:controller_class).and_return(Class.new)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "infers the anonymous controller class when infer_base_class_for_anonymous_controllers is true" do
|
84
|
+
RSpec.configuration.stub(:infer_base_class_for_anonymous_controllers?).and_return(true)
|
85
|
+
group.controller { }
|
86
|
+
|
87
|
+
controller_class = group.metadata[:example_group][:describes]
|
88
|
+
controller_class.superclass.should eq(group.controller_class)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "sets the anonymous controller class to ApplicationController when infer_base_class_for_anonymous_controllers is false" do
|
92
|
+
RSpec.configuration.stub(:infer_base_class_for_anonymous_controllers?).and_return(false)
|
93
|
+
group.controller { }
|
94
|
+
|
95
|
+
controller_class = group.metadata[:example_group][:describes]
|
96
|
+
controller_class.superclass.should eq(ApplicationController)
|
97
|
+
end
|
98
|
+
end
|
63
99
|
end
|
64
100
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "ActiveSupport::Relation =~ matcher" do
|
4
|
+
let!(:models) { Array.new(3) { MockableModel.create } }
|
5
|
+
|
6
|
+
it "verifies that the scope returns the records on the right hand side, regardless of order" do
|
7
|
+
MockableModel.scoped.should =~ models.reverse
|
8
|
+
end
|
9
|
+
|
10
|
+
it "fails if the scope encompasses more records than on the right hand side" do
|
11
|
+
another_model = MockableModel.create
|
12
|
+
|
13
|
+
MockableModel.scoped.should_not =~ models.reverse
|
14
|
+
end
|
15
|
+
|
16
|
+
it "fails if the scope encompasses fewer records than on the right hand side" do
|
17
|
+
MockableModel.limit(models.length - 1).should_not =~ models.reverse
|
18
|
+
end
|
19
|
+
end
|
@@ -5,22 +5,44 @@ describe "route_to" do
|
|
5
5
|
include RSpec::Rails::Matchers::RoutingMatchers::RouteHelpers
|
6
6
|
|
7
7
|
it "delegates to assert_recognizes" do
|
8
|
-
self.should_receive(:assert_recognizes).with({ "these" => "options" }, { :method=> :get, :path=>"path" })
|
8
|
+
self.should_receive(:assert_recognizes).with({ "these" => "options" }, { :method=> :get, :path=>"path" }, {})
|
9
9
|
{:get => "path"}.should route_to("these" => "options")
|
10
10
|
end
|
11
11
|
|
12
12
|
context "with shortcut syntax" do
|
13
13
|
|
14
14
|
it "routes with extra options" do
|
15
|
-
self.should_receive(:assert_recognizes).with({ :controller => "controller", :action => "action", :extra => "options"}, { :method=> :get, :path=>"path" })
|
15
|
+
self.should_receive(:assert_recognizes).with({ :controller => "controller", :action => "action", :extra => "options"}, { :method=> :get, :path=>"path" }, {})
|
16
16
|
get("path").should route_to("controller#action", :extra => "options")
|
17
17
|
end
|
18
18
|
|
19
19
|
it "routes without extra options" do
|
20
|
-
self.should_receive(:assert_recognizes).with(
|
20
|
+
self.should_receive(:assert_recognizes).with(
|
21
|
+
{:controller => "controller", :action => "action"},
|
22
|
+
{:method=> :get, :path=>"path" },
|
23
|
+
{}
|
24
|
+
)
|
21
25
|
get("path").should route_to("controller#action")
|
22
26
|
end
|
23
27
|
|
28
|
+
it "routes with one query parameter" do
|
29
|
+
self.should_receive(:assert_recognizes).with(
|
30
|
+
{:controller => "controller", :action => "action", :queryitem => "queryvalue"},
|
31
|
+
{:method=> :get, :path=>"path" },
|
32
|
+
{'queryitem' => 'queryvalue' }
|
33
|
+
)
|
34
|
+
get("path?queryitem=queryvalue").should route_to("controller#action", :queryitem => 'queryvalue')
|
35
|
+
end
|
36
|
+
|
37
|
+
it "routes with multiple query parameters" do
|
38
|
+
self.should_receive(:assert_recognizes).with(
|
39
|
+
{:controller => "controller", :action => "action", :queryitem => "queryvalue", :qi2 => 'qv2'},
|
40
|
+
{:method=> :get, :path=>"path"},
|
41
|
+
{'queryitem' => 'queryvalue', 'qi2' => 'qv2'}
|
42
|
+
)
|
43
|
+
get("path?queryitem=queryvalue&qi2=qv2").should route_to("controller#action", :queryitem => 'queryvalue', :qi2 => 'qv2')
|
44
|
+
end
|
45
|
+
|
24
46
|
end
|
25
47
|
|
26
48
|
context "with should" do
|