Skip to content

Commit

Permalink
clean up RequestExampleGroupBehaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Apr 26, 2010
1 parent a92d898 commit 17ee47c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 27 deletions.
31 changes: 17 additions & 14 deletions lib/rspec/rails/adapters.rb
@@ -1,24 +1,27 @@
require 'active_support/concern'
require 'test/unit/assertions'

module Rspec::Rails
module SetupAndTeardownAdapter
def setup(*methods)
methods.each {|method| before { send method } }
end
module Rspec
module Rails
module SetupAndTeardownAdapter
def setup(*methods)
methods.each {|method| before { send method } }
end

def teardown(*methods)
methods.each {|method| after { send method } }
def teardown(*methods)
methods.each {|method| after { send method } }
end
end
end

module TestUnitAssertionAdapter
extend ActiveSupport::Concern
module TestUnitAssertionAdapter
extend ActiveSupport::Concern

included do
include Test::Unit::Assertions

included do
include Test::Unit::Assertions
before do
@_result = Struct.new(:add_assertion).new
before do
@_result = Struct.new(:add_assertion).new
end
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions lib/rspec/rails/example/controller_example_group.rb
@@ -1,4 +1,3 @@
require 'active_support/core_ext/class/attribute_accessors'
require 'action_controller'
require 'webrat'

Expand All @@ -20,7 +19,7 @@ def controller_class
include Webrat::Methods
include Rspec::Matchers
before do
@routes = Rails.application.routes
@routes = ::Rails.application.routes
ActionController::Base.allow_forgery_protection = false
end
end
Expand Down
24 changes: 13 additions & 11 deletions lib/rspec/rails/example/request_example_group.rb
Expand Up @@ -2,15 +2,17 @@
require 'webrat'

module RequestExampleGroupBehaviour
include ActionDispatch::Assertions
extend ActiveSupport::Concern
include ActionDispatch::Integration::Runner
include Webrat::Matchers
include Webrat::Methods
include Rspec::Matchers

def self.included(mod)
mod.before do
@_result = Struct.new(:add_assertion).new
included do
include Rspec::Rails::TestUnitAssertionAdapter
include ActionDispatch::Assertions
include Webrat::Matchers
include Webrat::Methods
include Rspec::Matchers

before do
@router = ::Rails.application.routes
end
end
Expand All @@ -19,14 +21,14 @@ def app
::Rails.application
end

Webrat.configure do |config|
config.mode = :rack
end

def last_response
response
end

Webrat.configure do |config|
config.mode = :rack
end

Rspec.configure do |c|
c.include self, :example_group => { :file_path => /\bspec\/requests\// }
end
Expand Down

0 comments on commit 17ee47c

Please sign in to comment.