1

RoR アプリを作成していますが、自動生成されたテストは次の理由で失敗します。

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)>'

Gemfile で以下を使用しています。

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

ハンドラーとその他のハンドラーを使用するためにどこかに設定する必要がある特定の構成値はあり:hamlますか?

リクエストに応じて、次の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」ではなく「layout admin.html.haml」と入力しました。同様に、パーシャルについては、サフィックスのない名前だけではなく、haml ファイルの完全な名前を使用しました。これにより、RSpec と私のテストが満足のいくものになりました。

今、私はこれを行う必要はありません。テンプレート名でテンプレート ハンドラーを渡すことは、hereごとに非推奨である (または非推奨になる予定である) ことを認識していますが、これによりテストのブロックが解除され、正しいものが見つかるまで実稼働環境で動作します。解決。

これまで参照でテンプレート ハンドラーを指定する必要はありませんでした。サイトの作成後に HAML サポートをサイトに追加したという事実と関係があると思いますが、設定した構成設定が見つかりませんでした。私が行方不明だと思います。

幸運を!マイケル

于 2012-04-26T19:45:29.020 に答える