Class: Jasminerice::Runner
- Inherits:
-
Object
- Object
- Jasminerice::Runner
- Includes:
- Capybara::DSL
- Defined in:
- lib/jasminerice-runner.rb,
lib/jasminerice-runner/runner.rb,
lib/jasminerice-runner/version.rb
Constant Summary collapse
- VERSION =
"0.0.4"
Instance Method Summary collapse
- #capybara_driver ⇒ Object
- #get_results ⇒ Object
-
#initialize(environment) ⇒ Runner
constructor
A new instance of Runner.
- #jasmine_url ⇒ Object
- #report_failures(failures) ⇒ Object
- #run ⇒ Object
- #wait_for_finished ⇒ Object
Constructor Details
#initialize(environment) ⇒ Runner
Returns a new instance of Runner.
5 6 7 |
# File 'lib/jasminerice-runner/runner.rb', line 5 def initialize(environment) @environment = environment end |
Instance Method Details
#capybara_driver ⇒ Object
9 10 11 |
# File 'lib/jasminerice-runner/runner.rb', line 9 def self.class. || :selenium end |
#get_results ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/jasminerice-runner/runner.rb', line 40 def get_results { passed: page.evaluate_script("window.jasmineRiceReporter.results.passedCount"), failed: page.evaluate_script("window.jasmineRiceReporter.results.failedCount"), total: page.evaluate_script("window.jasmineRiceReporter.results.totalCount"), failures: page.evaluate_script("window.jasmineRiceReporter.failedSpecs") } end |
#jasmine_url ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/jasminerice-runner/runner.rb', line 31 def jasmine_url url = "/jasmine" if @environment.present? url += "?environment=#{@environment}" end url end |
#report_failures(failures) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/jasminerice-runner/runner.rb', line 49 def report_failures(failures) puts 'Jasmine failures: ' for suiteName,suiteFailures in failures puts " " + suiteName + "\n" for specName,specFailures in suiteFailures puts " " + specName + "\n" for specFailure in specFailures puts " " + specFailure + "\n" end end puts "\n" end end |
#run ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/jasminerice-runner/runner.rb', line 13 def run Capybara.default_driver = visit jasmine_url print "Running jasmine specs" wait_for_finished results = get_results puts "Jasmine results - Passed: #{results[:passed]} Failed: #{results[:failed]} Total: #{results[:total]}" failures = results[:failures] if failures.size == 0 puts "Jasmine specs passed, yay!" else report_failures(failures) raise "Jasmine specs failed" end end |
#wait_for_finished ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/jasminerice-runner/runner.rb', line 63 def wait_for_finished reporter = page.evaluate_script("window.jasmineRiceReporter") if reporter.nil? if @environment.present? filename = "#{@environment}_spec.js" else filename = "spec.js" end puts "\njasmineRiceReporter not defined! Check your configuration to make\n" + "sure that #{filename} exists and that jasminerice_reporter is included." raise "Reporter not found" end start = Time.now while true break if page.evaluate_script("window.jasmineRiceReporter.finished") sleep 1 print "." end print "\n" end |