Class: Keeptesting::BrowserConsole
- Inherits:
-
Object
- Object
- Keeptesting::BrowserConsole
- Defined in:
- lib/keeptesting/browser_console.rb
Constant Summary collapse
- RESULT_FILE_PATH =
"/tmp/keeptesting-state.txt"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ BrowserConsole
constructor
A new instance of BrowserConsole.
- #start_console ⇒ Object
- #store_last_test_summary(success, output) ⇒ Object
- #store_running_status ⇒ Object
- #testrun(options) ⇒ Object
- #watch_files(options) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ BrowserConsole
Returns a new instance of BrowserConsole.
11 12 13 14 |
# File 'lib/keeptesting/browser_console.rb', line 11 def initialize(={}) watch_files() start_console end |
Class Method Details
.retrieve_last_test_summary ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/keeptesting/browser_console.rb', line 35 def self.retrieve_last_test_summary file = File.open(RESULT_FILE_PATH, "rb") contents = file.read result = contents.lines.first output = contents.lines.to_a[1..-1].join("\n") return result, output end |
Instance Method Details
#start_console ⇒ Object
69 70 71 72 73 |
# File 'lib/keeptesting/browser_console.rb', line 69 def start_console webconsole_path = File.dirname(__FILE__) + '/../../webconsole.rb' puts "\n\n\nWeb console starting up, goto http://localhost:5000\n\n\n" puts `ruby #{webconsole_path} -e development -p 5000` end |
#store_last_test_summary(success, output) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/keeptesting/browser_console.rb', line 24 def store_last_test_summary(success, output) File.open RESULT_FILE_PATH, "w" do |filebody| if success filebody.write("Success\n") else filebody.write("Failure\n") end filebody.write(output) end end |
#store_running_status ⇒ Object
18 19 20 21 22 |
# File 'lib/keeptesting/browser_console.rb', line 18 def store_running_status File.open RESULT_FILE_PATH, "w" do |filebody| filebody.write("Running\n") end end |
#testrun(options) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/keeptesting/browser_console.rb', line 45 def testrun() store_running_status cmd = [:test_command] test_output = `#{cmd} 2>&1` test_succeeded = Keeptesting::Common::test_success?(test_output, [:failure_regex]) store_last_test_summary(test_succeeded, test_output) end |
#watch_files(options) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/keeptesting/browser_console.rb', line 53 def watch_files() Thread.new do console = self console.testrun() FSSM.monitor do [:watched_paths].each do |watched_path| path watched_path do update {|base, relative| console.testrun()} delete {|base, relative| console.testrun()} create {|base, relative| console.testrun()} end end end end end |