Skip to content

Instantly share code, notes, and snippets.

@ianks

ianks/block4.rb Secret

Created June 17, 2017 00:01
Show Gist options
  • Save ianks/165b998ae3a50a2eaae8e9267208817e to your computer and use it in GitHub Desktop.
Save ianks/165b998ae3a50a2eaae8e9267208817e 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) }
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