race_condition-rspec 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/race_condition/client.rb +29 -10
- data/lib/race_condition/rspec/configuration.rb +6 -1
- data/lib/race_condition/rspec/report.rb +34 -17
- data/lib/race_condition/rspec/version.rb +1 -1
- data/lib/race_condition/rspec.rb +0 -1
- data/race_condition-rspec.gemspec +1 -3
- data/spec/fakes/spec_helper.rb +5 -3
- metadata +5 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36cda9c2eb826865fb948b83584460adf4e9561c
|
4
|
+
data.tar.gz: 491391fb105aa01f7dde471737f8c56bb8414c43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cda2a25c932b37331fa81e12b628360c16b415784a29c5f95b01067bd136d16c20ef4e4a75b3293df38aeb487a5502bc6a6097cc2cbd094f3effa69fd4ac107
|
7
|
+
data.tar.gz: d8d42a7d8edf891e106bbfa8ef085acbfafc9afd74a316b92c48e21491be5439618977b3857b664ad72859dd266a7ad54afc959e14c62d91ee83dae3b81b20fc
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# RaceCondition::
|
1
|
+
# RaceCondition::RSpec [![Build Status](https://travis-ci.org/RaceCondition-io/race_condition-rspec.svg?branch=master)](https://travis-ci.org/RaceCondition-io/race_condition-rspec)
|
2
2
|
|
3
3
|
RSpec client for sending test suite results to RaceCondition.
|
4
4
|
|
@@ -29,7 +29,7 @@ RaceCondition::RSpec.configure do |c|
|
|
29
29
|
end
|
30
30
|
```
|
31
31
|
|
32
|
-
* `report_if` - This is a boolean or lambda that tells the reporter if it should test suite results to the server. Most popular CI servers set the `CI` environment variable.
|
32
|
+
* `report_if` - This is a boolean or lambda that tells the reporter if it should send test suite results to the server. Most popular CI servers set the `CI` environment variable.
|
33
33
|
* `codebase_id` - This is the codebase ID from RaceCondition that you want to send the results to.
|
34
34
|
* `branch_name` - The current branch name (optional, but recommended).
|
35
35
|
* `commit` - The commit under test (optional).
|
@@ -1,29 +1,48 @@
|
|
1
|
+
require "net/http"
|
2
|
+
require 'json'
|
3
|
+
|
1
4
|
module RaceCondition
|
2
5
|
class Client
|
3
|
-
|
4
|
-
|
5
|
-
base_uri "https://racecondition.io/"
|
6
|
-
endpoint "api/1"
|
6
|
+
ENDPOINT = "api/v1"
|
7
7
|
|
8
8
|
def report!(project_id, report_output)
|
9
9
|
return unless report?
|
10
10
|
|
11
11
|
puts "Sending test run data to RaceCondition..."
|
12
|
-
|
13
|
-
post("projects/#{project_id}/builds", extra_body: params)
|
14
|
-
rescue Errno::ECONNREFUSED, SocketError, Net::ReadTimeout
|
15
|
-
puts "Unable to reach RaceCondition."
|
16
|
-
end
|
12
|
+
response = post("projects/#{project_id}/builds", report_output)
|
17
13
|
|
18
|
-
|
14
|
+
unless response.code.to_i == 200
|
15
|
+
puts "Unable to log test results to RaceCondition."
|
16
|
+
end
|
17
|
+
rescue Errno::ECONNREFUSED, SocketError, Net::ReadTimeout => e
|
18
|
+
puts "Unable to reach RaceCondition."
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
+
def post(path, params)
|
24
|
+
url = URI.parse("#{base_url}/#{ENDPOINT}/#{path}")
|
25
|
+
|
26
|
+
http = Net::HTTP.new(url.host, url.port)
|
27
|
+
http.read_timeout = 5
|
28
|
+
http.open_timeout = 5
|
29
|
+
|
30
|
+
json_headers = {
|
31
|
+
"Content-Type" => "application/json",
|
32
|
+
"Accept" => "application/json"
|
33
|
+
}
|
34
|
+
|
35
|
+
http.post(url.path, params.to_json, json_headers)
|
36
|
+
end
|
37
|
+
|
23
38
|
def report?
|
24
39
|
config.report?
|
25
40
|
end
|
26
41
|
|
42
|
+
def base_url
|
43
|
+
config.report_to_domain
|
44
|
+
end
|
45
|
+
|
27
46
|
def config
|
28
47
|
RaceCondition::RSpec.configuration
|
29
48
|
end
|
@@ -6,7 +6,12 @@ module RaceCondition
|
|
6
6
|
:commit,
|
7
7
|
:build_number,
|
8
8
|
:codebase_id,
|
9
|
-
:report_if
|
9
|
+
:report_if,
|
10
|
+
:report_to_domain # for testing purposes
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
self.report_to_domain = "https://racecondition.io"
|
14
|
+
end
|
10
15
|
|
11
16
|
def report?
|
12
17
|
if report_if.respond_to? :call
|
@@ -13,10 +13,13 @@ module RaceCondition
|
|
13
13
|
|
14
14
|
def broadcast!
|
15
15
|
data = {
|
16
|
-
seed: seed,
|
17
|
-
duration: duration,
|
18
16
|
examples: examples_output,
|
19
|
-
|
17
|
+
seed: seed.seed,
|
18
|
+
client: "race_condition-rspec",
|
19
|
+
duration: duration,
|
20
|
+
branch_name: config.branch_name,
|
21
|
+
commit: config.commit,
|
22
|
+
build_number: config.build_number
|
20
23
|
}
|
21
24
|
|
22
25
|
allow_webmock!
|
@@ -29,14 +32,6 @@ module RaceCondition
|
|
29
32
|
WebMock.allow_net_connect! if Object.const_defined?("WebMock")
|
30
33
|
end
|
31
34
|
|
32
|
-
def metadata
|
33
|
-
{
|
34
|
-
branch_name: config.branch_name,
|
35
|
-
commit: config.commit,
|
36
|
-
build_number: config.build_number
|
37
|
-
}
|
38
|
-
end
|
39
|
-
|
40
35
|
def config
|
41
36
|
RaceCondition::RSpec.configuration
|
42
37
|
end
|
@@ -56,18 +51,20 @@ module RaceCondition
|
|
56
51
|
example = example.example
|
57
52
|
end
|
58
53
|
|
59
|
-
data =
|
60
|
-
|
54
|
+
data = {
|
55
|
+
started_at: example.execution_result[:started_at].iso8601,
|
56
|
+
finished_at: example.execution_result[:finished_at].iso8601,
|
57
|
+
run_time: example.execution_result[:run_time],
|
58
|
+
result: example.execution_result[:status],
|
61
59
|
full_description: example.full_description,
|
62
60
|
file_path: example.file_path,
|
63
61
|
location: example.location,
|
64
62
|
type: example.metadata[:type]
|
65
|
-
}
|
66
|
-
|
67
|
-
if data[:exception]
|
68
|
-
exception = data[:exception]
|
63
|
+
}
|
69
64
|
|
65
|
+
if exception = example.exception
|
70
66
|
data[:exception] = {
|
67
|
+
rerun: "rspec #{rerun_argument_for(example)}",
|
71
68
|
class: exception.class.name,
|
72
69
|
message: exception.message,
|
73
70
|
backtrace: exception.backtrace
|
@@ -76,6 +73,26 @@ module RaceCondition
|
|
76
73
|
|
77
74
|
data
|
78
75
|
end
|
76
|
+
|
77
|
+
# rerun logic from https://github.com/rspec/rspec-core/blob/4b0a10466cd19271bc5387bf5179bdb3b47a744d/lib/rspec/core/notifications.rb
|
78
|
+
|
79
|
+
def rerun_argument_for(example)
|
80
|
+
location = example.location_rerun_argument
|
81
|
+
return location unless duplicate_rerun_locations.include?(location)
|
82
|
+
example.id
|
83
|
+
end
|
84
|
+
|
85
|
+
def duplicate_rerun_locations
|
86
|
+
@duplicate_rerun_locations ||= begin
|
87
|
+
locations = ::RSpec.world.all_examples.map(&:location_rerun_argument)
|
88
|
+
|
89
|
+
Set.new.tap do |s|
|
90
|
+
locations.group_by { |l| l }.each do |l, ls|
|
91
|
+
s << l if ls.count > 1
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
79
96
|
end
|
80
97
|
end
|
81
98
|
end
|
data/lib/race_condition/rspec.rb
CHANGED
@@ -18,10 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "api_smith"
|
22
|
-
|
23
21
|
spec.add_development_dependency "bundler", "~> 1.6"
|
24
22
|
spec.add_development_dependency "rake"
|
25
|
-
spec.add_development_dependency "rspec", "~>
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0.0"
|
26
24
|
spec.add_development_dependency "pry"
|
27
25
|
end
|
data/spec/fakes/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: race_condition-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Boland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: api_smith
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: bundler
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +44,14 @@ dependencies:
|
|
58
44
|
requirements:
|
59
45
|
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
47
|
+
version: 3.0.0
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
52
|
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
54
|
+
version: 3.0.0
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: pry
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
110
|
version: '0'
|
125
111
|
requirements: []
|
126
112
|
rubyforge_project:
|
127
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.6.8
|
128
114
|
signing_key:
|
129
115
|
specification_version: 4
|
130
116
|
summary: RSpec client for sending test suite results to RaceCondition.
|