Skip to content

Commit

Permalink
include Rspec::Matchers
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Feb 27, 2010
1 parent 885868e commit d862af7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
5 changes: 3 additions & 2 deletions lib/rspec/rails/example/controller_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ module ControllerExampleGroupBehaviour
include ActionDispatch::Integration::Runner
include Webrat::Matchers
include Webrat::Methods
include Rspec::Matchers
include Rspec::Rails::Matchers

def self.included(mod)
mod.before { @_result = Struct.new(:add_assertion).new }
mod.before do
@_result = Struct.new(:add_assertion).new
end
end

def app
Expand Down
4 changes: 4 additions & 0 deletions lib/rspec/rails/example/mailer_example_group.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
require 'webrat'

module MailerExampleGroupBehavior
include Webrat::Matchers
include Rspec::Matchers

def read_fixture(action)
IO.readlines(File.join(Rails.root, 'spec', 'fixtures', self.described_class.name.underscore, action))
Expand Down
15 changes: 7 additions & 8 deletions lib/rspec/rails/example/request_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ module RequestExampleGroupBehaviour
include Webrat::Matchers
include Webrat::Methods
include Rspec::Rails::Matchers
Rails.application.routes.install_helpers(self)

def self.included(mod)
mod.before do
@_result = Struct.new(:add_assertion).new
@router = Rails.application.routes
end
end

def app
Rails.application
end
Expand All @@ -21,13 +27,6 @@ def last_response
response
end

def self.included(mod)
mod.before do
@_result = Struct.new(:add_assertion).new
@router = Rails.application.routes
end
end

Rspec.configure do |c|
c.include self, :example_group => { :file_path => /\bspec\/requests\// }
end
Expand Down
1 change: 1 addition & 0 deletions lib/rspec/rails/example/view_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module ViewExampleGroupBehaviour
include Webrat::Matchers
include Rspec::Matchers

class ViewExampleController < ActionController::Base
attr_accessor :controller_path
Expand Down
6 changes: 4 additions & 2 deletions lib/rspec/rails/matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
module Rspec
module Rails
module Matchers
include Rspec::Matchers

def redirect_to(destination)
example = self
Rspec::Matchers::Matcher.new :redirect_to, destination do |destination_|
Matcher.new :redirect_to, destination do |destination_|
match_unless_raises Test::Unit::AssertionFailedError do |_|
example.assert_redirected_to destination_
end
Expand All @@ -15,7 +17,7 @@ def redirect_to(destination)

def render_template(options={}, message=nil)
example = self
Rspec::Matchers::Matcher.new :render_template, options, message do |options_, message_|
Matcher.new :render_template, options, message do |options_, message_|
match_unless_raises Test::Unit::AssertionFailedError do |_|
example.assert_template options_, message_
end
Expand Down

0 comments on commit d862af7

Please sign in to comment.