Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove handler and template engine from file names in generated view

specs.

- This eliminates deprecation warnings from rails 3.2, and still works
  with earlier 3.x versions.
  • Loading branch information...
commit 1ccb17cfea27fe189c97cb88619b236e851b6fb9 1 parent 13b699f
@dchelimsky dchelimsky authored
View
2  lib/generators/rspec/scaffold/templates/edit_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
-describe "<%= ns_table_name %>/edit.html.<%= options[:template_engine] %>" do
+describe "<%= ns_table_name %>/edit" do
before(:each) do
@<%= ns_file_name %> = assign(:<%= ns_file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? '))' : ',' %>
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
View
2  lib/generators/rspec/scaffold/templates/index_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
-describe "<%= ns_table_name %>/index.html.<%= options[:template_engine] %>" do
+describe "<%= ns_table_name %>/index" do
before(:each) do
assign(:<%= table_name %>, [
<% [1,2].each_with_index do |id, model_index| -%>
View
2  lib/generators/rspec/scaffold/templates/new_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
-describe "<%= ns_table_name %>/new.html.<%= options[:template_engine] %>" do
+describe "<%= ns_table_name %>/new" do
before(:each) do
assign(:<%= ns_file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? ').as_new_record)' : ',' %>
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
View
2  lib/generators/rspec/scaffold/templates/show_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
-describe "<%= ns_table_name %>/show.html.<%= options[:template_engine] %>" do
+describe "<%= ns_table_name %>/show" do
before(:each) do
@<%= ns_file_name %> = assign(:<%= ns_file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? '))' : ',' %>
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
View
2  lib/generators/rspec/view/templates/view_spec.rb
@@ -1,5 +1,5 @@
require 'spec_helper'
-describe "<%= file_path %>/<%= @action %>.html.<%= options[:template_engine] %>" do
+describe "<%= file_path %>/<%= @action %>" do
pending "add some examples to (or delete) #{__FILE__}"
end
View
8 spec/generators/rspec/scaffold/scaffold_generator_spec.rb
@@ -35,7 +35,7 @@
subject { file("spec/views/posts/edit.html.erb_spec.rb") }
it { should exist }
it { should contain /require 'spec_helper'/ }
- it { should contain /describe "(.*)\/edit.html.erb"/ }
+ it { should contain /describe "(.*)\/edit"/ }
it { should contain /it "renders the edit (.*) form"/ }
end
@@ -43,7 +43,7 @@
subject { file("spec/views/posts/index.html.erb_spec.rb") }
it { should exist }
it { should contain /require 'spec_helper'/ }
- it { should contain /describe "(.*)\/index.html.erb"/ }
+ it { should contain /describe "(.*)\/index"/ }
it { should contain /it "renders a list of (.*)"/ }
end
@@ -51,7 +51,7 @@
subject { file("spec/views/posts/new.html.erb_spec.rb") }
it { should exist }
it { should contain /require 'spec_helper'/ }
- it { should contain /describe "(.*)\/new.html.erb"/ }
+ it { should contain /describe "(.*)\/new"/ }
it { should contain /it "renders new (.*) form"/ }
end
@@ -59,7 +59,7 @@
subject { file("spec/views/posts/show.html.erb_spec.rb") }
it { should exist }
it { should contain /require 'spec_helper'/ }
- it { should contain /describe "(.*)\/show.html.erb"/ }
+ it { should contain /describe "(.*)\/show"/ }
it { should contain /it "renders attributes in <p>"/ }
end
end
View
8 spec/generators/rspec/view/view_generator_spec.rb
@@ -14,7 +14,7 @@
run_generator %w(posts index)
file('spec/views/posts/index.html.erb_spec.rb').tap do |f|
f.should contain /require 'spec_helper'/
- f.should contain /describe "posts\/index.html.erb"/
+ f.should contain /describe "posts\/index"/
end
end
@@ -23,18 +23,18 @@
run_generator %w(admin/posts index)
file('spec/views/admin/posts/index.html.erb_spec.rb').tap do |f|
f.should contain /require 'spec_helper'/
- f.should contain /describe "admin\/posts\/index.html.erb"/
+ f.should contain /describe "admin\/posts\/index"/
end
end
end
end
- describe 'haml' do
+ describe 'with a specified template engine' do
it 'generates a spec for the supplied action' do
run_generator %w(posts index --template_engine haml)
file('spec/views/posts/index.html.haml_spec.rb').tap do |f|
f.should contain /require 'spec_helper'/
- f.should contain /describe "posts\/index.html.haml"/
+ f.should contain /describe "posts\/index"/
end
end
end

2 comments on commit 1ccb17c

@petervandenabeele

I just upgraded an "older" Rails 3.1.3 project on which I had scaffold view tests generated with
rspec-rails 2.7. They now generated a large amount of deprecations. I was able to remove them
manually, thanks to help on the Ruby on Rails mailing list.

Is there a documentation patch we can apply somewhere to explain the problem and the solution
to rspec-rails users?

@dchelimsky
Owner

Please post this as a documentation bug to https://github.com/rspec/rspec-rails/issues. Thx.

Please sign in to comment.
Something went wrong with that request. Please try again.