Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 理解RSpec故障_Ruby On Rails_Rspec_Rspec2 - Fatal编程技术网

Ruby on rails 理解RSpec故障

Ruby on rails 理解RSpec故障,ruby-on-rails,rspec,rspec2,Ruby On Rails,Rspec,Rspec2,我在运行rspec spec/时遇到这些故障。失败的规范是通过脚手架自动生成的。我试图理解RSpec,但我不知道从哪里开始寻找原因,除了感觉缺少某种方法?!?然而,该应用程序似乎运行良好。test.log中未显示有关这些故障的任何信息。有没有其他地方我应该寻找线索来追踪这件事 $ rspec spec/ .....................F.F. Failures: 1) clowns/edit.html.haml renders the edit clown form

我在运行
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

您是否也在使用simple\u form(或者甚至formtastic)?当我将脚手架表单从标准表单转换为简单表单(
form\u for(@user)
=>
simple\u-for(@user)
)时,我会遇到同样的错误

正如你所说,它仍然有效,所以我不确定它是否值得担心。我想你最好还是让Cucumber担心一下。莎拉·梅说::-)

#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