Question

Je reçois ces échecs lors de l'exécution rspec spec/. La spécification qui échoue est a été généré automatiquement avec l'échafaudage. Je suis en train de comprendre RSpec mais je ne sais pas où commencer à chercher la cause autre que ce sent comme une méthode manque?!? Cependant, l'application semble fonctionner très bien. Rien au sujet de ces échecs apparaît dans test.log. Y at-il un autre endroit où je devrais être à la recherche pour obtenir des conseils de ce bas suivre?

$ 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

Et voici la spécification qui ne semble (edit.html.haml_spec.rb). Il a été généré automatiquement par 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
Était-ce utile?

La solution

Vous utilisez également simple_form (ou peut-être même formtastic )? Je reçois la même erreur quand je convertir les formes d'échafaudage de formes de normalisation à des formes de simple_form (form_for(@user) => simple_form_for(@user)).

Il fonctionne toujours, comme vous le dites, alors je ne suis pas sûr que ça vaut se soucier. Je pense que vous seriez mieux se contenter de laisser l'inquiétude Concombre à ce sujet. Sarah Mei dit sont une perte de temps . : -)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top