Module: ActiveDecorator::RSpec

Defined in:
lib/active_decorator/rspec.rb,
lib/active_decorator/rspec/version.rb

Constant Summary collapse

VERSION =
"0.0.7"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.enable(example) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/active_decorator/rspec.rb', line 9

def self.enable(example)
  example.extend self

  base_class = begin
                 ApplicationController
               rescue NameError
                 ActionController::Base
               end
  controller = Class.new(base_class).new
  controller.request = ActionController::TestRequest.new
  if ActiveDecorator::ViewContext.respond_to?(:current=)
    ActiveDecorator::ViewContext.current = controller.view_context
  else
    ActiveDecorator::ViewContext.push controller.view_context
  end

  self
end

Instance Method Details

#decorate(obj) ⇒ Object



28
29
30
31
# File 'lib/active_decorator/rspec.rb', line 28

def decorate(obj)
  ActiveDecorator::Decorator.instance.decorate(obj)
  obj
end