안녕하세요 모두 내가 액티브 메일을 상속했지만 행운이없는 모델에서 특정 메서드가 특정 메서드를 호출하는 경우 테스트 할 Rspec을 얻으려고합니다. 빠른 모형으로 다음과 같은 시나리오가 있습니다. 모델 UserNotifier :RSpec ActiveMailer 모델로 테스트 호출
class UserNotifier < ActionMailer::Base
def foobaz
end
end
컨트롤러 암호 컨트롤러 :
class PasswordsController < ApplicationController
def foobar
UserNotifier.foobaz
end
그리고 사양 :
describe "GET 'foobar'" do
it "should call the UserNotifier foobaz method" do
UserNotifier.should_receive(:foobaz)
get :foobar
end
end
하지만 난 항상이 실패로 끝날 :
1) PasswordsController GET 'foobar' should call the UserNotifier foobaz method
Failure/Error: UserNotifier.should_receive(:foobaz)
(<UserNotifier (class)>).foobaz(any args)
expected: 1 time
received: 0 times
수있는 사람 왜 그런지 가르쳐주세요. RSpec은 UserNotifier.foobaz 메서드가 호출되고 있다는 것을 등록하지 않습니까?
이 예제를 복제하고 예제를 통과합니다. 어쩌면 문제를 발견 한 원래 코드를 게시해야합니다. – zetetic
이것은 원래의 코드입니다. 나는 변화시키지 않았고이를 통과 할 수 없습니다. –
필자는 어떤 종류의 로그인 체크가 있거나 그 슈퍼 컨트롤러 중 하나에 있기 때문에 'PasswordsController'에 접근하지 못한다고 생각합니다. –