race_condition-rspec 0.0.1.alpha

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 842bc5a404dbb509fb615d76281ad0f99ea71dc0
4
+ data.tar.gz: 7370977761b2eef65f0c809993679543fbd3a98e
5
+ SHA512:
6
+ metadata.gz: 0d145aec4c674963a21c41d5c7470badaaef39e9781b1265f6d2f84c78461b20c5985686de6fbd0ce2602db917ccb9a93685c9017f17cbf20a63d9d68f0a45d7
7
+ data.tar.gz: 0d66a8d4914486435b8be89fd021ff7f0bd15952dae5364690d130c8a5463d386ee8e8e9615a7544ffbbb9efdac59f8877041a9bd1a2945e986ec3aacc6cb9c4
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ bin/
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ *.bundle
20
+ *.so
21
+ *.o
22
+ *.a
23
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in race_condition-rspec.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Ryan Boland
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # RaceCondition::Rspec
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'race_condition-rspec'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install race_condition-rspec
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/race_condition-rspec/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,18 @@
1
+ module RaceCondition
2
+ class Client
3
+ include APISmith::Client
4
+ base_uri "http://localhost:3000/"
5
+ endpoint "api/1"
6
+
7
+ def report!(project_id, report_output)
8
+ puts "Sending test run data to RaceCondition..."
9
+ params = { build: report_output }
10
+ post("projects/#{project_id}/builds", extra_body: params)
11
+ rescue Errno::ECONNREFUSED, SocketError, Net::ReadTimeout
12
+ puts "Unable to reach RaceCondition."
13
+ end
14
+
15
+ def check_response_errors(response)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ module RaceCondition
2
+ module RSpec
3
+ class Configuration
4
+ attr_accessor :branch_name, :project_id, :commit, :build_number, :send_to
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,36 @@
1
+ module RaceCondition
2
+ module RSpec
3
+ class Listener
4
+ SUBSCRIPTIONS = %i(example_passed example_failed example_pending
5
+ dump_summary seed close)
6
+
7
+ def initialize
8
+ @report = Report.new
9
+ end
10
+
11
+ def example_passed(example)
12
+ @report.passed_examples << example
13
+ end
14
+
15
+ def example_failed(example)
16
+ @report.failed_examples << example
17
+ end
18
+
19
+ def example_pending(example)
20
+ @report.pending_examples << example
21
+ end
22
+
23
+ def dump_summary(duration, example_count, failure_count, pending_count)
24
+ @report.duration = duration
25
+ end
26
+
27
+ def seed(seed)
28
+ @report.seed = seed
29
+ end
30
+
31
+ def close
32
+ @report.broadcast!
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,75 @@
1
+ module RaceCondition
2
+ module RSpec
3
+ class Report
4
+ attr_accessor :passed_count, :passed_examples, :failure_count,
5
+ :failed_examples, :pending_count, :pending_examples,
6
+ :seed, :duration
7
+
8
+ def initialize
9
+ @passed_examples = []
10
+ @failed_examples = []
11
+ @pending_examples = []
12
+ end
13
+
14
+ def broadcast!
15
+ data = {
16
+ seed: seed,
17
+ duration: duration,
18
+ examples: examples_output,
19
+ metadata: metadata
20
+ }
21
+
22
+ allow_webmock!
23
+ Client.new.report!("f8e76771aef86908", data)
24
+ end
25
+
26
+ private
27
+
28
+ def allow_webmock!
29
+ WebMock.allow_net_connect! if Object.const_defined?("WebMock")
30
+ end
31
+
32
+ def metadata
33
+ config = RaceCondition::RSpec.configuration
34
+
35
+ {
36
+ branch_name: config.branch_name,
37
+ commit: config.commit,
38
+ build_number: config.build_number
39
+ }
40
+ end
41
+
42
+ def examples
43
+ passed_examples + failed_examples + pending_examples
44
+ end
45
+
46
+ def examples_output
47
+ examples.map do |example|
48
+ map_to_data_hash(example)
49
+ end
50
+ end
51
+
52
+ def map_to_data_hash(example)
53
+ data = example.execution_result.merge({
54
+ description: example.description,
55
+ full_description: example.full_description,
56
+ file_path: example.file_path,
57
+ location: example.location,
58
+ type: example.metadata[:type]
59
+ })
60
+
61
+ if data[:exception]
62
+ exception = data[:exception]
63
+
64
+ data[:exception] = {
65
+ class: exception.class.name,
66
+ message: exception.message,
67
+ backtrace: exception.backtrace
68
+ }
69
+ end
70
+
71
+ data
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,5 @@
1
+ module RaceCondition
2
+ module Rspec
3
+ VERSION = "0.0.1.alpha"
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ require "api_smith"
2
+ require "race_condition/rspec/version"
3
+ require "race_condition/rspec/configuration"
4
+ require "race_condition/client"
5
+ require "race_condition/rspec/report"
6
+ require "race_condition/rspec/listener"
7
+
8
+ RSpec.configure do |config|
9
+ config.reporter.register_listener(RaceCondition::RSpec::Listener.new,
10
+ *RaceCondition::RSpec::Listener::SUBSCRIPTIONS)
11
+ end
12
+
13
+ module RaceCondition
14
+ module RSpec
15
+ def self.configuration
16
+ @configuration ||= Configuration.new
17
+ end
18
+
19
+ def self.configure
20
+ yield configuration
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'race_condition/rspec/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "race_condition-rspec"
8
+ spec.version = RaceCondition::Rspec::VERSION
9
+ spec.authors = ["Ryan Boland"]
10
+ spec.email = ["bolandryanm@gmail.com"]
11
+ spec.summary = "RSpec client for sending test suite results to RaceCondition."
12
+ spec.description = "RSpec client for sending test suite results to RaceCondition."
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "api_smith"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec", "~> 2.99.0"
26
+ spec.add_development_dependency "pry"
27
+ end
@@ -0,0 +1,12 @@
1
+ require_relative "spec_helper"
2
+
3
+ RSpec.describe 'group 1' do
4
+ specify('group 1 example 1', type: "feature") {}
5
+ specify('group 1 example 2') {}
6
+ specify('group 1 example 3') {}
7
+ describe 'group 1-1' do
8
+ specify('group 1-1 example 1') {}
9
+ specify('group 1-1 example 2') {}
10
+ specify('group 1-1 example 3') {}
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ require "race_condition/rspec.rb"
2
+
3
+ class RaceCondition::Client
4
+ def report!(project, data)
5
+ puts data.to_json
6
+ end
7
+ end
8
+
9
+ RaceCondition::RSpec.configure do |c|
10
+ end
11
+
12
+ RSpec.configure do |c|
13
+ end
@@ -0,0 +1,14 @@
1
+ require "spec_helper"
2
+
3
+ describe "RaceCondition" do
4
+ it "works" do
5
+ out = run_command "rspec spec/fakes/simple.rb"
6
+ expect(out["examples"].first["type"]).to eq "feature"
7
+ end
8
+
9
+ def run_command(command)
10
+ out = `#{command}`
11
+ out = out.split("failures\n")
12
+ JSON.parse(out[1])
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ Dir['./spec/support/**/*.rb'].map { |f| require f }
2
+
3
+ require "pry"
4
+ require "race_condition/rspec"
5
+
6
+ RSpec.configure do |c|
7
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: race_condition-rspec
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.alpha
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Boland
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-29 00:00:00.000000000 Z
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
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.99.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.99.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: RSpec client for sending test suite results to RaceCondition.
84
+ email:
85
+ - bolandryanm@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - lib/race_condition/client.rb
96
+ - lib/race_condition/rspec.rb
97
+ - lib/race_condition/rspec/configuration.rb
98
+ - lib/race_condition/rspec/listener.rb
99
+ - lib/race_condition/rspec/report.rb
100
+ - lib/race_condition/rspec/version.rb
101
+ - race_condition-rspec.gemspec
102
+ - spec/fakes/simple.rb
103
+ - spec/fakes/spec_helper.rb
104
+ - spec/integration/race_condition_spec.rb
105
+ - spec/spec_helper.rb
106
+ homepage: ''
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">"
122
+ - !ruby/object:Gem::Version
123
+ version: 1.3.1
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.2.2
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: RSpec client for sending test suite results to RaceCondition.
130
+ test_files:
131
+ - spec/fakes/simple.rb
132
+ - spec/fakes/spec_helper.rb
133
+ - spec/integration/race_condition_spec.rb
134
+ - spec/spec_helper.rb