1

I'm writing a RoR app, and the automatically generated tests fail because of the following:

11) Sources GET /sources works! (now write some real specs)
     Failure/Error: get sources_path
     ActionView::MissingTemplate:
       Missing template sources/index, application/index with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in:
         * "/Users/brian.hicks/Dropbox/code/incremental/incremental/app/views"
         * "/Users/brian.hicks/.rvm/gems/ruby-1.9.3-p125@incremental/gems/devise-2.0.4/app/views"
     # ./app/controllers/sources_controller.rb:11:in `index'
     # ./spec/requests/sources_spec.rb:7:in `block (3 levels) in <top (required)>'

I'm using the following in my Gemfile:

gem 'rails', '3.2.3'
gem 'haml-rails', '>= 0.3.4'
gem 'rspec-rail', '>= 2.8.1'

Is there a specific config value I need to set somewhere to use the :haml handler as well as the rest of them?

By request, here's Gemfile.lock:

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (3.2.3)
      actionpack (= 3.2.3)
      mail (~> 2.4.4)
    actionpack (3.2.3)
      activemodel (= 3.2.3)
      activesupport (= 3.2.3)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.1)
      rack (~> 1.4.0)
      rack-cache (~> 1.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.1.2)
    activemodel (3.2.3)
      activesupport (= 3.2.3)
      builder (~> 3.0.0)
    activerecord (3.2.3)
      activemodel (= 3.2.3)
      activesupport (= 3.2.3)
      arel (~> 3.0.2)
      tzinfo (~> 0.3.29)
    activeresource (3.2.3)
      activemodel (= 3.2.3)
      activesupport (= 3.2.3)
    activesupport (3.2.3)
      i18n (~> 0.6)
      multi_json (~> 1.0)
    addressable (2.2.7)
    arel (3.0.2)
    bcrypt-ruby (3.0.1)
    bson (1.6.2)
    bson_ext (1.6.2)
      bson (~> 1.6.2)
    builder (3.0.0)
    cancan (1.6.7)
    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.1)
      ffi (~> 1.0.6)
    coffee-rails (3.2.2)
      coffee-script (>= 2.2.0)
      railties (~> 3.2.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.3.1)
    daemons (1.1.8)
    database_cleaner (0.7.2)
    devise (2.0.4)
      bcrypt-ruby (~> 3.0)
      orm_adapter (~> 0.0.3)
      railties (~> 3.1)
      warden (~> 1.1.1)
    diff-lcs (1.1.3)
    erubis (2.7.0)
    eventmachine (0.12.10)
    execjs (1.3.0)
      multi_json (~> 1.0)
    factory_girl (3.1.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (3.1.0)
      factory_girl (~> 3.1.0)
      railties (>= 3.0.0)
    ffi (1.0.11)
    haml (3.1.4)
    haml-rails (0.3.4)
      actionpack (~> 3.0)
      activesupport (~> 3.0)
      haml (~> 3.0)
      railties (~> 3.0)
    heroku (2.24.1)
      launchy (>= 0.3.2)
      netrc (~> 0.7.1)
      rest-client (~> 1.6.1)
      rubyzip
    hike (1.2.1)
    i18n (0.6.0)
    journey (1.0.3)
    jquery-rails (2.0.2)
      railties (>= 3.2.0, < 5.0)
      thor (~> 0.14)
    json (1.6.6)
    launchy (2.1.0)
      addressable (~> 2.2.6)
    libwebsocket (0.1.3)
      addressable
    mail (2.4.4)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.18)
    mongo (1.6.2)
      bson (~> 1.6.2)
    mongoid (2.4.8)
      activemodel (~> 3.1)
      mongo (~> 1.3)
      tzinfo (~> 0.3.22)
    mongoid-rspec (1.4.4)
      mongoid (~> 2.0)
      rspec (~> 2)
    multi_json (1.2.0)
    netrc (0.7.1)
    nokogiri (1.5.2)
    orm_adapter (0.0.7)
    polyglot (0.3.3)
    quiet_assets (1.0.0)
      rails (~> 3.1)
    rack (1.4.1)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-ssl (1.3.2)
      rack
    rack-test (0.6.1)
      rack (>= 1.0)
    rails (3.2.3)
      actionmailer (= 3.2.3)
      actionpack (= 3.2.3)
      activerecord (= 3.2.3)
      activeresource (= 3.2.3)
      activesupport (= 3.2.3)
      bundler (~> 1.0)
      railties (= 3.2.3)
    railties (3.2.3)
      actionpack (= 3.2.3)
      activesupport (= 3.2.3)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (~> 0.14.6)
    rake (0.9.2.2)
    rdoc (3.12)
      json (~> 1.4)
    rest-client (1.6.7)
      mime-types (>= 1.16)
    rspec (2.9.0)
      rspec-core (~> 2.9.0)
      rspec-expectations (~> 2.9.0)
      rspec-mocks (~> 2.9.0)
    rspec-core (2.9.0)
    rspec-expectations (2.9.1)
      diff-lcs (~> 1.1.3)
    rspec-mocks (2.9.0)
    rspec-rails (2.9.0)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec (~> 2.9.0)
    rubyzip (0.9.7)
    sass (3.1.15)
    sass-rails (3.2.5)
      railties (~> 3.2.0)
      sass (>= 3.1.10)
      tilt (~> 1.3)
    selenium-webdriver (2.21.0)
      childprocess (>= 0.2.5)
      ffi (~> 1.0)
      libwebsocket (~> 0.1.3)
      multi_json (~> 1.0)
      rubyzip
    simple_form (2.0.1)
      actionpack (~> 3.0)
      activemodel (~> 3.0)
    sprockets (2.1.2)
      hike (~> 1.2)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    thin (1.3.1)
      daemons (>= 1.0.9)
      eventmachine (>= 0.12.6)
      rack (>= 1.0.0)
    thor (0.14.6)
    tilt (1.3.3)
    treetop (1.4.10)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.33)
    uglifier (1.2.4)
      execjs (>= 0.3.0)
      multi_json (>= 1.0.2)
    warden (1.1.1)
      rack (>= 1.0)
    xpath (0.1.4)
      nokogiri (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  bson_ext (>= 1.3.1)
  cancan
  capybara (>= 1.1.2)
  coffee-rails (~> 3.2.1)
  database_cleaner (>= 0.7.1)
  devise (>= 2.0.0)
  factory_girl_rails (>= 1.6.0)
  haml-rails (>= 0.3.4)
  heroku
  jquery-rails
  launchy (>= 2.0.5)
  mongoid (>= 2.4.3)
  mongoid-rspec (>= 1.4.4)
  quiet_assets
  rails (= 3.2.3)
  rspec-rails (>= 2.8.1)
  sass-rails (~> 3.2.3)
  simple_form
  thin
  uglifier (>= 1.0.3)
4

1 回答 1

2

更新:我看到了一个类似的问题(我现在找不到:}),它建议添加文本

require "haml"

到 config/test.rb 设置,这对我有用。所以我不再需要在部分或布局等引用中指定模板处理程序,一切正常。

我在 Rails 3.2.2、Cucumber 1.10 和 rspec-rails 2.8.0 中遇到了同样的问题。

以下解决方法让我解决了这个问题:任何我引用基于 HAML 的部分的地方,我都使用模板的完全限定名称。例如,为了在我的站点的管理部分引用我的管理布局,我输入了“layout admin.html.haml”而不是“layout admin”。同样对于部分,我使用了我的 haml 文件的全名,而不仅仅是没有任何后缀的名称,这让 RSpec 和我的测试很开心,

现在,我不应该这样做,并且我意识到在模板名称中传递模板处理程序已(或将要)弃用在这里,但这确实解除了我的测试并在生产中工作,直到我找到正确的解决方案。

我以前从未在引用中指定模板处理程序,我猜这与我在创建网站后向我的网站添加 HAML 支持这一事实有关,但我还没有找到我的配置设置我猜我失踪了。

祝你好运!迈克尔

于 2012-04-26T19:45:29.020 回答