Skip to content

Commit

Permalink
convert matchers to updated Matcher DSL
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Mar 19, 2010
1 parent c2a0fcb commit bb1b389
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
2 changes: 1 addition & 1 deletion lib/rspec/rails/example/controller_example_group.rb
Expand Up @@ -14,7 +14,7 @@ module ControllerExampleGroupBehaviour
include ActionDispatch::Integration::Runner
include Webrat::Matchers
include Webrat::Methods
include Rspec::Rails::Matchers
include Rspec::Matchers

def self.setup(*args); end
def self.teardown(*args); end
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/rails/example/request_example_group.rb
Expand Up @@ -6,7 +6,7 @@ module RequestExampleGroupBehaviour
include ActionDispatch::Integration::Runner
include Webrat::Matchers
include Webrat::Methods
include Rspec::Rails::Matchers
include Rspec::Matchers

def self.included(mod)
mod.before do
Expand Down
31 changes: 8 additions & 23 deletions lib/rspec/rails/matchers.rb
Expand Up @@ -11,30 +11,15 @@ class AssertionFailedError < StandardError
end
end

module Rspec
module Rails
module Matchers
include Rspec::Matchers

def redirect_to(destination)
running_example = self
Matcher.new :redirect_to, destination do |destination_|
match_unless_raises Test::Unit::AssertionFailedError do |_|
running_example.assert_redirected_to destination_
end
end
end

def render_template(options={}, message=nil)
running_example = self
Matcher.new :render_template, options, message do |options_, message_|
match_unless_raises Test::Unit::AssertionFailedError do |_|
running_example.assert_template options_, message_
end
end
end
Rspec::Matchers.define :redirect_to do |destination|
match_unless_raises Test::Unit::AssertionFailedError do |_|
assert_redirected_to destination
end
end

end
Rspec::Matchers.define :render_template do |options, message|
match_unless_raises Test::Unit::AssertionFailedError do |_|
assert_template options, message
end
end

Expand Down

0 comments on commit bb1b389

Please sign in to comment.