Module: Qlive::Suite

Includes:
QunitAssets
Defined in:
lib/qlive/suite.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from QunitAssets

#glob_script_tags, #prepare_assets, #qunit_disable_autostart, #qunit_finalize, #qunit_framework, #qunit_html_structure, #qunit_javascript_test_sources, #qunit_support_assets

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



8
9
10
# File 'lib/qlive/suite.rb', line 8

def request
  @request
end

#sessionObject (readonly)

Returns the value of attribute session.



8
9
10
# File 'lib/qlive/suite.rb', line 8

def session
  @session
end

Class Method Details

.included(base) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/qlive/suite.rb', line 12

def self.included(base)
  registration = Registry.register_class(base)
  base.class_eval do
    class << self
      attr_reader :suite_registration
    end
  end
  base.instance_variable_set(:@suite_registration, registration)

  InsertionPoints.each do |place|
    attr_accessor place

    define_method "html_#{place}" do
      htmls = instance_variable_get("@#{place}")
      has_content = htmls.length > 0
      htmls.unshift "\n<!-- Begin Qlive Insertions (#{place}) -->" if has_content
      htmls << "<!-- End Qlive Insertions (#{place}) -->\n" if has_content
      htmls.join("\n")
    end
  end
end

Instance Method Details

#before_each_request(rack_request) ⇒ Object

DEPRECATED



62
63
64
65
# File 'lib/qlive/suite.rb', line 62

def before_each_request(rack_request)
  Qlive.logger.warn("Qlive suite '#{suite_name}' uses deprecated 'before_each_request' method. Rename it to 'before_each_suite'.")
  before_each_suite(rack_request)
end

#before_each_suite(rack_request) ⇒ Object



53
54
55
# File 'lib/qlive/suite.rb', line 53

def before_each_suite(rack_request)
  # override in suite
end

#before_suite_response(status, headers, body) ⇒ Object



57
58
59
# File 'lib/qlive/suite.rb', line 57

def before_suite_response(status, headers, body)
  # override in suite
end

#prepare(args = {}) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/qlive/suite.rb', line 36

def prepare(args={})
  @session = args[:session]
  @request = args[:request]
  InsertionPoints.each do |place|
    instance_variable_set("@#{place}", [ ])
  end
  prepare_assets
end

#registrationObject



45
46
47
# File 'lib/qlive/suite.rb', line 45

def registration
  self.class.suite_registration
end

#suite_nameObject



49
50
51
# File 'lib/qlive/suite.rb', line 49

def suite_name
  self.registration.name
end