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
38
39
40
# 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 :response_from_page_or_rjs_without_body, :response_from_page_or_rjs
      alias_method :response_from_page_or_rjs, :response_from_page_or_rjs_with_body
    elsif instance_methods.include?(:response_from_page_with_rjs) # prototype-rails hacks we do not want
      alias_method :response_from_page, :response_from_page_without_rjs
    end
  end
end

Instance Method Details

#body(text, debug = false) ⇒ Object


42
43
44
45
# File 'lib/call_center/test/dsl.rb', line 42

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