Class: StreamCi::Ruby::Rspec::Runner
- Inherits:
-
RSpec::Core::Runner
- Object
- RSpec::Core::Runner
- StreamCi::Ruby::Rspec::Runner
- Defined in:
- lib/stream_ci/ruby/rspec/runner.rb
Instance Method Summary collapse
Instance Method Details
#run_specs(example_groups) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/stream_ci/ruby/rspec/runner.rb', line 55 def run_specs(example_groups) examples_count = @world.example_count(example_groups) success = @configuration.reporter.report(examples_count) do |reporter| @configuration.with_suite_hooks do # TODO # * what does [email protected]_example_failure return? # * what does @configuration.failure_exit_code return? @no_failures = true opts = { query: { api_key: '12345', branch: 'test', build: '1' } } stream_ci_url = ENV['STREAM_CI_URL'] || 'https://api.streamci.com' response = HTTParty.get("#{stream_ci_url}/v1/tests/next", opts) binding.pry until response.code == 204 || response.code >= 300 do # should we clear the world / example groups before each one? # will that mess up reporting? # # does this need to be the full path or just spec/some/spec/path ? binding.pry if response.code == 200 puts "Running #{response.body}" binding.pry load JSON.parse(response.body)['test'] unless @world.example_groups.last.run(reporter) @no_failures = false end end end @no_failures end end && !@world.non_example_failure success ? 0 : @configuration.failure_exit_code end |
#setup(err, out) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/stream_ci/ruby/rspec/runner.rb', line 10 def setup(err, out) @configuration.error_stream = err @configuration.output_stream = out if @configuration.output_stream == $stdout .configure(@configuration) @configuration.output_stream.print( "#\n# Preparing test manifest to send to StreamCI\n#\n" ) t1 = Time.now project_root = Rails.root.to_s # this needs to be setup via a config option, as non-rails apps might use this spec_root = '/spec' # pull from rspec config? test_manifest = Dir["#{project_root}#{spec_root}/**/*_spec.rb"].map do |fp| fp.gsub("#{project_root}/", '') end # this does not currently handle directories -- need to fix. given_files_or_directories = .args if given_files_or_directories test_manifest = test_manifest & given_files_or_directories end opts = { query: { api_key: '12345', branch: 'test', build: '1', test_manifest: test_manifest } } stream_ci_url = ENV['STREAM_CI_URL'] || 'https://api.streamci.com' HTTParty.post("#{stream_ci_url}/v1/tests", opts) t2 = Time.now @configuration.output_stream.print "#\n# Test manifest sent to StreamCI - (#{((t2 - t1) * 1000).round} ms)\n#\n" # TODO # * What do these commands do / mean? # # @configuration.load_spec_files # @world.announce_filters end |