-
-
Save ianks/165b998ae3a50a2eaae8e9267208817e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe Post do | |
let(:api_client) { double(fetch_comments: []) } | |
subject(:post) { Post.new(api_client: api_client) } | |
def fetch_comments_with(params) | |
receive(:fetch_comments).with(a_hash_including(params)).once | |
end | |
describe '#comments' do | |
it 'only fetches the approved comments by default' do | |
expect(api_client).to fetch_comments_with(approved: true) | |
post.comments | |
end | |
it 'only fetches the unread comments by default' do | |
expect(api_client).to fetch_comments_with(status: :unread) | |
post.comments | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment