Skip to content

Instantly share code, notes, and snippets.

@ThijsWouters
Created January 6, 2014 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThijsWouters/8288990 to your computer and use it in GitHub Desktop.
Save ThijsWouters/8288990 to your computer and use it in GitHub Desktop.
Descriptions of matchers with an array of strings.
require 'rspec'
describe 'Matcher description' do
it 'returns the correct description' do
[
[be(['foo']), 'equal "foo"'],
[be_a(['foo']), 'be a kind of "foo"'],
[be_an_instance_of(['foo']), 'be an instance of ["foo"]'],
[be_within(['foo']), 'be within ["foo"] of '],
[contain_exactly(['foo']), 'contain exactly ["foo"]'],
[cover(['foo']), 'cover ["foo"]'],
[end_with(['foo']), 'end with "foo"'],
[eq(['foo']), 'eq ["foo"]'],
[eql(['foo']), 'eql "foo"'],
[equal(['foo']), 'equal "foo"'],
[exist(['foo']), 'exist ["foo"]'],
[include(['foo']), 'include ["foo"]'],
[match(['foo']), 'match ["foo"]'],
[match_array(['foo']), 'contain exactly "foo"'],
[raise_error(['foo']), 'raise ["foo"]'],
[respond_to(['foo']), 'respond to #["foo"]'],
[start_with(['foo']), 'start with "foo"'],
[throw_symbol(['foo']), 'throw ["foo"]'],
[yield_with_args(['foo']), 'yield with args(["foo"])'],
[yield_successive_args(['foo']), 'yield successive args(["foo"])'],
[yield_with_args(['foo']), 'yield with args(["foo"])'],
].each do |matcher, expected_description|
expect(matcher.description).to eq(expected_description)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment