Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
dchelimsky committed Dec 20, 2011
1 parent 13b699f commit 1ccb17c
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion 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| -%>
Expand Down
2 changes: 1 addition & 1 deletion 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| -%>
Expand Down
2 changes: 1 addition & 1 deletion 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| -%>
Expand Down
2 changes: 1 addition & 1 deletion 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| -%>
Expand Down
2 changes: 1 addition & 1 deletion 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
8 changes: 4 additions & 4 deletions spec/generators/rspec/scaffold/scaffold_generator_spec.rb
Expand Up @@ -35,31 +35,31 @@
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

describe 'index' do
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

describe 'new' do
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

describe 'show' do
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
Expand Down
8 changes: 4 additions & 4 deletions spec/generators/rspec/view/view_generator_spec.rb
Expand Up @@ -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

Expand All @@ -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
Expand Down

2 comments on commit 1ccb17c

@petervandenabeele
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Please sign in to comment.