Pregunta

So I have this test in my app:

expect{
  post :create, :name=> 'abc'
}.to change(Event.count).from(0).to(1)

and it keeps throwing he this error:

TypeError: nil is not a symbol

Would anyone know why?

¿Fue útil?

Solución

Found out the issue. Should be using {} instead of (). Should be this instead:

expect{
  post :create, :name=> 'abc'
}.to change{Event.count}.from(0).to(1)

Otros consejos

You can also do it as below:

expect{
  post :create, :name=> 'abc'
}.to change(Event, :count).from(0).to(1)
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top