rspec_delivery 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +128 -0
- data/Rakefile +1 -0
- data/lib/rspec_delivery.rb +4 -0
- data/lib/rspec_delivery/formatter.rb +91 -0
- data/lib/rspec_delivery/message.rb +37 -0
- data/lib/rspec_delivery/tracker.rb +35 -0
- data/lib/rspec_delivery/version.rb +3 -0
- data/rspec_delivery.gemspec +26 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0d0fe2d0f5d216690da27112433a49575661d864
|
4
|
+
data.tar.gz: c8d547d5891ad0f05a002b2ef217730759b80649
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d0cae8053e58176f01fcb71acf5b1284c59cf76fb3f5254fd9c039c4b4b4471999ce04e1ffdc2aa8043d82ba20bfb1fc91c15faa649fa3550b5c42ad7782a1e1
|
7
|
+
data.tar.gz: 8d27b967266dfaa61d6947eb9b5de9dfa2879241f67484b58420d7506519fb570c70d2feb922a848a5f8cf4db8c762d68e6390a7adf4c95d62e122e8584e12c9
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Kevin Wanek
|
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,128 @@
|
|
1
|
+
# RSpec Delivery
|
2
|
+
|
3
|
+
RSpec Delivery is a gem designed to post to a web-service the results of your rspec test. (still in development)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'rspec_delivery'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install rspec_delivery
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
|
22
|
+
#### Setting the Formatter
|
23
|
+
Once you have the RSpec Delivery gem installed, you need to specify 'RspecDelivery' as the formatter to be used when running your rspec tests.
|
24
|
+
|
25
|
+
in a Rakefile:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
RSpec::Core::RakeTask.new do |t|
|
29
|
+
t.rspec_opts = "-r post_rspec/formatter -f RspecDelivery::Formatter"
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
or within your .rspec file:
|
34
|
+
|
35
|
+
```
|
36
|
+
--format RspecDelivery::Formatter
|
37
|
+
--color
|
38
|
+
```
|
39
|
+
|
40
|
+
or from the command line:
|
41
|
+
|
42
|
+
```
|
43
|
+
rspec -r rspec_delivery/formatter --format RspecDelivery::Formatter --color
|
44
|
+
```
|
45
|
+
|
46
|
+
or from within your spec_helper.rb
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
require 'rspec_delivery/formatter'
|
50
|
+
|
51
|
+
RSpec.configure do |config|
|
52
|
+
config.add_formatter(RspecDelivery::Formatter)
|
53
|
+
config.color_enabled = true
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
#### Setting the POST endpoint
|
58
|
+
You also need to add a config var within the Rspec.config block to specify an endpoint to post to:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
RSpec.configure do |config|
|
62
|
+
config.add_setting :rspec_delivery_endpoint
|
63
|
+
config.rspec_delivery_endpoint = 'http://localhost:3000/...'
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
#### Response / Summary
|
70
|
+
Once your rspec suite finishes running, it will send a POST to your specified endpoint with a body that looks like:
|
71
|
+
|
72
|
+
```json
|
73
|
+
{
|
74
|
+
"rspec_data"=>{
|
75
|
+
"duration"=>184.146366,
|
76
|
+
"example_count"=>9,
|
77
|
+
"failure_count"=>4,
|
78
|
+
"pending_count"=>0
|
79
|
+
},
|
80
|
+
"errors"=>[
|
81
|
+
{
|
82
|
+
"description"=>"Example description #1...",
|
83
|
+
"status"=>"failed",
|
84
|
+
"run_time"=>15.583829,
|
85
|
+
"file_path"=>"./spec/models/example_1.rb",
|
86
|
+
"line_number"=>"10"
|
87
|
+
}, {
|
88
|
+
"description"=>"Example description #2",
|
89
|
+
"status"=>"failed",
|
90
|
+
"run_time"=>22.671084,
|
91
|
+
"file_path"=>"./spec/controllers/example_2.rb",
|
92
|
+
"line_number"=>"38"
|
93
|
+
},
|
94
|
+
....
|
95
|
+
],
|
96
|
+
"successes"=>[
|
97
|
+
{
|
98
|
+
"description"=>"Example description #3",
|
99
|
+
"status"=>"passed",
|
100
|
+
"run_time"=>22.481478,
|
101
|
+
"file_path"=>"./app/specs/models/example_3.rb",
|
102
|
+
"line_number"=>"5"
|
103
|
+
},
|
104
|
+
....
|
105
|
+
],
|
106
|
+
"pending"=>nil
|
107
|
+
}
|
108
|
+
```
|
109
|
+
|
110
|
+
After the POST is sent, a message will be displayed within your terminal that contains the rspec suite summary (total time spent running tests, number of tests, number of failed tests, number of pending tests, and success rate) and two additional line items including the server response status and the server response body.
|
111
|
+
|
112
|
+
## TODO
|
113
|
+
|
114
|
+
- error handling
|
115
|
+
- still needs some stabilization / refactoring
|
116
|
+
- would like to setup a config block to set things like endpoint, config vars, etc...
|
117
|
+
- would like to setup the ability to send an email instead of http POST
|
118
|
+
- setup other HTTP methods (such as 'GET')
|
119
|
+
- ability to customize POST body
|
120
|
+
|
121
|
+
|
122
|
+
## Contributing
|
123
|
+
|
124
|
+
1. Fork it
|
125
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
126
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
127
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
128
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'rspec/core/formatters/progress_formatter'
|
2
|
+
|
3
|
+
require 'rspec_delivery/tracker'
|
4
|
+
require 'rspec_delivery/message'
|
5
|
+
|
6
|
+
module RspecDelivery
|
7
|
+
class Formatter < RSpec::Core::Formatters::ProgressFormatter
|
8
|
+
|
9
|
+
def start(example_count)
|
10
|
+
RSpec.configuration.post_rspec_endpoint
|
11
|
+
|
12
|
+
@tracker = RspecDelivery::Tracker.new
|
13
|
+
|
14
|
+
rescue NoMethodError => e
|
15
|
+
# RSpec.clear_remaining_example_groups
|
16
|
+
puts "RSpec Delivery: You must set an endpoint to post to within your RSpec.configuration block found in spec_helper.rb. Instructions can be found at https://github.com/theef/post_rspec. \nRSpec Error Message: #{e} \n\n"
|
17
|
+
abort
|
18
|
+
end
|
19
|
+
|
20
|
+
def example_group_started(example_group)
|
21
|
+
end
|
22
|
+
|
23
|
+
def example_group_finished(example_group)
|
24
|
+
end
|
25
|
+
|
26
|
+
def example_started(example)
|
27
|
+
end
|
28
|
+
|
29
|
+
def example_passed(example)
|
30
|
+
@tracker.add example
|
31
|
+
super(example)
|
32
|
+
end
|
33
|
+
|
34
|
+
def example_pending(example)
|
35
|
+
@tracker.add example
|
36
|
+
super(example)
|
37
|
+
end
|
38
|
+
|
39
|
+
def example_failed(example)
|
40
|
+
@tracker.add example
|
41
|
+
super(example)
|
42
|
+
end
|
43
|
+
|
44
|
+
def message(message)
|
45
|
+
end
|
46
|
+
|
47
|
+
def stop
|
48
|
+
end
|
49
|
+
|
50
|
+
def start_dump()
|
51
|
+
end
|
52
|
+
|
53
|
+
def dump_pending()
|
54
|
+
end
|
55
|
+
|
56
|
+
def dump_failures()
|
57
|
+
end
|
58
|
+
|
59
|
+
def dump_summary(duration, example_count, failure_count, pending_count)
|
60
|
+
|
61
|
+
endpoint = RSpec.configuration.post_rspec_endpoint
|
62
|
+
|
63
|
+
unless endpoint.blank?
|
64
|
+
rspec_data = {
|
65
|
+
duration: duration,
|
66
|
+
example_count: example_count,
|
67
|
+
failure_count: failure_count,
|
68
|
+
pending_count: pending_count
|
69
|
+
}
|
70
|
+
|
71
|
+
message = RspecDelivery::Message.new(rspec_data)
|
72
|
+
message.tracker_data = @tracker
|
73
|
+
message.send endpoint
|
74
|
+
|
75
|
+
super(duration, example_count, failure_count, pending_count)
|
76
|
+
end
|
77
|
+
|
78
|
+
rescue NoMethodError => e
|
79
|
+
puts "\n\nRSpec error: #{e}"
|
80
|
+
end
|
81
|
+
|
82
|
+
####
|
83
|
+
|
84
|
+
def seed(seed)
|
85
|
+
end
|
86
|
+
|
87
|
+
def close()
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module RspecDelivery
|
2
|
+
class Message
|
3
|
+
|
4
|
+
attr_accessor :rspec_data, :tracker_data
|
5
|
+
|
6
|
+
def initialize(rspec_data)
|
7
|
+
puts "\n\n"
|
8
|
+
puts "duration: #{(rspec_data[:duration].to_f / 60).to_s[0..5]} mins.\n"
|
9
|
+
puts "example_count: #{rspec_data[:example_count]}\n"
|
10
|
+
puts "failure_count: #{rspec_data[:failure_count]}\n"
|
11
|
+
puts "success_rate: #{((1 - (rspec_data[:failure_count].to_f/rspec_data[:example_count].to_f)) * 100).to_s[0..5]}% \n\n"
|
12
|
+
@rspec_data = rspec_data
|
13
|
+
end
|
14
|
+
|
15
|
+
def send(endpoint)
|
16
|
+
response = HTTParty.post(endpoint,
|
17
|
+
body: {
|
18
|
+
rspec_data: self.rspec_data,
|
19
|
+
errors: self.tracker_data.errors,
|
20
|
+
successes: self.tracker_data.successes,
|
21
|
+
pending: self.tracker_data.pending
|
22
|
+
}.to_json,
|
23
|
+
headers: {
|
24
|
+
'Content-Type' => 'application/json'
|
25
|
+
}
|
26
|
+
)
|
27
|
+
|
28
|
+
puts "RSpec Delivery Response Status: #{response.code}"
|
29
|
+
body = response.body
|
30
|
+
if body.blank? || body == ''
|
31
|
+
body = '<no server response body>'
|
32
|
+
end
|
33
|
+
puts "RSpec Delivery Response Body: #{body}"
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module RspecDelivery
|
2
|
+
class Tracker
|
3
|
+
|
4
|
+
attr_accessor :errors, :successes, :pending
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@errors = []
|
8
|
+
@successes = []
|
9
|
+
@pending = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def add(example)
|
13
|
+
# TODO, add exception message (an RSPEC::Expectation::Message obj)
|
14
|
+
status = example.execution_result[:status]
|
15
|
+
|
16
|
+
message = {
|
17
|
+
description: example.full_description,
|
18
|
+
status: status,
|
19
|
+
run_time: example.execution_result[:run_time],
|
20
|
+
file_path: example.file_path,
|
21
|
+
line_number: example.location.split('.rb:')[1]
|
22
|
+
}
|
23
|
+
|
24
|
+
if status == "failed"
|
25
|
+
@errors << message
|
26
|
+
elsif status == "passed"
|
27
|
+
@successes << message
|
28
|
+
elsif status == "pending"
|
29
|
+
@pending << message
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rspec_delivery/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'rspec_delivery'
|
8
|
+
spec.version = RspecDelivery::VERSION
|
9
|
+
spec.authors = ['Kevin Wanek']
|
10
|
+
spec.email = ['k@dmcy.us']
|
11
|
+
spec.description = 'A custom rspec formatter to post RSpec suite results to a web service.'
|
12
|
+
spec.summary = 'See description.'
|
13
|
+
spec.homepage = 'https://github.com/theef/rspec_delivery'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
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_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
|
24
|
+
spec.add_dependency 'httparty'
|
25
|
+
spec.add_dependency 'rspec'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec_delivery
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kevin Wanek
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: httparty
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
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: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: A custom rspec formatter to post RSpec suite results to a web service.
|
70
|
+
email:
|
71
|
+
- k@dmcy.us
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- lib/rspec_delivery.rb
|
82
|
+
- lib/rspec_delivery/formatter.rb
|
83
|
+
- lib/rspec_delivery/message.rb
|
84
|
+
- lib/rspec_delivery/tracker.rb
|
85
|
+
- lib/rspec_delivery/version.rb
|
86
|
+
- rspec_delivery.gemspec
|
87
|
+
homepage: https://github.com/theef/rspec_delivery
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.0.3
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: See description.
|
111
|
+
test_files: []
|