Skip to content

Instantly share code, notes, and snippets.

@aaronjensen
Created March 27, 2015 15:47
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 aaronjensen/d23838db8de02cccaeea to your computer and use it in GitHub Desktop.
Save aaronjensen/d23838db8de02cccaeea to your computer and use it in GitHub Desktop.
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