Q:

RSpec shared_examples using let versus block argument

Sandi Metz's "Practical Object Oriented Design in Ruby" used Minitest to demonstrate writing shared test to test roles.  So I am thinking about how to do the RSpec equivalent.
The wheel plays the role of a diameterizable.  A diameterizable is defined as an object that responds to width.  So far, I came up with two different versions to make the object available to the shared example.  Which is a better approach or is there a better way?
version 1, use let:
# wheel_spec.rb
RSpec.describe Wheel do
  let(:wheel) { Wheel.new(26, 1.5) }

  it_behaves_like "a diameterizable" do
    let(:diameterizable) { wheel }
  end

  # wheel is available for use ...
end

# diameterizable_interface.rb
RSpec.shared_examples "a diameterizable" do
  it "implements the diameterizable interface" do
    expect(diameterizable).to respond_to(:width)
  end
end

version 2, use block argument:
# wheel_spec.rb
RSpec.describe Wheel do
  let(:wheel) { Wheel.new(26, 1.5) }

  it_behaves_like "a diameterizable", Wheel.new

  # wheel is available for use ...
end

# diameterizable_interface.rb
RSpec.shared_examples "a diameterizable" do |diameterizable|
  it "implements the diameterizable interface" do
    expect(diameterizable).to respond_to(:width)
  end
end 

A:

This seems like a good time to use an implicit subject:
RSpec.shared_examples "a diameterizable" do
  it "implements the diameterizable interface" do
    expect(subject).to respond_to(:width)
  end
end

RSpec.describe Wheel do
  let(:wheel) { Wheel.new(26, 1.5) }
  subject { wheel }

  it_behaves_like "a diameterizable"
end

btw your second version creates a new Wheel for the shared example, which is likely to create problems.

