2010-11-30 10 views
0

Je reçois ces échecs lors de l'exécution rspec spec/. La spécification qui échoue a été générée automatiquement avec l'échafaudage. J'essaie de comprendre RSpec mais je ne sais pas où commencer à chercher la cause autre que cela sent comme une méthode est manquant?!? Pourtant, l'application semble bien fonctionner. Rien sur ces échecs n'apparaît dans test.log. Y a-t-il un autre endroit où je devrais chercher des indices pour suivre cela?Comprendre l'échec RSpec

$ 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 

Répondre

0

Êtes-vous aussi utilise simple_form (ou peut-être même formtastic)? J'obtiens la même erreur quand je convertis les formes d'échafaudage des formes standards aux formes simples_form (form_for(@user) =>simple_form_for(@user)). Cela fonctionne toujours, comme vous le dites, donc je ne suis pas sûr que cela vaille la peine de s'inquiéter. Je pense que vous feriez mieux de laisser Cucumber s'inquiéter à ce sujet. Sarah Mei dit view specs are a waste of time. :-)

+0

Oui, simple_form était utilisé sur cette vue ... merci! – Meltemi