spec/spec_helper.rb in remnant-0.1.3 vs spec/spec_helper.rb in remnant-0.2.0
- old
+ new
@@ -8,117 +8,13 @@
RSpec.configure do |config|
config.mock_with :rr
end
require 'action_controller'
-require 'action_controller/test_process'
-require 'active_record'
require 'active_support'
-require 'rack'
-require 'sham_rack'
-require 'flail'
-require 'flail/rails/controller_methods'
-require 'flail/rails/rescue_action'
+require 'remnant'
-
Dir["#{File.expand_path(File.dirname(__FILE__))}/support/*.rb"].map {|file| require(file)}
-class FlailArmory
-
- module ClassMethods
- def define_constant(name, value)
- @defined_constants ||= []
- Object.const_set(name, value)
- @defined_constants << name
- end
-
- def build_controller_class(&definition)
- Class.new(ActionController::Base).tap do |klass|
- klass.__send__(:include, Flail::Rails::ControllerMethods)
- klass.__send__(:include, Flail::Rails::RescueAction)
- klass.class_eval(&definition) if definition
-
- klass.class_eval do
- def rescue_action_in_public_without_flail(*args)
- end
- end
- define_constant('FlailTestController', klass)
- end
- end
-
- def process_action(options = {}, &action)
- options[:request] ||= ActionController::TestRequest.new
- options[:response] ||= ActionController::TestResponse.new
-
- klass = build_controller_class do
- cattr_accessor :local
- define_method(:index, &action)
-
- def current_user
- @current_user
- end
-
- def local_request?
- local
- end
- end
-
- if options[:user_agent]
- if options[:request].respond_to?(:user_agent=)
- options[:request].user_agent = options[:user_agent]
- else
- options[:request].env["HTTP_USER_AGENT"] = options[:user_agent]
- end
- end
-
- klass.consider_all_requests_local = options[:all_local]
- klass.local = options[:local]
-
- controller = klass.new
-
- if options[:user]
- controller.instance_variable_set(:@current_user, options[:user])
- end
-
- options[:request].query_parameters = options[:request].query_parameters.merge(options[:params] || {})
- options[:request].session = ActionController::TestSession.new(options[:session] || {})
- options[:request].env['REQUEST_URI'] = options[:request].request_uri
-
- controller.process(options[:request], options[:response])
- controller
- end
-
- def process_action_with_error(options = {})
- process_action(options) do
- raise "Hello"
- end
- end
-
- def setup
- Flail.configure do
- handle do |payload|
- FlailArmory.payload = ActiveSupport::JSON.decode(payload)
- end
- end
- define_constant('RAILS_ROOT', '/path/to/rails/root')
- end
-
- def payload=(value)
- @payload = value
- end
-
- def payload
- @payload
- end
-
- def raid
- @defined_constants.each do |constant|
- Object.__send__(:remove_const, constant)
- end
-
- @payload = nil
- @defined_constants = []
- end
- end
- extend ClassMethods
-end
+# for dependency reloading
+ActiveSupport::Dependencies.autoload_paths << File.dirname(__FILE__) + '/app/'