문제

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?

도움이 되었습니까?

해결책

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)

다른 팁

You can also do it as below:

expect{
  post :create, :name=> 'abc'
}.to change(Event, :count).from(0).to(1)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top