메서드를 호출하는 메서드에서 메서드 중 하나가 특정 매개 변수를 가져 오는 지 여부를 테스트하려고합니다. 예를 들어 아래 코드에서 MyModel은 offset
메서드에 대해 매개 변수 0을 받아야합니다. 불행히도 아래 코드는 작동하지 않습니다. should_receive와 stub_chain을 혼합하는 것은 불가능한 것 같습니다. 어떻게 해결할 수 있을까요? 나는 또한 RSpec에 Google 그룹에 질문을 게시 stub_chain with should_receive
데이비드 (RSpec에의 창조자를
tags = taggable.tag_counts.offset(page-1).limit(per_page).where(*where_clause).order("count DESC")
업데이트했다 : 나는 RSpec에 2
MyModel.should_receive(:offset).with(0).stub_chain(:tag_counts, :offset, :limit, :order).and_return([]) # does not work!
코드 내가 테스트를 시도하고 사용하고 있습니다) 대답했습니다 (David에게 감사드립니다) : http://groups.google.com/group/rspec/browse_thread/thread/6b8394836d2390b0?hl=en