rspec-rails 2.5.0 → 2.6.0.rc2

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.
Files changed (70) hide show
  1. data/.gitignore +9 -4
  2. data/.travis.yml +11 -0
  3. data/README_DEV.md +43 -0
  4. data/Rakefile +54 -27
  5. data/Thorfile +6 -21
  6. data/features/Autotest.md +7 -0
  7. data/features/Changelog.md +17 -2
  8. data/features/Upgrade.md +13 -12
  9. data/features/controller_specs/README.md +18 -10
  10. data/features/controller_specs/anonymous_controller.feature +5 -5
  11. data/features/controller_specs/controller_spec.feature +1 -1
  12. data/features/controller_specs/isolation_from_views.feature +2 -2
  13. data/features/controller_specs/render_views.feature +3 -3
  14. data/features/helper_specs/helper_spec.feature +3 -3
  15. data/features/mailer_specs/url_helpers.feature +2 -2
  16. data/features/matchers/new_record_matcher.feature +2 -2
  17. data/features/matchers/redirect_to_matcher.feature +1 -1
  18. data/features/matchers/render_template_matcher.feature +1 -1
  19. data/features/mocks/mock_model.feature +21 -5
  20. data/features/mocks/stub_model.feature +2 -2
  21. data/features/model_specs/errors_on.feature +1 -1
  22. data/features/model_specs/transactional_examples.feature +10 -5
  23. data/features/routing_specs/README.md +2 -1
  24. data/features/routing_specs/be_routable_matcher.feature +5 -5
  25. data/features/routing_specs/named_routes.feature +1 -1
  26. data/features/routing_specs/route_to_matcher.feature +28 -8
  27. data/features/step_definitions/additional_cli_steps.rb +1 -1
  28. data/features/support/env.rb +7 -18
  29. data/features/view_specs/inferred_controller_path.feature +3 -3
  30. data/features/view_specs/stub_template.feature +2 -2
  31. data/features/view_specs/view_spec.feature +8 -8
  32. data/gemfiles/base.rb +45 -0
  33. data/gemfiles/rails-3-0-stable +7 -0
  34. data/gemfiles/rails-3.0.0 +5 -0
  35. data/gemfiles/rails-3.0.1 +5 -0
  36. data/gemfiles/rails-3.0.2 +5 -0
  37. data/gemfiles/rails-3.0.3 +5 -0
  38. data/gemfiles/rails-3.0.4 +5 -0
  39. data/gemfiles/rails-3.0.5 +5 -0
  40. data/gemfiles/rails-3.0.6 +5 -0
  41. data/gemfiles/rails-master +7 -0
  42. data/lib/generators/rspec/scaffold/scaffold_generator.rb +20 -2
  43. data/lib/generators/rspec/scaffold/templates/controller_spec.rb +23 -23
  44. data/lib/generators/rspec/scaffold/templates/edit_spec.rb +7 -7
  45. data/lib/generators/rspec/scaffold/templates/index_spec.rb +2 -2
  46. data/lib/generators/rspec/scaffold/templates/new_spec.rb +5 -5
  47. data/lib/generators/rspec/scaffold/templates/routing_spec.rb +14 -14
  48. data/lib/generators/rspec/scaffold/templates/show_spec.rb +2 -2
  49. data/lib/rspec/rails/example/controller_example_group.rb +9 -1
  50. data/lib/rspec/rails/example/routing_example_group.rb +1 -0
  51. data/lib/rspec/rails/matchers/routing_matchers.rb +23 -2
  52. data/lib/rspec/rails/mocks.rb +3 -0
  53. data/lib/rspec/rails/tasks/rspec.rake +1 -1
  54. data/lib/rspec/rails/version.rb +1 -1
  55. data/rspec-rails.gemspec +5 -36
  56. data/spec/autotest/rails_rspec2_spec.rb +2 -7
  57. data/spec/rspec/rails/example/controller_example_group_spec.rb +25 -0
  58. data/spec/rspec/rails/matchers/route_to_spec.rb +15 -0
  59. data/spec/rspec/rails/mocks/ar_classes.rb +5 -2
  60. data/spec/rspec/rails/view_rendering_spec.rb +0 -6
  61. data/templates/generate_stuff.rb +2 -1
  62. data/templates/run_specs.rb +2 -2
  63. metadata +54 -77
  64. data/Gemfile-3-0-stable +0 -6
  65. data/Gemfile-3.0.0 +0 -3
  66. data/Gemfile-3.0.3 +0 -3
  67. data/Gemfile-base +0 -38
  68. data/Gemfile-master +0 -5
  69. data/specs.watchr +0 -59
  70. data/templates/Gemfile-base +0 -17
@@ -0,0 +1,45 @@
1
+ module GemfileBase
2
+ def self.extended(host)
3
+ host.instance_eval do
4
+ source "http://rubygems.org"
5
+
6
+ %w[rspec rspec-core rspec-expectations rspec-mocks rspec-rails].each do |lib|
7
+ library_path = File.expand_path("../../../#{lib}", __FILE__)
8
+ if File.exist?(library_path)
9
+ gem lib, :path => library_path
10
+ elsif ENV["USE_GIT_REPOS"] == 'true'
11
+ gem lib, :git => "git://github.com/rspec/#{lib}.git"
12
+ else
13
+ gem lib
14
+ end
15
+ end
16
+
17
+ gem 'sqlite3-ruby', :require => 'sqlite3'
18
+ # gem "cucumber", "~> 0.10.2"
19
+ # gem "aruba", :git => "git://github.com/aslakhellesoy/aruba"
20
+ gem "rcov", "0.9.9"
21
+ gem "relish", "0.2.0"
22
+ gem "guard-rspec", "0.1.9"
23
+ gem "growl", "1.0.3"
24
+ gem "ZenTest", "~> 4.4.2"
25
+ gem "webrat", "0.7.2"
26
+
27
+ if RUBY_PLATFORM =~ /darwin/
28
+ gem "autotest-fsevent", "~> 0.2.4"
29
+ gem "autotest-growl", "~> 0.2.9"
30
+ end
31
+
32
+ gem "ruby-debug", :platforms => :ruby_18
33
+ gem "ruby-debug19", "~> 0.11.6", :platforms => :ruby_19
34
+
35
+ platforms :ruby_18, :ruby_19 do
36
+ gem "rb-fsevent", "~> 0.3.9"
37
+ gem "ruby-prof", "~> 0.9.2"
38
+ end
39
+
40
+ platforms :jruby do
41
+ gem "jruby-openssl"
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path("../base.rb", __FILE__)
2
+
3
+ extend GemfileBase
4
+
5
+ gem "rails", :git => "git://github.com/rails/rails.git", :branch => "3-0-stable"
6
+ gem "arel", :git => "git://github.com/rails/arel.git", :branch => "2-0-stable"
7
+ gem "rack", :git => "git://github.com/rack/rack.git"
@@ -0,0 +1,5 @@
1
+ require File.expand_path("../base.rb", __FILE__)
2
+
3
+ extend GemfileBase
4
+
5
+ gem "rails", "3.0.0"
@@ -0,0 +1,5 @@
1
+ require File.expand_path("../base.rb", __FILE__)
2
+
3
+ extend GemfileBase
4
+
5
+ gem "rails", "3.0.1"
@@ -0,0 +1,5 @@
1
+ require File.expand_path("../base.rb", __FILE__)
2
+
3
+ extend GemfileBase
4
+
5
+ gem "rails", "3.0.2"
@@ -0,0 +1,5 @@
1
+ require File.expand_path("../base.rb", __FILE__)
2
+
3
+ extend GemfileBase
4
+
5
+ gem "rails", "3.0.3"
@@ -0,0 +1,5 @@
1
+ require File.expand_path("../base.rb", __FILE__)
2
+
3
+ extend GemfileBase
4
+
5
+ gem "rails", "3.0.4"
@@ -0,0 +1,5 @@
1
+ require File.expand_path("../base.rb", __FILE__)
2
+
3
+ extend GemfileBase
4
+
5
+ gem "rails", "3.0.5"
@@ -0,0 +1,5 @@
1
+ require File.expand_path("../base.rb", __FILE__)
2
+
3
+ extend GemfileBase
4
+
5
+ gem "rails", "3.0.6"
@@ -0,0 +1,7 @@
1
+ require File.expand_path("../base.rb", __FILE__)
2
+
3
+ extend GemfileBase
4
+
5
+ gem "rails", :git => "git://github.com/rails/rails.git"
6
+ gem "arel", :git => "git://github.com/rails/arel.git"
7
+ gem "rack", :git => "git://github.com/rack/rack.git"
@@ -65,6 +65,24 @@ module Rspec
65
65
  "{'these' => 'params'}"
66
66
  end
67
67
 
68
+ # support for namespaced-resources
69
+ def ns_file_name
70
+ if ARGV[0].match(/(\w+)\/(\w+)/)
71
+ "#{$1.underscore}_#{$2.singularize.underscore}"
72
+ else
73
+ file_name
74
+ end
75
+ end
76
+
77
+ # support for namespaced-resources
78
+ def ns_table_name
79
+ if ARGV[0].match(/(\w+)\/(\w+)/)
80
+ "#{$1.underscore}/#{$2.tableize}"
81
+ else
82
+ table_name
83
+ end
84
+ end
85
+
68
86
  # Returns the name of the mock. For example, if the file name is user,
69
87
  # it returns mock_user.
70
88
  #
@@ -81,9 +99,9 @@ module Rspec
81
99
  if hash
82
100
  method, and_return = hash.to_a.first
83
101
  method = orm_instance.send(method).split('.').last.gsub(/\(.*?\)/, '')
84
- "mock_#{file_name}(:#{method} => #{and_return})"
102
+ "mock_#{ns_file_name}(:#{method} => #{and_return})"
85
103
  else
86
- "mock_#{file_name}"
104
+ "mock_#{ns_file_name}"
87
105
  end
88
106
  end
89
107
 
@@ -21,54 +21,54 @@ describe <%= controller_class_name %>Controller do
21
21
 
22
22
  <% end -%>
23
23
  describe "GET show" do
24
- it "assigns the requested <%= file_name %> as @<%= file_name %>" do
24
+ it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
25
25
  <%= stub orm_class.find(class_name, "37".inspect) %> { <%= mock_file_name %> }
26
26
  get :show, :id => "37"
27
- assigns(:<%= file_name %>).should be(<%= mock_file_name %>)
27
+ assigns(:<%= ns_file_name %>).should be(<%= mock_file_name %>)
28
28
  end
29
29
  end
30
30
 
31
31
  describe "GET new" do
32
- it "assigns a new <%= file_name %> as @<%= file_name %>" do
32
+ it "assigns a new <%= ns_file_name %> as @<%= ns_file_name %>" do
33
33
  <%= stub orm_class.build(class_name) %> { <%= mock_file_name %> }
34
34
  get :new
35
- assigns(:<%= file_name %>).should be(<%= mock_file_name %>)
35
+ assigns(:<%= ns_file_name %>).should be(<%= mock_file_name %>)
36
36
  end
37
37
  end
38
38
 
39
39
  describe "GET edit" do
40
- it "assigns the requested <%= file_name %> as @<%= file_name %>" do
40
+ it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
41
41
  <%= stub orm_class.find(class_name, "37".inspect) %> { <%= mock_file_name %> }
42
42
  get :edit, :id => "37"
43
- assigns(:<%= file_name %>).should be(<%= mock_file_name %>)
43
+ assigns(:<%= ns_file_name %>).should be(<%= mock_file_name %>)
44
44
  end
45
45
  end
46
46
 
47
47
  describe "POST create" do
48
48
  describe "with valid params" do
49
- it "assigns a newly created <%= file_name %> as @<%= file_name %>" do
49
+ it "assigns a newly created <%= ns_file_name %> as @<%= ns_file_name %>" do
50
50
  <%= stub orm_class.build(class_name, params) %> { <%= mock_file_name(:save => true) %> }
51
- post :create, :<%= file_name %> => <%= params %>
52
- assigns(:<%= file_name %>).should be(<%= mock_file_name %>)
51
+ post :create, :<%= ns_file_name %> => <%= params %>
52
+ assigns(:<%= ns_file_name %>).should be(<%= mock_file_name %>)
53
53
  end
54
54
 
55
- it "redirects to the created <%= file_name %>" do
55
+ it "redirects to the created <%= ns_file_name %>" do
56
56
  <%= stub orm_class.build(class_name) %> { <%= mock_file_name(:save => true) %> }
57
- post :create, :<%= file_name %> => {}
57
+ post :create, :<%= ns_file_name %> => {}
58
58
  response.should redirect_to(<%= table_name.singularize %>_url(<%= mock_file_name %>))
59
59
  end
60
60
  end
61
61
 
62
62
  describe "with invalid params" do
63
- it "assigns a newly created but unsaved <%= file_name %> as @<%= file_name %>" do
63
+ it "assigns a newly created but unsaved <%= ns_file_name %> as @<%= ns_file_name %>" do
64
64
  <%= stub orm_class.build(class_name, params) %> { <%= mock_file_name(:save => false) %> }
65
- post :create, :<%= file_name %> => <%= params %>
66
- assigns(:<%= file_name %>).should be(<%= mock_file_name %>)
65
+ post :create, :<%= ns_file_name %> => <%= params %>
66
+ assigns(:<%= ns_file_name %>).should be(<%= mock_file_name %>)
67
67
  end
68
68
 
69
69
  it "re-renders the 'new' template" do
70
70
  <%= stub orm_class.build(class_name) %> { <%= mock_file_name(:save => false) %> }
71
- post :create, :<%= file_name %> => {}
71
+ post :create, :<%= ns_file_name %> => {}
72
72
  response.should render_template("new")
73
73
  end
74
74
  end
@@ -76,19 +76,19 @@ describe <%= controller_class_name %>Controller do
76
76
 
77
77
  describe "PUT update" do
78
78
  describe "with valid params" do
79
- it "updates the requested <%= file_name %>" do
79
+ it "updates the requested <%= ns_file_name %>" do
80
80
  <%= stub orm_class.find(class_name, "37".inspect) %> { <%= mock_file_name %> }
81
81
  mock_<%= should_receive orm_instance.update_attributes(params) %>
82
- put :update, :id => "37", :<%= file_name %> => <%= params %>
82
+ put :update, :id => "37", :<%= ns_file_name %> => <%= params %>
83
83
  end
84
84
 
85
- it "assigns the requested <%= file_name %> as @<%= file_name %>" do
85
+ it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
86
86
  <%= stub orm_class.find(class_name) %> { <%= mock_file_name(:update_attributes => true) %> }
87
87
  put :update, :id => "1"
88
- assigns(:<%= file_name %>).should be(<%= mock_file_name %>)
88
+ assigns(:<%= ns_file_name %>).should be(<%= mock_file_name %>)
89
89
  end
90
90
 
91
- it "redirects to the <%= file_name %>" do
91
+ it "redirects to the <%= ns_file_name %>" do
92
92
  <%= stub orm_class.find(class_name) %> { <%= mock_file_name(:update_attributes => true) %> }
93
93
  put :update, :id => "1"
94
94
  response.should redirect_to(<%= table_name.singularize %>_url(<%= mock_file_name %>))
@@ -96,10 +96,10 @@ describe <%= controller_class_name %>Controller do
96
96
  end
97
97
 
98
98
  describe "with invalid params" do
99
- it "assigns the <%= file_name %> as @<%= file_name %>" do
99
+ it "assigns the <%= ns_file_name %> as @<%= ns_file_name %>" do
100
100
  <%= stub orm_class.find(class_name) %> { <%= mock_file_name(:update_attributes => false) %> }
101
101
  put :update, :id => "1"
102
- assigns(:<%= file_name %>).should be(<%= mock_file_name %>)
102
+ assigns(:<%= ns_file_name %>).should be(<%= mock_file_name %>)
103
103
  end
104
104
 
105
105
  it "re-renders the 'edit' template" do
@@ -111,7 +111,7 @@ describe <%= controller_class_name %>Controller do
111
111
  end
112
112
 
113
113
  describe "DELETE destroy" do
114
- it "destroys the requested <%= file_name %>" do
114
+ it "destroys the requested <%= ns_file_name %>" do
115
115
  <%= stub orm_class.find(class_name, "37".inspect) %> { <%= mock_file_name %> }
116
116
  mock_<%= should_receive orm_instance.destroy %>
117
117
  delete :destroy, :id => "37"
@@ -1,29 +1,29 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
- describe "<%= table_name %>/edit.html.<%= options[:template_engine] %>" do
4
+ describe "<%= ns_table_name %>/edit.html.<%= options[:template_engine] %>" do
5
5
  before(:each) do
6
- @<%= file_name %> = assign(:<%= file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? '))' : ',' %>
6
+ @<%= ns_file_name %> = assign(:<%= ns_file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? '))' : ',' %>
7
7
  <% output_attributes.each_with_index do |attribute, attribute_index| -%>
8
8
  :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
9
9
  <% end -%>
10
10
  <%= output_attributes.empty? ? "" : " ))\n" -%>
11
11
  end
12
12
 
13
- it "renders the edit <%= file_name %> form" do
13
+ it "renders the edit <%= ns_file_name %> form" do
14
14
  render
15
15
 
16
16
  <% if webrat? -%>
17
- rendered.should have_selector("form", :action => <%= file_name %>_path(@<%= file_name %>), :method => "post") do |form|
17
+ rendered.should have_selector("form", :action => <%= ns_file_name %>_path(@<%= ns_file_name %>), :method => "post") do |form|
18
18
  <% for attribute in output_attributes -%>
19
- form.should have_selector("<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>", :name => "<%= file_name %>[<%= attribute.name %>]")
19
+ form.should have_selector("<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]")
20
20
  <% end -%>
21
21
  end
22
22
  <% else -%>
23
23
  # Run the generator again with the --webrat flag if you want to use webrat matchers
24
- assert_select "form", :action => <%= index_helper %>_path(@<%= file_name %>), :method => "post" do
24
+ assert_select "form", :action => <%= index_helper %>_path(@<%= ns_file_name %>), :method => "post" do
25
25
  <% for attribute in output_attributes -%>
26
- assert_select "<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>", :name => "<%= file_name %>[<%= attribute.name %>]"
26
+ assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]"
27
27
  <% end -%>
28
28
  end
29
29
  <% end -%>
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
- describe "<%= table_name %>/index.html.<%= options[:template_engine] %>" do
4
+ describe "<%= ns_table_name %>/index.html.<%= options[:template_engine] %>" do
5
5
  before(:each) do
6
6
  assign(:<%= table_name %>, [
7
7
  <% [1,2].each_with_index do |id, model_index| -%>
@@ -16,7 +16,7 @@ describe "<%= table_name %>/index.html.<%= options[:template_engine] %>" do
16
16
  ])
17
17
  end
18
18
 
19
- it "renders a list of <%= table_name %>" do
19
+ it "renders a list of <%= ns_table_name %>" do
20
20
  render
21
21
  <% for attribute in output_attributes -%>
22
22
  <% if webrat? -%>
@@ -1,28 +1,28 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
- describe "<%= table_name %>/new.html.<%= options[:template_engine] %>" do
4
+ describe "<%= ns_table_name %>/new.html.<%= options[:template_engine] %>" do
5
5
  before(:each) do
6
- assign(:<%= file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? ').as_new_record)' : ',' %>
6
+ assign(:<%= ns_file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? ').as_new_record)' : ',' %>
7
7
  <% output_attributes.each_with_index do |attribute, attribute_index| -%>
8
8
  :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
9
9
  <% end -%>
10
10
  <%= !output_attributes.empty? ? " ).as_new_record)\n end" : " end" %>
11
11
 
12
- it "renders new <%= file_name %> form" do
12
+ it "renders new <%= ns_file_name %> form" do
13
13
  render
14
14
 
15
15
  <% if webrat? -%>
16
16
  rendered.should have_selector("form", :action => <%= table_name %>_path, :method => "post") do |form|
17
17
  <% for attribute in output_attributes -%>
18
- form.should have_selector("<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>", :name => "<%= file_name %>[<%= attribute.name %>]")
18
+ form.should have_selector("<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]")
19
19
  <% end -%>
20
20
  end
21
21
  <% else -%>
22
22
  # Run the generator again with the --webrat flag if you want to use webrat matchers
23
23
  assert_select "form", :action => <%= index_helper %>_path, :method => "post" do
24
24
  <% for attribute in output_attributes -%>
25
- assert_select "<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>", :name => "<%= file_name %>[<%= attribute.name %>]"
25
+ assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]"
26
26
  <% end -%>
27
27
  end
28
28
  <% end -%>
@@ -4,33 +4,33 @@ describe <%= controller_class_name %>Controller do
4
4
  describe "routing" do
5
5
 
6
6
  <% unless options[:singleton] -%>
7
- it "recognizes and generates #index" do
8
- { :get => "/<%= table_name %>" }.should route_to(:controller => "<%= table_name %>", :action => "index")
7
+ it "routes to #index" do
8
+ get("/<%= ns_table_name %>").should route_to("<%= ns_table_name %>#index")
9
9
  end
10
10
 
11
11
  <% end -%>
12
- it "recognizes and generates #new" do
13
- { :get => "/<%= table_name %>/new" }.should route_to(:controller => "<%= table_name %>", :action => "new")
12
+ it "routes to #new" do
13
+ get("/<%= ns_table_name %>/new").should route_to("<%= ns_table_name %>#new")
14
14
  end
15
15
 
16
- it "recognizes and generates #show" do
17
- { :get => "/<%= table_name %>/1" }.should route_to(:controller => "<%= table_name %>", :action => "show", :id => "1")
16
+ it "routes to #show" do
17
+ get("/<%= ns_table_name %>/1").should route_to("<%= ns_table_name %>#show", :id => "1")
18
18
  end
19
19
 
20
- it "recognizes and generates #edit" do
21
- { :get => "/<%= table_name %>/1/edit" }.should route_to(:controller => "<%= table_name %>", :action => "edit", :id => "1")
20
+ it "routes to #edit" do
21
+ get("/<%= ns_table_name %>/1/edit").should route_to("<%= ns_table_name %>#edit", :id => "1")
22
22
  end
23
23
 
24
- it "recognizes and generates #create" do
25
- { :post => "/<%= table_name %>" }.should route_to(:controller => "<%= table_name %>", :action => "create")
24
+ it "routes to #create" do
25
+ post("/<%= ns_table_name %>").should route_to("<%= ns_table_name %>#create")
26
26
  end
27
27
 
28
- it "recognizes and generates #update" do
29
- { :put => "/<%= table_name %>/1" }.should route_to(:controller => "<%= table_name %>", :action => "update", :id => "1")
28
+ it "routes to #update" do
29
+ put("/<%= ns_table_name %>/1").should route_to("<%= ns_table_name %>#update", :id => "1")
30
30
  end
31
31
 
32
- it "recognizes and generates #destroy" do
33
- { :delete => "/<%= table_name %>/1" }.should route_to(:controller => "<%= table_name %>", :action => "destroy", :id => "1")
32
+ it "routes to #destroy" do
33
+ delete("/<%= ns_table_name %>/1").should route_to("<%= ns_table_name %>#destroy", :id => "1")
34
34
  end
35
35
 
36
36
  end
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
- describe "<%= table_name %>/show.html.<%= options[:template_engine] %>" do
4
+ describe "<%= ns_table_name %>/show.html.<%= options[:template_engine] %>" do
5
5
  before(:each) do
6
- @<%= file_name %> = assign(:<%= file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? '))' : ',' %>
6
+ @<%= ns_file_name %> = assign(:<%= ns_file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? '))' : ',' %>
7
7
  <% output_attributes.each_with_index do |attribute, attribute_index| -%>
8
8
  :<%= attribute.name %> => <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
9
9
  <% end -%>
@@ -148,13 +148,21 @@ module RSpec::Rails
148
148
  end
149
149
 
150
150
  after do
151
- @routes = @orig_routes
151
+ @routes, @orig_routes = @orig_routes, nil
152
152
  end
153
153
  end
154
154
  end
155
155
 
156
156
  module InstanceMethods
157
157
  attr_reader :controller, :routes
158
+
159
+ def method_missing(method, *args, &block)
160
+ if @orig_routes && @orig_routes.named_routes.helpers.include?(method)
161
+ controller.send(method, *args, &block)
162
+ else
163
+ super
164
+ end
165
+ end
158
166
  end
159
167
 
160
168
  included do
@@ -6,6 +6,7 @@ module RSpec::Rails
6
6
  include RSpec::Rails::RailsExampleGroup
7
7
  include ActionDispatch::Assertions::RoutingAssertions
8
8
  include RSpec::Rails::Matchers::RoutingMatchers
9
+ include RSpec::Rails::Matchers::RoutingMatchers::RouteHelpers
9
10
 
10
11
  module InstanceMethods
11
12
  attr_reader :routes