Class: JazzMoney::RspecThread
- Inherits:
-
Object
- Object
- JazzMoney::RspecThread
- Defined in:
- lib/jazz_money/rspec_thread.rb
Instance Attribute Summary collapse
-
#jasmine_reporter ⇒ Object
readonly
Returns the value of attribute jasmine_reporter.
Class Method Summary collapse
Instance Method Summary collapse
- #declare_spec(parent, spec) ⇒ Object
- #declare_suite(parent, suite) ⇒ Object
- #declare_suites ⇒ Object
-
#initialize(suites, jasmine_reporter) ⇒ RspecThread
constructor
A new instance of RspecThread.
- #report_spec(spec_results) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(suites, jasmine_reporter) ⇒ RspecThread
Returns a new instance of RspecThread.
16 17 18 19 |
# File 'lib/jazz_money/rspec_thread.rb', line 16 def initialize(suites, jasmine_reporter) @suites = suites @jasmine_reporter = jasmine_reporter end |
Instance Attribute Details
#jasmine_reporter ⇒ Object (readonly)
Returns the value of attribute jasmine_reporter.
6 7 8 |
# File 'lib/jazz_money/rspec_thread.rb', line 6 def jasmine_reporter @jasmine_reporter end |
Class Method Details
.start(suites, jasmine_reporter) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/jazz_money/rspec_thread.rb', line 8 def self.start(suites, jasmine_reporter) t = Thread.start do me = new(suites, jasmine_reporter) me.run end t end |
Instance Method Details
#declare_spec(parent, spec) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/jazz_money/rspec_thread.rb', line 49 def declare_spec(parent, spec) me = self example_name = spec["name"] spec_id = spec['id'] parent.it example_name do while me.jasmine_reporter.results[spec_id].nil? sleep 0.2 end me.report_spec(me.jasmine_reporter.results[spec_id]) end end |
#declare_suite(parent, suite) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/jazz_money/rspec_thread.rb', line 33 def declare_suite(parent, suite) me = self parent.describe suite["name"] do suite["children"].each do |suite_or_spec| type = suite_or_spec["type"] if type == "suite" me.declare_suite(self, suite_or_spec) elsif type == "spec" me.declare_spec(self, suite_or_spec) else raise "unknown type #{type} for #{suite_or_spec.inspect}" end end end end |
#declare_suites ⇒ Object
26 27 28 29 30 31 |
# File 'lib/jazz_money/rspec_thread.rb', line 26 def declare_suites me = self @suites.each do |suite| declare_suite(self, suite) end end |
#report_spec(spec_results) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/jazz_money/rspec_thread.rb', line 61 def report_spec(spec_results) if (spec_results['result'] != 'passed') = spec_results['messages'].reject {|| ["message"] =~ /Passed/} = [] .each do || << ["message"] js_stack_lines = ["stack_trace"].split("\n").select {|stack_line| stack_line =~ /spec\/javascript/} js_stack_lines.each {|stack_line| << stack_line.gsub("()@", "./")} end Spec::Expectations.fail_with(.join("\n")) end end |
#run ⇒ Object
21 22 23 24 |
# File 'lib/jazz_money/rspec_thread.rb', line 21 def run declare_suites Spec::Runner.run end |