File: shared_examples.rb

package info (click to toggle)
ruby-rspec-collection-matchers 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 192 kB
  • sloc: ruby: 948; sh: 7; makefile: 4
file content (12 lines) | stat: -rw-r--r-- 412 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
shared_examples_for "an RSpec matcher" do |options|
  let(:valid_value)   { options.fetch(:valid_value) }
  let(:invalid_value) { options.fetch(:invalid_value) }

  it 'matches a valid value when using #== so it can be composed' do
    expect(matcher).to eq(valid_value)
  end

  it 'does not match an invalid value when using #== so it can be composed' do
    expect(matcher).not_to eq(invalid_value)
  end
end