Class: JsTestDriver::HtmlFixture

Inherits:
Object
  • Object
show all
Defined in:
lib/js_test_driver/html_fixture.rb

Overview

This is a class that given a directory name, puts all its *.html children into a javascript file, so that they can later be used in the tests

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(directory_name, name = nil, namespace = nil) ⇒ HtmlFixture

Returns a new instance of HtmlFixture.



8
9
10
11
12
13
14
# File 'lib/js_test_driver/html_fixture.rb', line 8

def initialize(directory_name, name = nil, namespace = nil)
  @name = name || "all"
  @namespace = namespace || "htmlFixtures"
  @data = {}

  load_data(directory_name)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/js_test_driver/html_fixture.rb', line 6

def name
  @name
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



6
7
8
# File 'lib/js_test_driver/html_fixture.rb', line 6

def namespace
  @namespace
end

Instance Method Details

#to_hObject



16
17
18
# File 'lib/js_test_driver/html_fixture.rb', line 16

def to_h
  @data
end

#to_sObject



20
21
22
23
24
25
# File 'lib/js_test_driver/html_fixture.rb', line 20

def to_s
  <<JS
if (typeof(#{namespace}) === 'undefined') { #{namespace} = {}; }
#{namespace}.#{name} = #{self.to_h.to_json};
JS
end