Created
March 27, 2015 15:47
-
-
Save aaronjensen/d23838db8de02cccaeea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo < SimpleDelegator | |
def in(&block) | |
instance_eval &block | |
end | |
def have_awesomeness | |
matcher do |target| | |
expect(target).to eq 3 | |
end | |
end | |
def matcher(&block) | |
Matcher.new(&block) | |
end | |
class Matcher | |
def initialize(&block) | |
@block = block | |
end | |
def matches?(target) | |
@block.call(target) | |
true | |
end | |
end | |
end | |
describe 'asdf' do | |
it 'asfd' do | |
hi = "hi" | |
with(:foo) do | |
expect(3).to have_awesomeness | |
end | |
end | |
def with(sym, &block) | |
Foo.new(self).in(&block) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment