Skip to content

Commit

Permalink
add expect {block}.to[_not] matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Sep 21, 2009
1 parent 8056ead commit d1cd262
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rspec/expectations/extensions.rb
@@ -1 +1,2 @@
require 'rspec/expectations/extensions/kernel'
require 'rspec/expectations/extensions/rspec/core/example_group'
19 changes: 19 additions & 0 deletions lib/rspec/expectations/extensions/rspec/core/example_group.rb
@@ -0,0 +1,19 @@
module Rspec
module Core
class ExampleGroup
module BlockAliases
alias_method :to, :should
alias_method :to_not, :should_not
end

# Extends the submitted block with aliases to and to_not
# for should and should_not. Allows expectations like this:
#
# expect { this_block }.to change{this.expression}.from(old_value).to(new_value)
# expect { this_block }.to raise_error
def expect(&block)
block.extend BlockAliases
end
end
end
end

0 comments on commit d1cd262

Please sign in to comment.