Class: Opal::RSpec::Runner
- Inherits:
-
Object
- Object
- Opal::RSpec::Runner
- Defined in:
- opal/opal/rspec/runner.rb
Class Method Summary collapse
Instance Method Summary collapse
- #finish ⇒ Object
-
#initialize(options = {}) ⇒ Runner
constructor
A new instance of Runner.
- #run(err = $stdout, out = $stdout) ⇒ Object
- #run_async_examples(&block) ⇒ Object
- #run_examples ⇒ Object
- #start ⇒ Object
Constructor Details
Class Method Details
.autorun ⇒ Object
22 23 24 25 26 27 28 |
# File 'opal/opal/rspec/runner.rb', line 22 def autorun if browser? `setTimeout(function() { #{Runner.new.run} }, 0)` else # phantom Runner.new.run end end |
.browser? ⇒ Boolean
6 7 8 |
# File 'opal/opal/rspec/runner.rb', line 6 def browser? `typeof(document) !== "undefined"` end |
.default_formatter ⇒ Object
14 15 16 17 18 19 20 |
# File 'opal/opal/rspec/runner.rb', line 14 def default_formatter if phantom? TextFormatter else # browser BrowserFormatter end end |
.phantom? ⇒ Boolean
10 11 12 |
# File 'opal/opal/rspec/runner.rb', line 10 def phantom? `typeof(phantom) !== 'undefined' || typeof(OPAL_SPEC_PHANTOM) !== 'undefined'` end |
Instance Method Details
#finish ⇒ Object
63 64 65 66 |
# File 'opal/opal/rspec/runner.rb', line 63 def finish @configuration.run_hook(:after, :suite) @reporter.finish end |
#run(err = $stdout, out = $stdout) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'opal/opal/rspec/runner.rb', line 37 def run(err=$stdout, out=$stdout) @configuration.error_stream = err @configuration.output_stream ||= out self.start run_examples run_async_examples do self.finish end end |
#run_async_examples(&block) ⇒ Object
53 54 55 |
# File 'opal/opal/rspec/runner.rb', line 53 def run_async_examples(&block) AsyncRunner.new(self, @reporter, block).run end |
#run_examples ⇒ Object
49 50 51 |
# File 'opal/opal/rspec/runner.rb', line 49 def run_examples @world.example_groups.map { |g| g.run(@reporter) }.all? end |
#start ⇒ Object
57 58 59 60 61 |
# File 'opal/opal/rspec/runner.rb', line 57 def start @reporter = @configuration.reporter @reporter.start(@world.example_count) @configuration.run_hook(:before, :suite) end |