uptime_monitor 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,253 @@
1
+ grammar Maestro
2
+
3
+ rule body
4
+ ( waiting / validations_and_actions / element_validation / single_html_element / space)* {
5
+ def content
6
+ elements.map { |e| e.content }.compact
7
+ end
8
+
9
+ def description
10
+ elements.map { |e| e.description }.compact
11
+ end
12
+ }
13
+ end
14
+
15
+ rule waiting
16
+ space? "wait_for" page_content {
17
+ def content
18
+ [{:wait_until_exists? => page_content.content }]
19
+ end
20
+ def description
21
+ "waited, #{page_content.description}"
22
+ end
23
+ }
24
+ end
25
+
26
+ rule page_content
27
+ space (validations_and_actions / element_validation / html_element) space? {
28
+ def content
29
+ elements[1].content
30
+ end
31
+ def description
32
+ elements[1].description
33
+ end
34
+ }
35
+ end
36
+
37
+ rule validations_and_actions
38
+ (element_validation / html_element) check_func+ {
39
+ def content
40
+ this_content = elements.first.content
41
+ container = [(this_content.is_a?(Array) ? this_content.first : this_content )]
42
+ elements.last.elements.each do |e|
43
+ container << e.content
44
+ end
45
+ container
46
+ end
47
+
48
+ def description
49
+ string = elements.first.description
50
+ elements.last.elements.each do |e|
51
+ element_description = e.description
52
+ string << ", " if element_description.include?("with text") || element_description.include?("includes text")
53
+ string << element_description
54
+ end
55
+ string
56
+ end
57
+ }
58
+ end
59
+
60
+ rule element_validation
61
+ html_element ".where" space? hash space? {
62
+ def content
63
+ [{html_element.content => hash.content }]
64
+ end
65
+ def description
66
+ "#{html_element.description}, with #{hash.description}"
67
+ end
68
+ }
69
+ end
70
+
71
+ rule check_func
72
+ "." (reserved_with_string / click ) {
73
+ def content
74
+ elements[1].content
75
+ end
76
+ def description
77
+ elements[1].description
78
+ end
79
+ }
80
+ end
81
+
82
+ rule click
83
+ "click" {
84
+ def content
85
+ [:click]
86
+ end
87
+ def description
88
+ ""
89
+ end
90
+ }
91
+ end
92
+
93
+ rule reserved_with_string
94
+ reserved_functions string_params {
95
+ def content
96
+ [{reserved_functions.content => string_params.content }]
97
+ end
98
+ def description
99
+ if reserved_functions.description.include?("set") || reserved_functions.description.include?("select")
100
+ ""
101
+ else
102
+ "#{reserved_functions.description} #{string_params.description}"
103
+ end
104
+ end
105
+ }
106
+ end
107
+
108
+ rule reserved_functions
109
+ ("with_text" / "includes_text" / "set" / "select") {
110
+ def content
111
+ case text_value
112
+ when "with_text"
113
+ :text
114
+ when "includes_text"
115
+ :includes_text
116
+ when "set"
117
+ :set
118
+ when "select"
119
+ :select
120
+ end
121
+ end
122
+ def description
123
+ case text_value
124
+ when "with_text"
125
+ "with text"
126
+ when "includes_text"
127
+ "includes text"
128
+ when "set"
129
+ "set to"
130
+ when "select"
131
+ "select"
132
+ end
133
+ end
134
+ }
135
+ end
136
+
137
+ rule string_params
138
+ space? '(' space? string space? ')' {
139
+ def content
140
+ string.content
141
+ end
142
+ def description
143
+ string.description
144
+ end
145
+ }
146
+ end
147
+
148
+ rule hash
149
+ '(' hash_contents+ ')' {
150
+ def content
151
+ hash = {}
152
+ elements[1].elements.each do |e|
153
+ hash.merge!(e.content)
154
+ end
155
+ hash
156
+ end
157
+ def description
158
+ string = ""
159
+ count = 0
160
+ elements[1].elements.each do |e|
161
+ string << ", " if count > 0
162
+ string << e.description
163
+ count += 1
164
+ end
165
+ string
166
+ end
167
+ }
168
+ end
169
+
170
+ rule hash_contents
171
+ key_value_pair space? ','? space? {
172
+ def content
173
+ key_value_pair.content
174
+ end
175
+ def description
176
+ key_value_pair.description
177
+ end
178
+ }
179
+ end
180
+
181
+ rule key_value_pair
182
+ space? identifier space? ":" space? string space? {
183
+ def content
184
+ {identifier.content => string.content }
185
+ end
186
+ def description
187
+ "#{identifier.description}=#{string.description}"
188
+ end
189
+ }
190
+ end
191
+
192
+ rule single_html_element
193
+ word number {
194
+ def content
195
+ [text_value.to_sym]
196
+ end
197
+ def description
198
+ "#{text_value}"
199
+ end
200
+ }
201
+ end
202
+
203
+ rule html_element
204
+ word number {
205
+ def content
206
+ text_value.to_sym
207
+ end
208
+ def description
209
+ "#{text_value}"
210
+ end
211
+ }
212
+ end
213
+
214
+ rule identifier
215
+ word number {
216
+ def content
217
+ text_value.to_sym
218
+ end
219
+ def description
220
+ text_value
221
+ end
222
+ }
223
+ end
224
+
225
+ rule string
226
+ '"' (!'"' . / '\"')* '"' {
227
+ def content
228
+ eval text_value
229
+ end
230
+ def description
231
+ text_value
232
+ end
233
+ }
234
+ end
235
+
236
+ rule word
237
+ [A-Za-z_]+
238
+ end
239
+
240
+ rule number
241
+ ([0-9]+)?
242
+ end
243
+
244
+ rule space
245
+ [\s]+ {
246
+ def content
247
+ end
248
+
249
+ def description
250
+ end
251
+ }
252
+ end
253
+ end
@@ -0,0 +1,20 @@
1
+ module Hercules
2
+ module Maestro
3
+ class Browser
4
+ attr_reader :browser
5
+ attr_reader :parser
6
+ attr_reader :s_expr
7
+ def initialize(url, browser_name = "firefox", is_headless = false)
8
+ @parser = Hercules::UptimeMonitor::MaestroLangParser.new
9
+ @browser = Hercules::UptimeMonitor::Browser.new(url, browser_name, is_headless)
10
+ end
11
+ def exists?(script)
12
+ @s_expr = @parser.parse(script).first
13
+ @browser.exists? @s_expr
14
+ end
15
+ def close
16
+ @browser.close
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,45 @@
1
+ require 'treetop'
2
+
3
+ module Hercules
4
+ module UptimeMonitor
5
+ class Parser
6
+ def self.parse(data, parser, description = false)
7
+ if data.respond_to? :read
8
+ data = data.read
9
+ end
10
+
11
+ ast = parser.parse data
12
+
13
+ if ast
14
+ return (description ? ast.description : ast.content)
15
+ else
16
+ parser.failure_reason =~ /^(Expected .+) after/m
17
+ raise(Hercules::UptimeMonitor::ParserSyntaxError.new(error: "syntax error"), "syntax error") if $1.blank?
18
+ message =
19
+ "#{$1.gsub("\n", '$NEWLINE')}:" << "\n" <<
20
+ data.lines.to_a[parser.failure_line - 1] << "\n" <<
21
+ "#{'~' * (parser.failure_column - 1)}^"
22
+ raise(Hercules::UptimeMonitor::ParserSyntaxError.new(error: message), message)
23
+ end
24
+ end
25
+ end
26
+
27
+ class MaestroLangParser
28
+ Treetop.load(File.expand_path(File.join(File.dirname(__FILE__), 'maestro')))
29
+ @@maestro_parser = MaestroParser.new
30
+ def parse(data, description = false)
31
+ Hercules::UptimeMonitor::Parser.parse(data, @@maestro_parser, description)
32
+ end
33
+ end
34
+
35
+ class BrowsersLangParser
36
+ Treetop.load(File.expand_path(File.join(File.dirname(__FILE__), 'browsers')))
37
+ @@browsers_parser = BrowsersParser.new
38
+ def parse(data)
39
+ Hercules::UptimeMonitor::Parser.parse(data, @@browsers_parser)
40
+ end
41
+ end
42
+
43
+ class ParserSyntaxError < StandardError; end
44
+ end
45
+ end
@@ -6,6 +6,9 @@ module Ragios
6
6
  attr_reader :success
7
7
  attr_reader :screenshot_url
8
8
  attr_reader :has_screenshot
9
+ attr_reader :browser_info
10
+ attr_reader :s_expr
11
+ attr_reader :validations
9
12
 
10
13
  def initialize
11
14
  @test_result = ActiveSupport::OrderedHash.new
@@ -19,17 +22,20 @@ module Ragios
19
22
  raise(Hercules::UptimeMonitor::NoUrlProvided.new(error: message), message) if @monitor.url.nil?
20
23
  message = "A browser must be provided for uptime_monitor: #{@monitor.monitor}"
21
24
  raise(Hercules::UptimeMonitor::NoBrowserProvided.new(error: message), message) if @monitor.browser.nil?
25
+ @browser_info = Hercules::UptimeMonitor::BrowsersLangParser.new.parse(@monitor.browser)
22
26
  message = "A validation (exists?) must be provided for uptime_monitor: #{@monitor.monitor}"
23
27
  raise(Hercules::UptimeMonitor::NoValidationProvided.new(error: message), message) if @monitor.exists?.nil?
28
+ @s_expr = Hercules::UptimeMonitor::MaestroLangParser.new.parse(@monitor.exists?)
29
+ @validations = Hercules::UptimeMonitor::MaestroLangParser.new.parse(@monitor.exists?, description = true)
30
+ {ok: true}
24
31
  end
25
32
 
26
33
  def test_command?
27
34
  @result_set = []
28
35
  @success = true
29
36
  @has_screenshot = false
30
- browser_reader = Hercules::UptimeMonitor::BrowserReader.new(@monitor.browser)
31
- start_browser(@monitor.url, browser_reader.browser_name, browser_reader.headless)
32
- exists(@monitor.exists?)
37
+ start_browser(@monitor.url, browser_info[:browser], !!browser_info[:headless] )
38
+ exists(@s_expr)
33
39
  @test_result = {results: @result_set}
34
40
  @test_result[:screenshot] = @screenshot_url if @has_screenshot
35
41
  close_browser
@@ -52,28 +58,28 @@ module Ragios
52
58
  end
53
59
 
54
60
  def exists(page_elements)
55
- page_elements.each do |page_element|
56
- if @browser.exists?(page_element)
57
- result!(page_element, true)
58
- else
61
+ for i in 0..(page_elements.length - 1)
62
+ if @browser.exists?(page_elements[i])
63
+ result!(@validations[i], true)
64
+ else
59
65
  take_screenshot
60
- result!(page_element, false)
66
+ result!(@validations[i], false)
61
67
  end
62
68
  end
63
69
  end
64
70
 
65
- def result!(page_element, state)
71
+ def result!(validation, state)
66
72
  @success = false if state == false
67
- result = state ? [page_element, "exists_as_expected"] : [page_element, "does_not_exist_as_expected"]
73
+ result = state ? [validation, "exists_as_expected"] : [validation, "does_not_exist_as_expected"]
68
74
  @result_set << result
69
75
  end
70
76
 
71
77
  def take_screenshot
72
- if RAGIOS_HERCULES_ENABLE_SCREENSHOTS && not(@monitor.disable_screenshots) && not(@has_screenshot)
73
- @screenshot_url = @browser.capture_screenshot
78
+ if RAGIOS_HERCULES_ENABLE_SCREENSHOTS && not(@monitor.disable_screenshots) && not(@has_screenshot)
79
+ @screenshot_url = @browser.capture_screenshot
74
80
  @has_screenshot = true
75
81
  end
76
- end
82
+ end
77
83
  end
78
84
  end
79
85
  end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hercules::UptimeMonitor::BrowsersLangParser do
4
+ before(:all) do
5
+ @parser = Hercules::UptimeMonitor::BrowsersLangParser.new
6
+ end
7
+ it "parses valid browser names in the format - [\S]+" do
8
+ @parser.parse("firefox").should == {browser: "firefox", headless: false}
9
+ @parser.parse(" firefox ").should == {browser: "firefox", headless: false}
10
+ @parser.parse("_,0any_non_whitespace").should == {browser: "_,0any_non_whitespace", headless: false}
11
+ end
12
+ it "raises an exception for invalid browser name" do
13
+ expect { @parser.parse("\n") }.to raise_error
14
+ expect { @parser.parse(" ") }.to raise_error(Hercules::UptimeMonitor::ParserSyntaxError)
15
+ end
16
+ it "parses valid specification for headless browser operation" do
17
+ @parser.parse("firefox headless").should == {browser: "firefox", headless: true}
18
+ @parser.parse(" firefox headless ").should == {browser: "firefox", headless: true}
19
+ @parser.parse(" firefox headless ").should == {browser: "firefox", headless: true}
20
+
21
+ browser = <<-eos
22
+ chrome headless
23
+ eos
24
+ @parser.parse(browser).should == {browser: "chrome", headless: true}
25
+
26
+ browser = <<-eos
27
+ chrome
28
+
29
+ headless
30
+ eos
31
+ @parser.parse(browser).should == {browser: "chrome", headless: true}
32
+ end
33
+ it "raises an exception for invalid headless assignment" do
34
+ expect { @parser.parse("anybrowser invalid") }.to raise_error(Hercules::UptimeMonitor::ParserSyntaxError)
35
+ end
36
+ end
@@ -0,0 +1,153 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hercules::UptimeMonitor::MaestroLangParser do
4
+ before(:all) do
5
+ @parser = Hercules::UptimeMonitor::MaestroLangParser.new
6
+ end
7
+ it "it returns correct s expression for html elements" do
8
+ validations = <<-eos
9
+ h1
10
+ div
11
+ anything
12
+ eos
13
+ @parser.parse(validations).should == [[:h1], [:div], [:anything]]
14
+ end
15
+ it "it returns correct description for html elements" do
16
+ validations = <<-eos
17
+ h1
18
+ div
19
+ anything
20
+ eos
21
+ @parser.parse(validations, description = true).should == ["h1", "div", "anything"]
22
+ end
23
+ it "raises exceptions for incorrect html element format" do
24
+ expect{ @parser.parse("1hi") }.to raise_error(Hercules::UptimeMonitor::ParserSyntaxError)
25
+ expect{ @parser.parse(" 1hi ") }.to raise_error(Hercules::UptimeMonitor::ParserSyntaxError)
26
+ end
27
+ it "returns the correct s expression for element validation" do
28
+ validations = <<-eos
29
+ div.where( class: "box_content")
30
+ div.where( id: "test", class: "test-section" )
31
+ link.where ( href: "https://www.southmunn.com/aboutus")
32
+ text_field.where(id: "search")
33
+ eos
34
+ @parser.parse(validations).should == [
35
+ [div: {class: "box_content"}],
36
+ [div: {id:"test", class: "test-section"}],
37
+ [link: {href: "https://www.southmunn.com/aboutus"}],
38
+ [text_field: {id: "search"}],
39
+ ]
40
+ end
41
+ it "returns the correct description for element validation" do
42
+ validations = <<-eos
43
+ div.where(class: "box_content")
44
+ div.where(id: "test", class: "test-section" )
45
+ link.where(href: "https://www.southmunn.com/aboutus")
46
+ text_field.where(id:"search")
47
+ eos
48
+ @parser.parse(validations, description = true).should == [
49
+ 'div, with class="box_content"',
50
+ 'div, with id="test", class="test-section"',
51
+ 'link, with href="https://www.southmunn.com/aboutus"',
52
+ 'text_field, with id="search"'
53
+ ]
54
+ end
55
+ it "returns the correct s expression for text validations" do
56
+ validations = <<-eos
57
+ title.with_text( "Welcome to my site" )
58
+ title.includes_text ( "Welcome")
59
+ div.where(class: "box_content").includes_text( "SouthMunn is a Website")
60
+ title.includes_text("ruby").includes_text ("Search Results")
61
+ eos
62
+ @parser.parse(validations).should == [
63
+ [:title, [text: "Welcome to my site"]],
64
+ [:title, [includes_text: "Welcome"]],
65
+ [{div: {class: "box_content"}}, [includes_text: "SouthMunn is a Website"]],
66
+ [:title, [includes_text: "ruby"], [includes_text: "Search Results"]]
67
+ ]
68
+ end
69
+ it "returns the correct description for text validations" do
70
+ validations = <<-eos
71
+ title.with_text("Welcome to my site")
72
+ title.includes_text("Welcome")
73
+ div.where(class: "box_content").includes_text("SouthMunn is a Website")
74
+ title.includes_text("ruby").includes_text("Search Results")
75
+ eos
76
+ @parser.parse(validations, description = true).should == [
77
+ 'title, with text "Welcome to my site"',
78
+ 'title, includes text "Welcome"',
79
+ 'div, with class="box_content", includes text "SouthMunn is a Website"',
80
+ 'title, includes text "ruby", includes text "Search Results"'
81
+ ]
82
+ end
83
+ it "returns the correct s expression for actions" do
84
+ validations = <<-eos
85
+ text_area.where(name:"longtext").set("In a world...")
86
+ select_list.where(name: "mydropdown").select("Old Cheese")
87
+ radio.where(name: "group1", value: "Milk").click
88
+ button.where(value: "Add to Cart").click
89
+ button.click
90
+ eos
91
+ @parser.parse(validations).should == [
92
+ [{text_area: {name: "longtext"}}, [set: "In a world..."]],
93
+ [{select_list: {name: "mydropdown"}},[select: "Old Cheese"]],
94
+ [{radio: {name: "group1", value: "Milk"}}, [:click]],
95
+ [{button: {value: "Add to Cart"}}, [:click]],
96
+ [:button, [:click]]
97
+ ]
98
+ end
99
+ it "returns the correct description for validations within actions" do
100
+ validations = <<-eos
101
+ text_area.where(name:"longtext").set("In a world...")
102
+ select_list.where(name: "mydropdown").select("Old Cheese")
103
+ radio.where(name: "group1", value: "Milk").click
104
+ button.where(value: "Add to Cart").click
105
+ button.click
106
+ eos
107
+ @parser.parse(validations, description = true).should == [
108
+ 'text_area, with name="longtext"',
109
+ 'select_list, with name="mydropdown"',
110
+ 'radio, with name="group1", value="Milk"',
111
+ 'button, with value="Add to Cart"',
112
+ 'button'
113
+ ]
114
+ end
115
+ it "returns the correct s expression for waiting" do
116
+ validations = <<-eos
117
+ wait_for title.with_text("Obi Akubue")
118
+ wait_for title.includes_text("ruby").includes_text("Search Results")
119
+ wait_for text_field.where(id: "s").set("ruby")
120
+ wait_for div.where( class: "box_content")
121
+ eos
122
+ @parser.parse(validations).should == [
123
+ [wait_until_exists?: [:title,[text: "Obi Akubue"]]],
124
+ [wait_until_exists?: [:title, [includes_text: "ruby"], [includes_text: "Search Results"]]],
125
+ [wait_until_exists?: [{text_field: {id: "s"}}, [set: "ruby"]]],
126
+ [wait_until_exists?: [div: {class: "box_content"}]]
127
+ ]
128
+ end
129
+ it "returns the correct description for waiting" do
130
+ validations = <<-eos
131
+ wait_for title.with_text("Obi Akubue")
132
+ wait_for title.includes_text("ruby").includes_text("Search Results")
133
+ wait_for text_field.where(id: "s").set("ruby")
134
+ wait_for div.where( class: "box_content")
135
+ eos
136
+ @parser.parse(validations, description = true).should == [
137
+ 'waited, title, with text "Obi Akubue"',
138
+ 'waited, title, includes text "ruby", includes text "Search Results"',
139
+ 'waited, text_field, with id="s"',
140
+ 'waited, div, with class="box_content"'
141
+ ]
142
+ end
143
+ it "detects syntax errors" do
144
+ expect{ @parser.parse(".anything") }.to raise_error(Hercules::UptimeMonitor::ParserSyntaxError)
145
+ expect { @parser.parse("h1.where") }.to raise_error(Hercules::UptimeMonitor::ParserSyntaxError)
146
+ expect { @parser.parse("anything.anything") }.to raise_error(Hercules::UptimeMonitor::ParserSyntaxError)
147
+ expect { @parser.parse("div.where(\"test\" => \"test\")") }.to raise_error(Hercules::UptimeMonitor::ParserSyntaxError)
148
+ expect { @parser.parse("div.where(:test => \"test\")") }.to raise_error(Hercules::UptimeMonitor::ParserSyntaxError)
149
+ expect { @parser.parse("title.with_text(Welcome to my site\")") }.to raise_error(Hercules::UptimeMonitor::ParserSyntaxError)
150
+ end
151
+ end
152
+
153
+
@@ -33,73 +33,47 @@ describe Ragios::Plugin::UptimeMonitor do
33
33
  monitor = {browser: :browser, url: :url}
34
34
  expect{@uptime_monitor.init(monitor)}.to raise_error(Hercules::UptimeMonitor::NoValidationProvided)
35
35
  end
36
- it "returns true if page element exists" do
37
- monitor = {browser: :browser, exists?: :exists, url: :url}
38
- @uptime_monitor.init(monitor)
39
- @uptime_monitor.start_browser("http://obi-akubue.org","firefox", headless = true)
40
- page_element = [:title]
41
- @uptime_monitor.exists([page_element])
42
- @uptime_monitor.test_result.should == {:results => [[page_element, "exists_as_expected"]]}
43
- @uptime_monitor.has_screenshot.should == nil #since no test_command? was run
44
- @uptime_monitor.screenshot_url.should == nil
45
- @uptime_monitor.success.should == nil #since no test_command? was run
46
- @uptime_monitor.close_browser
47
- end
48
- it "returns false if page element don't exists" do
49
- monitor = {browser: :browser, exists?: :exists, url: :url}
50
- @uptime_monitor.init(monitor)
51
- @uptime_monitor.start_browser("http://obi-akubue.org","firefox", headless = true)
52
- page_element = [:title, [text: "dont_exist"]]
53
- @uptime_monitor.exists([page_element])
54
- @uptime_monitor.test_result.should == {:results => [[page_element, "does_not_exist_as_expected"]]}
55
- if @uptime_monitor.has_screenshot
56
- !!(/^.*\.png$/.match(@uptime_monitor.screenshot_url)).should == true
57
- end
58
- @uptime_monitor.success.should == false
59
- @uptime_monitor.close_browser
60
- end
61
36
  it "runs a test that passes" do
62
- page_element = [:title]
63
- monitor = {url: "http://obi-akubue.org",
64
- browser: ["firefox", headless: true],
65
- exists?: [page_element]
66
- }
37
+ monitor = {
38
+ url: "http://obi-akubue.org",
39
+ browser: "firefox headless",
40
+ exists?: "title"
41
+ }
67
42
  @uptime_monitor.init(monitor)
68
43
  @uptime_monitor.test_command?.should == true
69
- @uptime_monitor.test_result.should == {:results => [[page_element, "exists_as_expected"]]}
44
+ @uptime_monitor.test_result.should == {:results => [["title", "exists_as_expected"]]}
70
45
  @uptime_monitor.has_screenshot.should == false
71
46
  @uptime_monitor.screenshot_url.should == nil
72
- @uptime_monitor.success.should == true
47
+ @uptime_monitor.success.should == true
73
48
  @uptime_monitor.close_browser
74
49
  end
75
50
  it "runs a test that fails" do
76
- page_element = [:title, [text: "dont_exist"]]
77
- monitor = {url: "http://obi-akubue.org",
78
- browser: ["firefox", headless: true],
79
- exists?: [page_element]
80
- }
51
+ monitor = {
52
+ url: "http://obi-akubue.org",
53
+ browser: "firefox headless",
54
+ exists?: 'title.with_text("dont_exist")'
55
+ }
81
56
  @uptime_monitor.init(monitor)
82
57
  @uptime_monitor.test_command?.should == false
83
- @uptime_monitor.test_result.should include(:results => [[page_element, "does_not_exist_as_expected"]])
58
+ @uptime_monitor.test_result.first.should == [:results, [["title, with text \"dont_exist\"", "does_not_exist_as_expected"]]]
84
59
  if @uptime_monitor.has_screenshot
85
60
  !!(/^.*\.png$/.match(@uptime_monitor.screenshot_url)).should == true
86
61
  end
87
- @uptime_monitor.success.should == false
62
+ @uptime_monitor.success.should == false
88
63
  @uptime_monitor.close_browser
89
64
  end
90
- it "can disable screenshot capture when a test fails for individual monitors" do
91
- page_element = [:title, [text: "dont_exist"]]
65
+ it "can disable screenshot capture when a test fails for individual monitors" do
92
66
  monitor = {
93
67
  url: "http://obi-akubue.org",
94
- browser: ["firefox", headless: true],
95
- exists?: [page_element],
68
+ browser: "firefox headless",
69
+ exists?: 'title.with_text("dont_exist")',
96
70
  disable_screenshots: true
97
71
  }
98
72
  @uptime_monitor.init(monitor)
99
73
  @uptime_monitor.test_command?.should == false
100
74
  @uptime_monitor.has_screenshot.should == false
101
75
  @uptime_monitor.screenshot_url.should == nil
102
- @uptime_monitor.success.should == false
76
+ @uptime_monitor.success.should == false
103
77
  @uptime_monitor.close_browser
104
78
  end
105
79
  end