FAQ

[Rails] DEPRECATION WARNING: Passing a template handler in the template name is deprecated. (rspec + haml)

Peter Vandenabeele
Jan 15, 2012 at 9:56 pm
I upgraded a small project that I had created on 3.1.3 to 3.2.0.rc2.

Running rspec on it brings about a large amount of these messages:

DEPRECATION WARNING: Passing a template handler in the template name is
deprecated. You can simply remove the handler name or pass render :handlers
=> [:haml] instead. (called from block (2 levels) in <top (required)> at
/home/peterv/data/backed_up/projects/code/contact_app/spec/views/contacts/new.html.haml_spec.rb:12)
.


The offending code seems to be:

spec/views/contacts$ cat -n new.html.haml_spec.rb
1 require 'spec_helper'
2
3 describe "contacts/new.html.haml" do
4 before(:each) do
5 assign(:contact, stub_model(Contact,
6 :email => "MyString",
7 :person_id => 1
8 ).as_new_record)
9 end
10
11 it "renders new contact form" do
12 render ####### this render seems to trigger it
13
14 # Run the generator again with the --webrat flag if you want
to use webrat matchers
15 assert_select "form", :action => contacts_path, :method =>
"post" do
16 assert_select "input#contact_email", :name =>
"contact[email]"
17 assert_select "input#contact_person_id", :name =>
"contact[person_id]"
18 end
19 end
20 end

These are the view files (with .haml extensions)

app/views/contacts$ ls -l
total 20
-rw-rw-r-- 1 peterv peterv 100 2012-01-15 20:12 edit.html.haml
-rw-rw-r-- 1 peterv peterv 416 2012-01-15 20:12 _form.html.haml
-rw-rw-r-- 1 peterv peterv 404 2012-01-15 20:12 index.html.haml
-rw-rw-r-- 1 peterv peterv 66 2012-01-15 20:12 new.html.haml
-rw-rw-r-- 1 peterv peterv 171 2012-01-15 20:12 show.html.haml

app/views/contacts$ cat -n new.html.haml
1 %h1 New contact
2
3 = render 'form'
4
5 = link_to 'Back', contacts_path

I just did a bundle update a few hours ago. I show the Gemfile and
Gemfile.lock below.

I presume this is associated with this commit


https://github.com/rails/rails/commit/43d27e9105b385f64ec195f60d10ab3d64281bd4

Is there a way I can fix this myself? I do not really understand what the
problem
and the proposed solution is ...

Thanks,

Peter

##########################################
cat Gemfile
source 'http://rubygems.org'

gem 'rails', '3.2.0.rc2'

gem 'pg'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem 'bootstrap-sass'
end

gem 'jquery-rails'
gem 'therubyracer'
gem 'bcrypt-ruby'
gem 'haml-rails'
gem 'capistrano'

# tools for testing
gem "rspec-rails", :group => [:test, :development]


group :test do
gem "factory_girl_rails"
gem "capybara"
gem "guard-rspec"
gem 'spec_support'

# on Linux
gem 'rb-inotify' unless RUBY_PLATFORM.include?("x86_64-darwin")
gem 'libnotify' unless RUBY_PLATFORM.include?("x86_64-darwin")
end

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

########################################
cat Gemfile.lock
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.2.0.rc2)
actionpack (= 3.2.0.rc2)
mail (~> 2.3.0)
actionpack (3.2.0.rc2)
activemodel (= 3.2.0.rc2)
activesupport (= 3.2.0.rc2)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.0.rc1)
rack (~> 1.4.0)
rack-cache (~> 1.1)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
activemodel (3.2.0.rc2)
activesupport (= 3.2.0.rc2)
builder (~> 3.0.0)
activerecord (3.2.0.rc2)
activemodel (= 3.2.0.rc2)
activesupport (= 3.2.0.rc2)
arel (~> 3.0.0.rc1)
tzinfo (~> 0.3.29)
activeresource (3.2.0.rc2)
activemodel (= 3.2.0.rc2)
activesupport (= 3.2.0.rc2)
activesupport (3.2.0.rc2)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.0)
bcrypt-ruby (3.0.1)
bootstrap-sass (1.4.3)
sass-rails (~> 3.1)
builder (3.0.0)
capistrano (2.9.0)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
capybara (1.1.2)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
childprocess (0.3.0)
ffi (~> 1.0.6)
coffee-rails (3.2.1)
coffee-script (>= 2.2.0)
railties (~> 3.2.0.beta)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.2.0)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.2.13)
multi_json (~> 1.0)
factory_girl (2.4.0)
activesupport
factory_girl_rails (1.5.0)
factory_girl (~> 2.4.0)
railties (>= 3.0.0)
ffi (1.0.11)
guard (0.10.0)
ffi (>= 0.5.0)
thor (~> 0.14.6)
guard-rspec (0.6.0)
guard (>= 0.10.0)
haml (3.1.4)
haml-rails (0.3.4)
actionpack (~> 3.0)
activesupport (~> 3.0)
haml (~> 3.0)
railties (~> 3.0)
highline (1.6.9)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.0)
jquery-rails (2.0.0)
railties (>= 3.2.0.beta, < 5.0)
thor (~> 0.14)
json (1.6.5)
libnotify (0.7.1)
libv8 (3.3.10.4)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.0.4)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.0.5)
net-ssh (>= 2.0.9)
net-ssh (2.3.0)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
nokogiri (1.5.0)
pg (0.12.2)
polyglot (0.3.3)
rack (1.4.0)
rack-cache (1.1)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.0.rc2)
actionmailer (= 3.2.0.rc2)
actionpack (= 3.2.0.rc2)
activerecord (= 3.2.0.rc2)
activeresource (= 3.2.0.rc2)
activesupport (= 3.2.0.rc2)
bundler (~> 1.0)
railties (= 3.2.0.rc2)
railties (3.2.0.rc2)
actionpack (= 3.2.0.rc2)
activesupport (= 3.2.0.rc2)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rb-inotify (0.8.8)
ffi (>= 0.5.0)
rdoc (3.12)
json (~> 1.4)
rspec (2.8.0)
rspec-core (~> 2.8.0)
rspec-expectations (~> 2.8.0)
rspec-mocks (~> 2.8.0)
rspec-core (2.8.0)
rspec-expectations (2.8.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.8.0)
rspec-rails (2.8.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.8.0)
rubyzip (0.9.5)
sass (3.1.12)
sass-rails (3.2.3)
railties (~> 3.2.0.beta)
sass (>= 3.1.10)
tilt (~> 1.3)
selenium-webdriver (2.16.0)
childprocess (>= 0.2.5)
ffi (~> 1.0.9)
multi_json (~> 1.0.4)
rubyzip
spec_support (0.0.2)
rspec
sprockets (2.1.2)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
therubyracer (0.9.9)
libv8 (~> 3.3.10)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.31)
uglifier (1.2.2)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
xpath (0.1.4)
nokogiri (~> 1.3)

PLATFORMS
ruby

DEPENDENCIES
bcrypt-ruby
bootstrap-sass
capistrano
capybara
coffee-rails
factory_girl_rails
guard-rspec
haml-rails
jquery-rails
libnotify
pg
rails (= 3.2.0.rc2)
rb-inotify
rspec-rails
sass-rails
spec_support
therubyracer
uglifier










--
Peter Vandenabeele
http://twitter.com/peter_v
http://rails.vandenabeele.com
gsm: +32-478-27.40.69
e-mail: peter@vandenabeele.com

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
reply

Search Discussions

2 responses

  • Matt Jones at Jan 16, 2012 at 1:13 pm

    On Jan 15, 3:55 pm, Peter Vandenabeele wrote:
    I upgraded a small project that I had created on 3.1.3 to 3.2.0.rc2.

    Running rspec on it brings about a large amount of these messages:

    DEPRECATION WARNING: Passing a template handler in the template name is
    deprecated. You can simply remove the handler name or pass render :handlers
    => [:haml] instead. (called from block (2 levels) in <top (required)> at
    /home/peterv/data/backed_up/projects/code/contact_app/spec/views/contacts/n ew.html.haml_spec.rb:12)
    .

    The offending code seems to be:

    spec/views/contacts$ cat -n new.html.haml_spec.rb
    1    require 'spec_helper'
    2
    3    describe "contacts/new.html.haml" do
    Does it go away if you change this to "contacts/new.html"?

    --Matt Jones

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Peter Vandenabeele at Jan 16, 2012 at 10:41 pm
    On Mon, Jan 16, 2012 at 2:13 PM, Matt Jones wrote:
    On Jan 15, 3:55 pm, Peter Vandenabeele wrote:
    I upgraded a small project that I had created on 3.1.3 to 3.2.0.rc2.

    Running rspec on it brings about a large amount of these messages:

    DEPRECATION WARNING: Passing a template handler in the template name is
    deprecated. You can simply remove the handler name or pass render :handlers
    => [:haml] instead. (called from block (2 levels) in <top (required)> at
    /home/peterv/data/backed_up/projects/code/contact_app/spec/views/contacts/n
    ew.html.haml_spec.rb:12)
    .

    The offending code seems to be:

    spec/views/contacts$ cat -n new.html.haml_spec.rb
    1 require 'spec_helper'
    2
    3 describe "contacts/new.html.haml" do
    Does it go away if you change this to "contacts/new.html"?
    Thanks for the accurate reply :-)

    With the change you suggested, I still get a deprecation (but it already
    changed)

    $ rspec spec/views/contacts/new.html.haml_spec.rb
    DEPRECATION WARNING: Passing the format in the template name is deprecated.
    Please pass render with :formats => [:html] instead. (called from block (2
    levels) in <top (required)> at
    /home/peterv/data/backed_up/customers/DDS/contact_app/spec/views/contacts/new.html.haml_spec.rb:12)


    So, I went 1 step further, and moved to this:

    -describe "contacts/new.html.haml" do
    +describe "contacts/new" do

    And now the result is OK:

    contact_app$ rspec spec/views/contacts/new.html.haml_spec.rb
    .

    Finished in 0.18224 seconds
    1 example, 0 failures

    I assume it was clear that this is all "auto-generated" test code by rspec
    initializer (that was 2.7 if I see correctly).

    Now with rspec 2.8.x I added a new resource (foo), and I see that rspec
    does it the correct way:

    ...
    describe "foos/new" do
    ...

    So, I presume this also shows the way towards the solution.

    I now replaced all occurences of this {new|edit|index|show}.html.haml
    into {new|edit|index|show} and all the deprecations are gone and all
    tests remain green.

    This _is_ fixed in rspec 2.8 , I believe with this commit:


    https://github.com/rspec/rspec-rails/commit/1ccb17cfea27fe189c97cb88619b236e851b6fb9

    I presume other users that have autogenerated rspec scaffold
    tests will be hit by this? Anything can be done there (I asked the question
    as
    a comment on that patch on Github).

    Thanks again,

    Peter

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post

2 users in discussion

Peter Vandenabeele: 2 posts Matt Jones: 1 post