Module: CallCenter::Test::DSL

Defined in:
lib/call_center/test/dsl.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/call_center/test/dsl.rb', line 16

def self.included(base)
  if ActionPack::VERSION::MAJOR == 2
    base.send(:include, ActionController::Assertions::SelectorAssertions)
  else
    base.send(:include, ActionDispatch::Assertions::SelectorAssertions)
  end

  base.extend(ClassMethods)
  base.class_eval do
    def html_document
      HTML::Document.new(CGI.unescapeHTML(@body))
    end

    if ActionPack::VERSION::STRING < "3.2.0"
      def response_from_page_or_rjs_with_body
        html_document.root
      end

      alias_method_chain :response_from_page_or_rjs, :body
    end
  end
end

Instance Method Details

#body(text, debug = false) ⇒ Object



39
40
41
42
# File 'lib/call_center/test/dsl.rb', line 39

def body(text, debug = false)
  puts text if debug
  @body = text
end