Skip to content

Instantly share code, notes, and snippets.

@techno-tanoC
Created November 14, 2014 05:19
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 techno-tanoC/36e7a0357f15c447b867 to your computer and use it in GitHub Desktop.
Save techno-tanoC/36e7a0357f15c447b867 to your computer and use it in GitHub Desktop.
get_matcher
# coding: utf-8
require 'spec_helper'
RSpec::Matchers.define :get do |first|
match do |actual|
actual.public_send(@second, *@args) == first
end
chain :by_call do |second, *args|
@second = second
@args = args
end
end
RSpec.describe 5 do
it { is_expected.to get(6).by_call(:succ) }
it { is_expected.to get("5").by_call(:to_s) }
it { is_expected.to get(7).by_call(:+, 2) }
end
describe "" do
subject { 5 }
it "" do
expect(subject.succ).to be 6
is_expected.to get(6).by_call(:succ)
is_expected.to get(7).by_call(:+, 2)
end
it "" do
expect(subject.to_s).to eq "5"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment