Class: StreamCi::Ruby::Rspec::Runner

Inherits:
RSpec::Core::Runner
  • Object
show all
Defined in:
lib/stream_ci/ruby/rspec/runner.rb

Instance Method Summary collapse

Instance Method Details

#run_specs(example_groups) ⇒ Object



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
54
55
56
57
58
59
# File 'lib/stream_ci/ruby/rspec/runner.rb', line 28

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' } }
      response = HTTParty.get('https://api.streamci.com/v1/tests/next', opts)

      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 ?
        if response.code == 200
          load response.body
          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



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/stream_ci/ruby/rspec/runner.rb', line 8

def setup(err, out)
  @configuration.error_stream = err
  @configuration.output_stream = out if @configuration.output_stream == $stdout
  @options.configure(@configuration)

  root_path = StreamCi::Ruby::Rspec.root
  test_manifest = Dir["#{root_path}/**/*_spec.rb"].map do |fp|
    fp.gsub("#{root_path}/", '')
  end

  opts = { query: { api_key: '12345', branch: 'test', build: '1', test_manifest: test_manifest } }
  HTTParty.post('https://api.streamci.com/v1/tests/next', opts)

  # TODO
  # * What do these commands do / mean?
  #
  # @configuration.load_spec_files
  # @world.announce_filters
end