Testing &block Arguments with Rspec

In my example, I have a service that calls OpenURI's open, which accepts a block as one of its arguments:

class MyService

  def call_response
    open("http://website.com/api", http_basic_authentication: ["username","password"], &:read)
  end
end

In this case, that last argument calls .read on the response automatically to get to its body. Now I'd like to test the following:

  1. A block argument gets passed in to open
  2. The block argument that gets passed in is specifically the &:read

You can do both very simply all in one spec with Rspec:

require 'spec_helper'

describe MyService do

  describe "#open"

    it "calls read on response" do
      my_service = MyService.new
      expect(my_service).to receive(:open) do |url, authentication, &block|
        expect(block).to eq :read.to_proc
      end

      my_service.call_response
    end
  end
end