Class: Jasmine::Sauce::CI::RspecReporter
- Inherits:
-
Object
- Object
- Jasmine::Sauce::CI::RspecReporter
- Defined in:
- lib/jasmine-selenium-sauce/rspec_reporter.rb
Instance Method Summary collapse
- #declare_spec(parent, spec) ⇒ Object
- #declare_suites(suites) ⇒ Object
- #process_children(parent, children) ⇒ Object
- #report(results) ⇒ Object
- #report_spec(spec_id) ⇒ Object
Instance Method Details
#declare_spec(parent, spec) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/jasmine-selenium-sauce/rspec_reporter.rb', line 38 def declare_spec(parent, spec) me = self example_name = spec["name"] parent.it example_name, {} do me.report_spec(spec["id"]) end end |
#declare_suites(suites) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/jasmine-selenium-sauce/rspec_reporter.rb', line 18 def declare_suites(suites) suites.each do |suite| group = example_group(suite["name"]) {} process_children(group, suite["children"]) end end |
#process_children(parent, children) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/jasmine-selenium-sauce/rspec_reporter.rb', line 25 def process_children(parent, children) children.each do |suite_or_spec| type = suite_or_spec["type"] if type == "suite" process_children(parent.describe(suite_or_spec["name"]), suite_or_spec["children"]) elsif type == "spec" declare_spec(parent, suite_or_spec) else raise "unknown type #{type} for #{suite_or_spec.inspect}" end end end |
#report(results) ⇒ Object
13 14 15 16 |
# File 'lib/jasmine-selenium-sauce/rspec_reporter.rb', line 13 def report(results) @results = results declare_suites(@results.suites) end |
#report_spec(spec_id) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/jasmine-selenium-sauce/rspec_reporter.rb', line 46 def report_spec(spec_id) spec_results = results_for(spec_id) out = "" = spec_results['messages'].each do || case when ["type"] == "log" puts ["text"] puts "\n" else unless ["message"] =~ /^Passed.$/ STDERR << ["message"] STDERR << "\n" out << ["message"] out << "\n" end if !["passed"] && ["trace"]["stack"] stack_trace = ["trace"]["stack"].gsub(/<br \/>/, "\n").gsub(/<\/?b>/, " ") STDERR << stack_trace.gsub(/\(.*\)@http:\/\/localhost:[0-9]+\/specs\//, "/spec/") STDERR << "\n" end end end fail out unless spec_results['result'] == 'passed' puts out unless out.empty? end |