Class: Henry::Dummy
- Inherits:
-
Object
- Object
- Henry::Dummy
- Defined in:
- lib/henry/dummy.rb
Overview
Henry Dummy class holding methods to emulate testing behaviours.
Defined Under Namespace
Modules: BrowserException
Instance Method Summary collapse
-
#browser(driver, url, text) ⇒ Object
Opens a browser, navigate the given url and asserts the page title.
-
#cpu(seconds, interval = nil) ⇒ Object
Produces CPU usage fot the given amount of time.
-
#file(name, path, content) ⇒ Object
Creates a file (and its path) adn writes the given content.
- #gird ⇒ Object
-
#initialize(task) ⇒ Dummy
constructor
A new instance of Dummy.
- #log ⇒ Object
- #map ⇒ Object
- #memory ⇒ Object
-
#message(message) ⇒ Object
Overwrites the execution message with the give value.
-
#return_code(code) ⇒ Object
Overwrites the execution code with the given value.
-
#runtime_error ⇒ Object
Raises an exception.
-
#sleep(seconds) ⇒ Object
Sleeps the process for the given amount for seconds.
Constructor Details
#initialize(task) ⇒ Dummy
Returns a new instance of Dummy.
20 21 22 |
# File 'lib/henry/dummy.rb', line 20 def initialize(task) @task = task end |
Instance Method Details
#browser(driver, url, text) ⇒ Object
Opens a browser, navigate the given url and asserts the page title.
29 30 31 32 33 34 35 36 37 |
# File 'lib/henry/dummy.rb', line 29 def browser(driver, url, text) navigator = Henry::Navigator.new(driver) title = navigator.navigate(url).title navigator.close raise BrowserException::TitleMismatch if !title.include?(text) end |
#cpu(seconds, interval = nil) ⇒ Object
Produces CPU usage fot the given amount of time.
43 44 45 46 47 48 49 50 51 |
# File 'lib/henry/dummy.rb', line 43 def cpu(seconds, interval=nil) Timeout::timeout(seconds) do loop do slow_down(interval) if interval end end rescue Timeout::Error end |
#file(name, path, content) ⇒ Object
Creates a file (and its path) adn writes the given content.
58 59 60 61 62 63 64 |
# File 'lib/henry/dummy.rb', line 58 def file(name, path, content) FileUtils.mkpath("#{Henry::Environment.config['output_directory']}/#{path}") File.open("#{Henry::Environment.config['output_directory']}/#{path}/#{name}", 'w') do |file| file.write(content) end end |
#gird ⇒ Object
66 67 |
# File 'lib/henry/dummy.rb', line 66 def gird end |
#log ⇒ Object
82 83 |
# File 'lib/henry/dummy.rb', line 82 def log end |
#map ⇒ Object
69 70 |
# File 'lib/henry/dummy.rb', line 69 def map end |
#memory ⇒ Object
72 73 |
# File 'lib/henry/dummy.rb', line 72 def memory end |
#message(message) ⇒ Object
Overwrites the execution message with the give value.
78 79 80 |
# File 'lib/henry/dummy.rb', line 78 def () @task.execution. = end |
#return_code(code) ⇒ Object
Overwrites the execution code with the given value.
88 89 90 |
# File 'lib/henry/dummy.rb', line 88 def return_code(code) @task.execution.code = code end |
#runtime_error ⇒ Object
Raises an exception
93 94 95 |
# File 'lib/henry/dummy.rb', line 93 def runtime_error raise Exception end |
#sleep(seconds) ⇒ Object
Sleeps the process for the given amount for seconds.
100 101 102 |
# File 'lib/henry/dummy.rb', line 100 def sleep(seconds) Kernel.sleep(seconds) end |