HAML Integration with RSPEC

I had 11 or so Rspec tests working until I turned my project into HAML. Then, when I did the tests, I got errors like:

ActionView::MissingTemplate: Missing template pages/home with {:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml], :formats=>[:html], :locale=>[:en, :en]} in view paths "/Users/myhomedirectory/my_app/app/views" /Users/myhomedirectory/.rvm/gems/ ruby-1.9.2-p180@global /gems/actionpack-3.0.6/lib/action_view/paths.rb:15:in `find' /Users/myhomedirectory/.rvm/gems/ ruby-1.9.2-p180@global /gems/actionpack-3.0.6/lib/action_view/lookup_context.rb:81:in `find' 

45 minutes after posting my original question, I solved my problem by adding the following lines to the /config/application.rb file:

 config.generators do |g| g.template_engine :haml end 

I got it exhausted due to a semi-related blog entry , but I wonder how anyone can know this? It is not documented in HAML as far as I can tell, so I have to wonder if I did something wrong when I installed it. I can’t imagine that everyone who used HAML should go through all this ...

+4
source share
2 answers

I could not figure out how to add a comment to the original question (as RobZolkos and Dave did above), and therefore, using this section "Answer".

I ran into the same problem when I renamed empty erb to haml and ran tests. However, in my case, the problem was "gem haml" was missing in the Gemfile. By adding this, followed by the installation of "bundle install", I solved the problem. Just a thought will be posted here, as it may be useful for someone. I did not have to add the material "g.template_engine: haml" as Dave should have.

+2
source

I just had the same problem when RSpec did not find action view patterns written in haml. Then I realized that the test environment does not consider haml as a rendering mechanism:

Missing template pages/home with {:handlers=>[:erb, :rjs ...

So, I will fix this by adding the haml-rails stone to the test group.

So, if you have the same problem, I recommend:

 group :development, :test do gem 'rspec-rails' ... gem 'haml-rails' end 
+2
source

Source: https://habr.com/ru/post/1347863/


All Articles