cucumber-pro 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +2 -0
- data/LICENSE +22 -0
- data/README.md +19 -0
- data/Rakefile +24 -0
- data/TODO.md +4 -0
- data/cucumber-pro.gemspec +34 -0
- data/features/publish_results.feature +49 -0
- data/features/step_definitions/steps.rb +53 -0
- data/features/support/aruba.rb +11 -0
- data/features/support/env.rb +2 -0
- data/features/support/fake_results_service.rb +98 -0
- data/features/support/world.rb +9 -0
- data/lib/cucumber/pro.rb +40 -0
- data/lib/cucumber/pro/formatter.rb +88 -0
- data/lib/cucumber/pro/scm.rb +38 -0
- data/lib/cucumber/pro/version.rb +9 -0
- data/lib/cucumber/pro/web_socket_session.rb +111 -0
- metadata +208 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 360d700355a6242a32b3bc1158413bb28631b78f
|
4
|
+
data.tar.gz: 62714230f4f2b5705019573dc6e1e6c0a73efd01
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e774893274297e0d247c25ef63d2781c9f30be102feb663a96c9591f923ce52f11228944b5957f8bbd82dae382c710d42a6b95be8c114f2ad9fb8170d787f117
|
7
|
+
data.tar.gz: dcad02c537dba40d9ebce9f6c5b1238896bc7f1a36edf656573abd87511f8d997f3f65d541c2a06dcb7220215f358b76a474e4c204a92eaab0e1418821971a12
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2013 Cucumber Ltd
|
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,19 @@
|
|
1
|
+
# Cucumber Pro Client Gem
|
2
|
+
|
3
|
+
This gem provides a formatter for Cucumber that publishes results to
|
4
|
+
the [Cucumber Pro](https://cucumber.pro) web service.
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
|
8
|
+
Add the following line to your gemfile:
|
9
|
+
|
10
|
+
```
|
11
|
+
gem 'cucumber-pro'
|
12
|
+
```
|
13
|
+
|
14
|
+
Now run Cucumber using the `Cucumber::Pro` formatter:
|
15
|
+
|
16
|
+
```
|
17
|
+
CUCUMBER_PRO_TOKEN=<your auth token> cucumber -f Cucumber::Pro -f pretty
|
18
|
+
```
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
desc 'Run tests'
|
6
|
+
task default: :cucumber
|
7
|
+
|
8
|
+
ENV['cucumber_pro_log_path'] = File.dirname(__FILE__) + '/tmp/test.log'
|
9
|
+
|
10
|
+
task :cucumber do
|
11
|
+
sh 'cucumber'
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'Run repeated tests to check for async bugs'
|
15
|
+
task :soak, :repetitions do |task, args|
|
16
|
+
reps = args[:repetitions] || 10
|
17
|
+
results = reps.to_i.times.map do
|
18
|
+
`cucumber`
|
19
|
+
print $? == 0 ? '.' : 'x'
|
20
|
+
$?
|
21
|
+
end
|
22
|
+
num_failed = results.count { |r| r != 0 }
|
23
|
+
fail "#{num_failed}/#{reps} failed" if num_failed > 0
|
24
|
+
end
|
data/TODO.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
3
|
+
require "cucumber/pro/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'cucumber-pro'
|
7
|
+
s.version = Cucumber::Pro::Version
|
8
|
+
s.authors = ["Matt Wynne"]
|
9
|
+
s.description = "Client library for publishing results to the Cucumber Pro service"
|
10
|
+
s.summary = "cucumber-pro-#{s.version}"
|
11
|
+
s.email = "hello@cucumber.pro"
|
12
|
+
s.homepage = "https://cucumber.pro"
|
13
|
+
s.platform = Gem::Platform::RUBY
|
14
|
+
s.license = "MIT"
|
15
|
+
s.required_ruby_version = ">= 1.9.3"
|
16
|
+
|
17
|
+
s.add_dependency 'grit'
|
18
|
+
s.add_dependency 'faye-websocket'
|
19
|
+
|
20
|
+
s.add_development_dependency 'bundler', '>= 1.3.5'
|
21
|
+
s.add_development_dependency 'rake', '>= 0.9.2'
|
22
|
+
s.add_development_dependency 'rspec', '>= 2.14.1'
|
23
|
+
s.add_development_dependency 'cucumber'
|
24
|
+
s.add_development_dependency 'aruba'
|
25
|
+
s.add_development_dependency 'thin'
|
26
|
+
s.add_development_dependency 'rack'
|
27
|
+
s.add_development_dependency 'anticipate'
|
28
|
+
|
29
|
+
s.rubygems_version = ">= 1.6.1"
|
30
|
+
s.files = `git ls-files`.split("\n").reject {|path| path =~ /\.gitignore$/ }
|
31
|
+
s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
|
32
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
33
|
+
s.require_path = "lib"
|
34
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
@announce
|
2
|
+
Feature: Publish results
|
3
|
+
|
4
|
+
Scenario: A couple of scenarios
|
5
|
+
Given a git repo
|
6
|
+
And a feature "features/test.feature" with:
|
7
|
+
"""
|
8
|
+
Feature:
|
9
|
+
Scenario:
|
10
|
+
Given passing
|
11
|
+
|
12
|
+
Scenario:
|
13
|
+
Given failing
|
14
|
+
"""
|
15
|
+
When I run `cucumber -f Cucumber::Pro -o /dev/null -f pretty`
|
16
|
+
Then the results service should receive a header
|
17
|
+
And the results service should receive these test-step results:
|
18
|
+
| status | path | location |
|
19
|
+
| passed | features/test.feature | 3 |
|
20
|
+
| failed | features/test.feature | 6 |
|
21
|
+
And the results service should receive these test-case results:
|
22
|
+
| status | path | location |
|
23
|
+
| passed | features/test.feature | 2 |
|
24
|
+
| failed | features/test.feature | 5 |
|
25
|
+
|
26
|
+
Scenario: A scenario outline
|
27
|
+
|
28
|
+
Note that we don't specify how step results will be published. This is because it's hard to get
|
29
|
+
a location for steps when a scenario outline executes.
|
30
|
+
|
31
|
+
Given a git repo
|
32
|
+
And a feature "features/test.feature" with:
|
33
|
+
"""
|
34
|
+
Feature:
|
35
|
+
Scenario Outline:
|
36
|
+
Given <result>
|
37
|
+
|
38
|
+
Examples:
|
39
|
+
| result |
|
40
|
+
| passing |
|
41
|
+
| failing |
|
42
|
+
"""
|
43
|
+
When I run `cucumber -f Cucumber::Pro -o /dev/null -f pretty`
|
44
|
+
Then the results service should receive a header
|
45
|
+
And the results service should receive these test-case results:
|
46
|
+
| status | path | location |
|
47
|
+
| passed | features/test.feature | 7 |
|
48
|
+
| failed | features/test.feature | 8 |
|
49
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
Before do
|
2
|
+
write_file 'features/step_definitions/steps.rb', <<-END
|
3
|
+
Given(/pass/) { }
|
4
|
+
Given(/fail/) { fail }
|
5
|
+
END
|
6
|
+
end
|
7
|
+
|
8
|
+
After do
|
9
|
+
terminate_processes!
|
10
|
+
end
|
11
|
+
|
12
|
+
Given(/^a git repo$/) do
|
13
|
+
run_simple "git init"
|
14
|
+
run_simple "git commit --allow-empty -m 'Initial commit'"
|
15
|
+
run_simple "git remote add origin #{repo_url}"
|
16
|
+
run_simple "git config --get remote.origin.url"
|
17
|
+
end
|
18
|
+
|
19
|
+
Given(/^a feature "(.*?)" with:$/) do |path, content|
|
20
|
+
write_file path, content
|
21
|
+
end
|
22
|
+
|
23
|
+
Then(/^the results service should receive a header$/) do
|
24
|
+
eventually do
|
25
|
+
results_service.messages.length.should > 0
|
26
|
+
end
|
27
|
+
results_service.messages.first['repo_url'].should == repo_url
|
28
|
+
end
|
29
|
+
|
30
|
+
Then(/^the results service should receive these ([\w\-]+) results:$/) do |type, results|
|
31
|
+
expected_results = results.hashes
|
32
|
+
actual_results = eventually {
|
33
|
+
results = results_service.messages.select { |msg| msg['mime_type'] =~ /#{type}/ }
|
34
|
+
expect( results.length ).to eq expected_results.length
|
35
|
+
results
|
36
|
+
}
|
37
|
+
expected_statuses = expected_results.map { |result| [result['status'], result['path'], result['location'].to_i ] }
|
38
|
+
actual_statuses = actual_results.map { |result| [result['body']['status'], result['path'], result['location']] }
|
39
|
+
expect( actual_statuses ).to eq expected_statuses
|
40
|
+
end
|
41
|
+
|
42
|
+
require 'anticipate'
|
43
|
+
module Eventually
|
44
|
+
include Anticipate
|
45
|
+
def eventually(&block)
|
46
|
+
result = nil
|
47
|
+
sleeping(0.1).seconds.between_tries.failing_after(30).tries do
|
48
|
+
result = block.call
|
49
|
+
end
|
50
|
+
result
|
51
|
+
end
|
52
|
+
end
|
53
|
+
World(Eventually)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'aruba/cucumber'
|
2
|
+
|
3
|
+
Before do
|
4
|
+
# ensure Cucumber's Ruby process can require the plugin as though it were a gem
|
5
|
+
path = File.expand_path(File.dirname(__FILE__) + '/../../lib')
|
6
|
+
set_env 'RUBYLIB', path
|
7
|
+
end
|
8
|
+
|
9
|
+
Before do
|
10
|
+
@aruba_timeout_seconds = 5
|
11
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'faye/websocket'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module FakeResultsService
|
5
|
+
PORT = 5000
|
6
|
+
VALID_TOKEN = 'valid-cucumber-pro-token'
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def messages
|
10
|
+
@messages ||= []
|
11
|
+
end
|
12
|
+
|
13
|
+
def reset
|
14
|
+
@messages = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
def logger
|
18
|
+
$logger
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
logger = self.logger
|
23
|
+
|
24
|
+
SocketApp = lambda do |env|
|
25
|
+
logger.debug [:server, :starting]
|
26
|
+
ws = Faye::WebSocket.new(env)
|
27
|
+
|
28
|
+
ws.on :open do |event|
|
29
|
+
logger.debug [:server, :open]
|
30
|
+
end
|
31
|
+
|
32
|
+
ws.on :message do |event|
|
33
|
+
logger.debug [:server, :message, event.data]
|
34
|
+
FakeResultsService.messages << JSON.parse(event.data)
|
35
|
+
ws.send 'ok'
|
36
|
+
end
|
37
|
+
|
38
|
+
ws.on :close do |event|
|
39
|
+
logger.debug [:server, :close]
|
40
|
+
end
|
41
|
+
|
42
|
+
# Return async Rack response
|
43
|
+
ws.rack_response
|
44
|
+
end
|
45
|
+
|
46
|
+
class Security
|
47
|
+
def initialize(app)
|
48
|
+
@app = app
|
49
|
+
end
|
50
|
+
|
51
|
+
def call(env)
|
52
|
+
request = Rack::Request.new(env)
|
53
|
+
params = request.params
|
54
|
+
return [401, [], {}] unless params['token'] == VALID_TOKEN
|
55
|
+
@app.call(env)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
require 'thin'
|
60
|
+
require 'rack'
|
61
|
+
require 'eventmachine'
|
62
|
+
Faye::WebSocket.load_adapter 'thin'
|
63
|
+
Thin::Logging.logger = logger
|
64
|
+
$em = Thread.new do
|
65
|
+
begin
|
66
|
+
EM.run do
|
67
|
+
thin = Rack::Handler.get('thin')
|
68
|
+
app = Security.new(SocketApp)
|
69
|
+
thin.run app, :Port => PORT
|
70
|
+
trap("INT") { exit }
|
71
|
+
end
|
72
|
+
rescue => exception
|
73
|
+
logger.fatal(exception)
|
74
|
+
$stderr.puts exception, exception.backtrace
|
75
|
+
exit 1
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
loop until EM.reactor_running?
|
80
|
+
end
|
81
|
+
|
82
|
+
if !respond_to?(:Before)
|
83
|
+
# Standalone (manual test) mode
|
84
|
+
$em.join
|
85
|
+
else
|
86
|
+
# Cucumber mode
|
87
|
+
Before { FakeResultsService.reset }
|
88
|
+
After { FakeResultsService.logger.debug [:server, :messages, FakeResultsService.messages] }
|
89
|
+
Before do
|
90
|
+
write_file 'features/step_definitions/cucumber_pro.rb', <<-END
|
91
|
+
require 'cucumber/pro'
|
92
|
+
Cucumber::Pro.configure do |c|
|
93
|
+
c.url = 'ws://localhost:#{FakeResultsService::PORT}'
|
94
|
+
c.token = "#{FakeResultsService::VALID_TOKEN}"
|
95
|
+
end
|
96
|
+
END
|
97
|
+
end
|
98
|
+
end
|
data/lib/cucumber/pro.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'cucumber/pro/formatter'
|
3
|
+
require 'cucumber/pro/web_socket_session'
|
4
|
+
|
5
|
+
module Cucumber
|
6
|
+
module Pro
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def new(*)
|
10
|
+
url = config.url + "?token=#{config.token}"
|
11
|
+
session = WebSocketSession.new(url, config.logger)
|
12
|
+
Formatter.new(session)
|
13
|
+
end
|
14
|
+
|
15
|
+
def configure
|
16
|
+
yield config
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def config
|
22
|
+
@config ||= Config.new
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class Config
|
27
|
+
attr_accessor :url, :logger, :token
|
28
|
+
end
|
29
|
+
|
30
|
+
# Default config
|
31
|
+
configure do |config|
|
32
|
+
config.url = 'ws://metarepo.cucumber.pro/ws'
|
33
|
+
config.logger = Logger.new(ENV['cucumber_pro_log_path'] || STDOUT)
|
34
|
+
config.token = ENV['CUCUMBER_PRO_TOKEN']
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'cucumber/pro/scm'
|
2
|
+
|
3
|
+
module Cucumber
|
4
|
+
module Pro
|
5
|
+
|
6
|
+
class Formatter
|
7
|
+
def initialize(session)
|
8
|
+
@session = session
|
9
|
+
send_header
|
10
|
+
end
|
11
|
+
|
12
|
+
def before_feature(feature)
|
13
|
+
@path = feature.file # we need this because table_row doens't have a file_colon_line
|
14
|
+
end
|
15
|
+
|
16
|
+
def before_step_result(*args)
|
17
|
+
keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line = *args
|
18
|
+
path, line = *file_colon_line.split(':')
|
19
|
+
send_step_result(path, line, status)
|
20
|
+
end
|
21
|
+
|
22
|
+
def after_feature_element(feature_element)
|
23
|
+
return if Cucumber::Ast::ScenarioOutline === feature_element
|
24
|
+
scenario = feature_element
|
25
|
+
path, line = *scenario.file_colon_line.split(':')
|
26
|
+
send_test_case_result(path, line, scenario.status)
|
27
|
+
end
|
28
|
+
|
29
|
+
def before_examples(*args)
|
30
|
+
@header_row = true
|
31
|
+
@in_examples = true
|
32
|
+
end
|
33
|
+
|
34
|
+
def after_examples(*args)
|
35
|
+
@in_examples = false
|
36
|
+
end
|
37
|
+
|
38
|
+
def after_table_row(table_row)
|
39
|
+
return unless @in_examples and Cucumber::Ast::OutlineTable::ExampleRow === table_row
|
40
|
+
if @header_row
|
41
|
+
@header_row = false
|
42
|
+
return
|
43
|
+
end
|
44
|
+
send_test_case_result(@path, table_row.line, table_row.status)
|
45
|
+
end
|
46
|
+
|
47
|
+
def after_features(*args)
|
48
|
+
@session.close
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def send_header
|
54
|
+
scm = Scm::Repo.find
|
55
|
+
@session.send({
|
56
|
+
repo_url: scm.remote,
|
57
|
+
branch: scm.branch,
|
58
|
+
rev: scm.rev,
|
59
|
+
group: get_run_id
|
60
|
+
})
|
61
|
+
end
|
62
|
+
|
63
|
+
def send_step_result(path, line, status)
|
64
|
+
@session.send({
|
65
|
+
path: path,
|
66
|
+
location: line.to_i,
|
67
|
+
mime_type: 'application/vnd.cucumber.test-step-result+json',
|
68
|
+
body: { status: status }
|
69
|
+
})
|
70
|
+
end
|
71
|
+
|
72
|
+
def send_test_case_result(path, line, status)
|
73
|
+
@session.send({
|
74
|
+
path: path,
|
75
|
+
location: line.to_i,
|
76
|
+
mime_type: 'application/vnd.cucumber.test-case-result+json',
|
77
|
+
body: { status: status }
|
78
|
+
})
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_run_id
|
82
|
+
Time.now.to_i
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Pro
|
3
|
+
|
4
|
+
module Scm
|
5
|
+
|
6
|
+
require 'grit'
|
7
|
+
class Repo
|
8
|
+
|
9
|
+
NoGitRepoFound = Class.new(StandardError)
|
10
|
+
|
11
|
+
def self.find(path = Dir.pwd)
|
12
|
+
if Dir.entries(path).include? '.git'
|
13
|
+
new(path)
|
14
|
+
else
|
15
|
+
raise NoGitRepoFound if path == '/'
|
16
|
+
find File.expand_path(path + '/..')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(path)
|
21
|
+
@repo = Grit::Repo.new(path)
|
22
|
+
end
|
23
|
+
|
24
|
+
def remote
|
25
|
+
@repo.config['remote.origin.url']
|
26
|
+
end
|
27
|
+
|
28
|
+
def branch
|
29
|
+
@repo.head.name
|
30
|
+
end
|
31
|
+
|
32
|
+
def rev
|
33
|
+
@repo.head.commit.id
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'faye/websocket'
|
3
|
+
require 'eventmachine'
|
4
|
+
|
5
|
+
module Cucumber
|
6
|
+
module Pro
|
7
|
+
module Error
|
8
|
+
AccessDenied = Class.new(StandardError) {
|
9
|
+
def initialize
|
10
|
+
super "Access denied."
|
11
|
+
end
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
class WebSocketSession
|
16
|
+
|
17
|
+
|
18
|
+
class SendMessage
|
19
|
+
def initialize(data)
|
20
|
+
@data = data
|
21
|
+
end
|
22
|
+
|
23
|
+
def send_to(ws)
|
24
|
+
ws.send(@data.to_json)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Close
|
29
|
+
def send_to(ws)
|
30
|
+
ws.close
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def initialize(url, logger)
|
35
|
+
@url, @logger = url, logger
|
36
|
+
@queue = Queue.new
|
37
|
+
start
|
38
|
+
end
|
39
|
+
|
40
|
+
def send(message)
|
41
|
+
logger.debug [:session, :send, message]
|
42
|
+
queue.push(SendMessage.new(message))
|
43
|
+
end
|
44
|
+
|
45
|
+
def close
|
46
|
+
logger.debug [:session, :close]
|
47
|
+
queue.push(Close.new)
|
48
|
+
@em.join
|
49
|
+
if @ws_error
|
50
|
+
puts "Cucumber Pro failed to send results: #{@ws_error}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
attr_reader :logger, :queue
|
57
|
+
|
58
|
+
def start
|
59
|
+
@em = Thread.new do
|
60
|
+
begin
|
61
|
+
EM.run { start_ws_client }
|
62
|
+
rescue => exception
|
63
|
+
logger.fatal exception
|
64
|
+
@ws_error = exception
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def start_ws_client
|
70
|
+
logger.debug [:ws, :start]
|
71
|
+
ws = Faye::WebSocket::Client.new(@url)
|
72
|
+
|
73
|
+
ws.on(:open) do
|
74
|
+
logger.debug [:ws, :open]
|
75
|
+
process_queue(ws)
|
76
|
+
end
|
77
|
+
|
78
|
+
ws.on(:error) do
|
79
|
+
logger.error [:ws, :error]
|
80
|
+
end
|
81
|
+
|
82
|
+
ws.on(:message) do |event|
|
83
|
+
logger.debug [:ws, :message, event.data]
|
84
|
+
end
|
85
|
+
|
86
|
+
ws.on(:close) do |event|
|
87
|
+
logger.debug [:ws, :close]
|
88
|
+
@ws_error = Error::AccessDenied.new
|
89
|
+
ws = nil
|
90
|
+
EM.stop_event_loop
|
91
|
+
end
|
92
|
+
self
|
93
|
+
end
|
94
|
+
|
95
|
+
def process_queue(ws)
|
96
|
+
process_next_message(ws)
|
97
|
+
EM.next_tick do
|
98
|
+
process_queue(ws)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def process_next_message(ws)
|
103
|
+
return if queue.empty?
|
104
|
+
message = queue.pop
|
105
|
+
message.send_to(ws)
|
106
|
+
logger.debug [:ws, :send, message]
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
metadata
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cucumber-pro
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Wynne
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: grit
|
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: faye-websocket
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.3.5
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.5
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.9.2
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.9.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.14.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.14.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: cucumber
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: aruba
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: thin
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rack
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: anticipate
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description: Client library for publishing results to the Cucumber Pro service
|
154
|
+
email: hello@cucumber.pro
|
155
|
+
executables: []
|
156
|
+
extensions: []
|
157
|
+
extra_rdoc_files: []
|
158
|
+
files:
|
159
|
+
- Gemfile
|
160
|
+
- LICENSE
|
161
|
+
- README.md
|
162
|
+
- Rakefile
|
163
|
+
- TODO.md
|
164
|
+
- cucumber-pro.gemspec
|
165
|
+
- features/publish_results.feature
|
166
|
+
- features/step_definitions/steps.rb
|
167
|
+
- features/support/aruba.rb
|
168
|
+
- features/support/env.rb
|
169
|
+
- features/support/fake_results_service.rb
|
170
|
+
- features/support/world.rb
|
171
|
+
- lib/cucumber/pro.rb
|
172
|
+
- lib/cucumber/pro/formatter.rb
|
173
|
+
- lib/cucumber/pro/scm.rb
|
174
|
+
- lib/cucumber/pro/version.rb
|
175
|
+
- lib/cucumber/pro/web_socket_session.rb
|
176
|
+
homepage: https://cucumber.pro
|
177
|
+
licenses:
|
178
|
+
- MIT
|
179
|
+
metadata: {}
|
180
|
+
post_install_message:
|
181
|
+
rdoc_options:
|
182
|
+
- "--charset=UTF-8"
|
183
|
+
require_paths:
|
184
|
+
- lib
|
185
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
186
|
+
requirements:
|
187
|
+
- - ">="
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: 1.9.3
|
190
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
requirements: []
|
196
|
+
rubyforge_project:
|
197
|
+
rubygems_version: 2.0.14
|
198
|
+
signing_key:
|
199
|
+
specification_version: 4
|
200
|
+
summary: cucumber-pro-0.0.1
|
201
|
+
test_files:
|
202
|
+
- features/publish_results.feature
|
203
|
+
- features/step_definitions/steps.rb
|
204
|
+
- features/support/aruba.rb
|
205
|
+
- features/support/env.rb
|
206
|
+
- features/support/fake_results_service.rb
|
207
|
+
- features/support/world.rb
|
208
|
+
has_rdoc:
|