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)
Pergunta
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?
Solução
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)
Outras dicas
You can also do it as below:
expect{
post :create, :name=> 'abc'
}.to change(Event, :count).from(0).to(1)