Skip to content

Instantly share code, notes, and snippets.

@ianks

ianks/block2.rb Secret

Created June 17, 2017 00:01
Show Gist options
  • Save ianks/2a1183e0c1127d3c4640088983c0565f to your computer and use it in GitHub Desktop.
Save ianks/2a1183e0c1127d3c4640088983c0565f to your computer and use it in GitHub Desktop.
describe Post do
let(:api_client) { double(fetch_comments: []) }
subject(:post) { Post.new(api_client: api_client) }
describe '#comments' do
it 'only fetches the approved comments by default' do
expect(api_client)
.to receive(:fetch_comments)
.with(a_hash_including(approved: true))
.once
.and_call_original
post.comments
end
it 'only fetches the unread comments by default' do
expect(api_client)
.to receive(:fetch_comments)
.with(a_hash_including(status: :unread))
.once
.and_call_original
post.comments
end
# ...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment