2019-03-18 13:21:35 +00:00
|
|
|
require 'simplecov'
|
|
|
|
SimpleCov.start do
|
|
|
|
add_filter 'spec'
|
|
|
|
add_group 'Draper', 'lib/draper'
|
|
|
|
add_group 'Generators', 'lib/generators'
|
|
|
|
end
|
|
|
|
|
2011-06-30 22:19:48 +00:00
|
|
|
require 'bundler/setup'
|
2013-01-17 02:36:56 +00:00
|
|
|
require 'draper'
|
2013-01-18 16:40:57 +00:00
|
|
|
require 'action_controller'
|
|
|
|
require 'action_controller/test_case'
|
2013-01-17 02:36:56 +00:00
|
|
|
|
|
|
|
RSpec.configure do |config|
|
2015-08-27 03:43:50 +00:00
|
|
|
config.expect_with :rspec do |expectations|
|
|
|
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
|
|
end
|
|
|
|
|
2015-03-09 21:51:50 +00:00
|
|
|
config.mock_with :rspec do |mocks|
|
|
|
|
mocks.yield_receiver_to_any_instance_implementation_blocks = true
|
|
|
|
end
|
2015-08-27 03:43:50 +00:00
|
|
|
|
|
|
|
config.filter_run :focus
|
|
|
|
config.run_all_when_everything_filtered = true
|
|
|
|
config.disable_monkey_patching!
|
|
|
|
|
|
|
|
if config.files_to_run.one?
|
|
|
|
config.default_formatter = 'doc'
|
|
|
|
else
|
|
|
|
config.default_formatter = 'progress'
|
|
|
|
end
|
|
|
|
|
|
|
|
config.order = :random
|
|
|
|
Kernel.srand config.seed
|
2013-01-17 02:36:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
class Model; include Draper::Decoratable; end
|
|
|
|
|
|
|
|
class Product < Model; end
|
2013-11-10 17:02:34 +00:00
|
|
|
class SpecialProduct < Product; end
|
2015-03-27 04:07:17 +00:00
|
|
|
class Other < Model; end
|
2017-10-12 16:55:00 +00:00
|
|
|
class Person < Model; end
|
|
|
|
class Child < Person; end
|
2013-01-17 02:36:56 +00:00
|
|
|
class ProductDecorator < Draper::Decorator; end
|
|
|
|
class ProductsDecorator < Draper::CollectionDecorator; end
|
|
|
|
|
|
|
|
class OtherDecorator < Draper::Decorator; end
|
|
|
|
|
|
|
|
module Namespaced
|
|
|
|
class Product < Model; end
|
|
|
|
class ProductDecorator < Draper::Decorator; end
|
2017-04-04 03:24:33 +00:00
|
|
|
ProductsDecorator = Class.new(Draper::CollectionDecorator)
|
2013-01-17 02:36:56 +00:00
|
|
|
class OtherDecorator < Draper::Decorator; end
|
|
|
|
end
|
|
|
|
|
2017-03-31 14:05:15 +00:00
|
|
|
ApplicationController = Class.new(ActionController::Base)
|
|
|
|
CustomController = Class.new(ActionController::Base)
|
|
|
|
|
2013-01-17 02:36:56 +00:00
|
|
|
# After each example, revert changes made to the class
|
|
|
|
def protect_class(klass)
|
|
|
|
before { stub_const klass.name, Class.new(klass) }
|
|
|
|
end
|
2013-01-18 16:40:57 +00:00
|
|
|
|
|
|
|
def protect_module(mod)
|
|
|
|
before { stub_const mod.name, mod.dup }
|
|
|
|
end
|