Skip to content

Commit

Permalink
Minor fixes (#7)
Browse files Browse the repository at this point in the history
* Add missing error message

* Minor fix
  • Loading branch information
frbk authored May 18, 2017
1 parent 16a3dde commit b2c7ace
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/tmj_formatter/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module TMJFormatter
VERSION = '0.1.2'.freeze
VERSION = '0.1.3'.freeze
end
19 changes: 10 additions & 9 deletions lib/tmj_result_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class TMJResultFormatter < RSpec::Core::Formatters::BaseFormatter

def start(_notification)
@options = DEFAULT_RESULT_FORMATTER_OPTIONS.merge(RSpec.configuration.tmj_result_formatter_options)
@client = TMJ::Client.new
if @options[:run_only_found_tests]
begin
@client = TMJ::Client.new
test_run_data = @client.TestRun.find(TMJ.config.test_run_id)
raise TMJ::TestRunError, test_run_data unless test_run_data.code == 200
rescue => e
Expand Down Expand Up @@ -39,10 +39,11 @@ def example_failed(notification)

private

def post_result(example)
def post_result(example) # TODO: refactor
return unless @options[:post_results]
return if test_id(example).empty?
begin
if TMJ.config.test_run_id
if TMJ.config.test_run_id && @options[:run_only_found_tests]
response = @client.TestRun.create_new_test_run_result(test_id(example), with_steps(example))
raise TMJ::TestRunError, response unless response.code == 201
else
Expand All @@ -57,12 +58,12 @@ def post_result(example)

def with_steps(example) # TODO: Make this better
{
test_case: test_id(example),
status: status(example.metadata[:execution_result]),
environment: fetch_environment(example),
comment: comment(example.metadata),
execution_time: run_time(example.metadata[:execution_result]),
script_results: steps(example.metadata)
test_case: test_id(example),
status: status(example.metadata[:execution_result]),
environment: fetch_environment(example),
comment: comment(example.metadata),
execution_time: run_time(example.metadata[:execution_result]),
script_results: steps(example.metadata)
}.delete_if { |_k, v| v.nil? }
end

Expand Down

0 comments on commit b2c7ace

Please sign in to comment.