0

の実行中にこれらのエラーが発生しますrspec spec/。失敗しているスペックは、スキャフォールディングで自動生成されたものです。RSpec を理解しようとしていますが、メソッドが欠落しているように感じる以外に、どこから原因を探し始めればよいかわかりませ? ! ? それでも、アプリは正常に動作しているようです。これらの障害については、 には何も表示されません。これを追跡するためのヒントを探す必要がある別の場所はありますか?test.log

$ rspec spec/
.....................F.F.

Failures:

  1) clowns/edit.html.haml renders the edit clown form
     Failure/Error: render
     undefined method `to_sym' for nil:NilClass
     # ./app/views/clowns/_form.html.haml:4:in `block in _app_views_clowns__form_html_haml__3590088286240866241_2176114460_3896491916910336970'
     # ./app/views/clowns/_form.html.haml:1:in `_app_views_clowns__form_html_haml__3590088286240866241_2176114460_3896491916910336970'
     # ./app/views/clowns/edit.html.haml:3:in `_app_views_clowns_edit_html_haml___574620942879655923_2176081980_599706797287605391'
     # ./spec/views/clowns/edit.html.haml_spec.rb:13:in `block (2 levels) in <top (required)>'

  2) clowns/new.html.haml renders new clown form
     Failure/Error: render
     undefined method `to_sym' for nil:NilClass
     # ./app/views/clowns/_form.html.haml:4:in `block in _app_views_clowns__form_html_haml__3590088286240866241_2176114460_3896491916910336970'
     # ./app/views/clowns/_form.html.haml:1:in `_app_views_clowns__form_html_haml__3590088286240866241_2176114460_3896491916910336970'
     # ./app/views/clowns/new.html.haml:3:in `_app_views_clowns_new_html_haml__1085372210838170129_2159651900_599706797287605391'
     # ./spec/views/clowns/new.html.haml_spec.rb:12:in `block (2 levels) in <top (required)>'

Finished in 1.03 seconds
27 examples, 2 failures, 2 pending

そして、これが明らかに失敗する仕様です ( edit.html.haml_spec.rb)。によって自動生成されましたrails g scaffold Clown name:string balloons:integer:

#spec/views/clowns/edit.html.haml_spec.rb
require 'spec_helper'

describe "clowns/edit.html.haml" do
  before(:each) do
    @clown = assign(:clown, stub_model(Clown,
      :name => "MyString",
      :balloons => 1
    ))
  end

  it "renders the edit clown form" do
    render

    # Run the generator again with the --webrat-matchers flag if you want to use webrat matchers
    assert_select "form", :action => clown_path(@clown), :method => "post" do
      assert_select "input#clown_name", :name => "clown[name]"
      assert_select "input#clown_balloons", :name => "clown[balloons]"
    end
  end
end
4

1 に答える 1

0

simple_form (またはおそらくformtastic )も使用していますか? scaffold フォームを標準フォームから simple_form フォーム ( form_for(@user)=> simple_form_for(@user)) に変換すると、同じエラーが発生します。

あなたが言うように、それはまだ機能しているので、心配する価値があるかどうかはわかりません. キュウリに心配させたほうがいいと思うよ。Sarah Mei は、view spec は時間の無駄だと言います。:-)

于 2010-11-30T12:02:07.780 に答える