Class: LearnTest::Strategies::Rspec
Instance Attribute Summary
#options, #runner
Instance Method Summary
collapse
#argv, #check_dependencies, #die, #initialize, #learn_oauth_token, #push_results?, #run_install, #user_id, #username
Instance Method Details
#cleanup ⇒ Object
64
65
66
|
# File 'lib/learn_test/strategies/rspec.rb', line 64
def cleanup
FileUtils.rm('.results.json') if File.exist?('.results.json')
end
|
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/learn_test/strategies/rspec.rb', line 12
def configure
if format_option_present?
if dot_rspec.any? {|dot_opt| dot_opt.match(/--format|-f/)}
argv << dot_rspec.reject {|dot_opt| dot_opt.match(/--format|-f/)}
else
argv << dot_rspec
end
argv.flatten!
else
argv.unshift('--format documentation')
end
if fail_fast_option_present?
argv << '--fail-fast'
end
argv.delete("--test")
argv.delete("-t")
argv.delete("-l")
argv.delete("--local")
end
|
#detect ⇒ Object
8
9
10
|
# File 'lib/learn_test/strategies/rspec.rb', line 8
def detect
runner.files.include?('spec') && (spec_files.include?('spec_helper.rb') || spec_files.include?('rails_helper.rb'))
end
|
#output ⇒ Object
39
40
41
|
# File 'lib/learn_test/strategies/rspec.rb', line 39
def output
File.exists?('.results.json') ? Oj.load(File.read('.results.json'), symbol_keys: true) : nil
end
|
#results ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/learn_test/strategies/rspec.rb', line 43
def results
{
username: username,
github_user_id: user_id,
learn_oauth_token: learn_oauth_token,
repo_name: runner.repo,
build: {
test_suite: [{
framework: 'rspec',
formatted_output: output,
duration: output ? output[:summary][:duration] : nil
}]
},
examples: output ? output[:summary][:example_count] : 1,
passing_count: output ? output[:summary][:example_count] - output[:summary][:failure_count] - output[:summary][:pending_count] : 0,
pending_count: output ? output[:summary][:pending_count] : 0,
failure_count: output ? output[:summary][:failure_count] : 1,
failure_descriptions: failures
}
end
|
#run ⇒ Object
35
36
37
|
# File 'lib/learn_test/strategies/rspec.rb', line 35
def run
system("#{bundle_command}rspec #{argv.join(' ')} --format j --out .results.json")
end
|
#service_endpoint ⇒ Object
4
5
6
|
# File 'lib/learn_test/strategies/rspec.rb', line 4
def service_endpoint
'/e/flatiron_rspec'
end
|