2012-07-10 25 views
5

Ho aggiornato la mia versione di RSpec alla versione più recente e ho le prove di rottura che hanno sintassi simileCome faccio a scrivere questo con RSpec

it "should delete a company" do 
    expect { click_link "Delete Company" }.should change(Company, :count).by(-1) 
end 

ho guardato la documentation e non riuscivo a vedere tutto ciò che può fanno questo nel verion corrente ... tutte le idee su come raggiungere questo obiettivo

l'errore che ottengo è

9) Company Pages Edit page as an admin user should delete a company 
    Failure/Error: expect { click_link "Delete Company" }.should change(Company, :count).by(-1) 
    NoMethodError: 
    undefined method `call' for #<RSpec::Expectations::ExpectationTarget:0x007fccafdfc360> 
    # ./spec/requests/companies_spec.rb:79:in `block (3 levels) in <top (required)>' 
+6

shouldnt questo sia '' to''' invece di '' 'should'' '? – phoet

+0

Lo verificherò – Trace

+0

@phoet è corretto. –

risposta

9

Ecco il doc sull'uso expectatio ns

it "should delete a company" do 
    expect { click_link "Delete Company" }.to change{Company.count}.by(-1) 
end 

Nota le seguenti modifiche

  1. should diventa to
  2. (Company, :count) diventa {Company.count}
Problemi correlati