limited_red 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
data/lib/limited_red.rb
CHANGED
@@ -2,7 +2,6 @@ $:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(_
|
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'httparty'
|
5
|
-
require 'cucumber'
|
6
5
|
|
7
6
|
module LimitedRed
|
8
7
|
ROOT = File.expand_path('..', __FILE__).to_s
|
@@ -14,12 +13,14 @@ module LimitedRed
|
|
14
13
|
autoload :Stats, "#{ROOT}/limited_red/stats"
|
15
14
|
autoload :Config, "#{ROOT}/limited_red/config"
|
16
15
|
autoload :Version, "#{ROOT}/limited_red/version"
|
17
|
-
|
16
|
+
|
18
17
|
module Adapter
|
19
18
|
autoload :HttParty, "#{ROOT}/limited_red/adapter/httparty"
|
20
19
|
end
|
21
20
|
|
22
|
-
module
|
23
|
-
|
21
|
+
module Cucumber
|
22
|
+
module Formatter
|
23
|
+
autoload :Stats, "#{ROOT}/limited_red/cucumber/formatter/stats"
|
24
|
+
end
|
24
25
|
end
|
25
26
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'cucumber'
|
2
|
+
require 'cucumber/formatter/json'
|
3
|
+
require 'limited_red/client'
|
4
|
+
|
5
|
+
module LimitedRed
|
6
|
+
module Cucumber
|
7
|
+
module Formatter
|
8
|
+
class Stats < ::Cucumber::Formatter::Json
|
9
|
+
|
10
|
+
def initialize(step_mother, path_or_io, options)
|
11
|
+
@t = Time.now
|
12
|
+
@build_id = Time.now.to_i
|
13
|
+
@step_mother = step_mother
|
14
|
+
@client = LimitedRed::Client.new(LimitedRed::Config.load_and_validate_config)
|
15
|
+
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def after_feature(feature)
|
20
|
+
if supports_feature_hash?
|
21
|
+
json = feature_hash.to_json
|
22
|
+
@client.log_result(@build_id, :result => json)
|
23
|
+
else
|
24
|
+
puts "Error: Gherkin version is out of date and does not support @feature_hash: #{gherkin_formatter.instance_variables}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def after_features(features)
|
29
|
+
print_summary
|
30
|
+
end
|
31
|
+
|
32
|
+
def print_summary
|
33
|
+
@client.log_build(@build_id, {:fails => failing_files,
|
34
|
+
:passes => passing_files})
|
35
|
+
|
36
|
+
ThreadPool.wait_for_all_threads_to_finish
|
37
|
+
end
|
38
|
+
|
39
|
+
def failing_files
|
40
|
+
failures = @step_mother.scenarios(:failed).select { |s| s.is_a?(::Cucumber::Ast::Scenario) || s.is_a?(::Cucumber::Ast::OutlineTable::ExampleRow) }
|
41
|
+
failures = failures.collect { |s| (s.is_a?(::Cucumber::Ast::OutlineTable::ExampleRow)) ? s.scenario_outline : s }
|
42
|
+
failures.map{|fail| fail.file_colon_line}
|
43
|
+
end
|
44
|
+
|
45
|
+
def passing_files
|
46
|
+
passing = @step_mother.scenarios(:passed).select { |s| s.is_a?(::Cucumber::Ast::Scenario) || s.is_a?(::Cucumber::Ast::OutlineTable::ExampleRow) }
|
47
|
+
passing = passing.collect { |s| (s.is_a?(::Cucumber::Ast::OutlineTable::ExampleRow)) ? s.scenario_outline : s }
|
48
|
+
passing.map{|pass| pass.file_colon_line}
|
49
|
+
end
|
50
|
+
|
51
|
+
def supports_feature_hash?
|
52
|
+
gherkin_formatter.instance_variables.include?(:@feature_hash)
|
53
|
+
end
|
54
|
+
|
55
|
+
def feature_hash
|
56
|
+
gherkin_formatter.instance_variable_get("@feature_hash")
|
57
|
+
end
|
58
|
+
|
59
|
+
def gherkin_formatter
|
60
|
+
@gf
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -3,7 +3,7 @@ AfterConfiguration do |config|
|
|
3
3
|
require 'limited_red'
|
4
4
|
|
5
5
|
options = config.instance_variable_get("@options")
|
6
|
-
options[:formats] << ['LimitedRed::Formatter::Stats', config.out_stream]
|
6
|
+
options[:formats] << ['LimitedRed::Cucumber::Formatter::Stats', config.out_stream]
|
7
7
|
|
8
8
|
limited_red_config = LimitedRed::Config.load_and_validate_config
|
9
9
|
if limited_red_config
|
@@ -0,0 +1,13 @@
|
|
1
|
+
RSpec.configure do |config|
|
2
|
+
config.after(:each) do
|
3
|
+
metadata = example.metadata
|
4
|
+
full_description = example.metadata[:full_description]
|
5
|
+
file, line = *(example.metadata[:example_group_block].source_location)
|
6
|
+
|
7
|
+
if example.exception #Fail
|
8
|
+
puts "FAIL", file, line
|
9
|
+
else # Pass
|
10
|
+
puts "PASS", file, line
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/limited_red/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: limited_red
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-01-02 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement: &
|
16
|
+
requirement: &70246371248880 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - =
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.8.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70246371248880
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: cucumber
|
27
|
-
requirement: &
|
27
|
+
requirement: &70246371306260 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 1.1.4
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70246371306260
|
36
36
|
description: Learn and adapt from you test metrics. Used with the www.limited-red.com
|
37
37
|
service. Tests are priorited by the probability of failure
|
38
38
|
email: joe@josephwilk.net
|
@@ -45,9 +45,10 @@ files:
|
|
45
45
|
- lib/limited_red/adapter/httparty.rb
|
46
46
|
- lib/limited_red/client.rb
|
47
47
|
- lib/limited_red/config.rb
|
48
|
-
- lib/limited_red/formatter/stats.rb
|
48
|
+
- lib/limited_red/cucumber/formatter/stats.rb
|
49
49
|
- lib/limited_red/gzip.rb
|
50
|
-
- lib/limited_red/
|
50
|
+
- lib/limited_red/plugins/cucumber.rb
|
51
|
+
- lib/limited_red/plugins/rspec.rb
|
51
52
|
- lib/limited_red/stats.rb
|
52
53
|
- lib/limited_red/thread_pool.rb
|
53
54
|
- lib/limited_red/version.rb
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'cucumber/formatter/json'
|
2
|
-
require 'limited_red/client'
|
3
|
-
|
4
|
-
module LimitedRed
|
5
|
-
module Formatter
|
6
|
-
class Stats < Cucumber::Formatter::Json
|
7
|
-
|
8
|
-
def initialize(step_mother, path_or_io, options)
|
9
|
-
@t = Time.now
|
10
|
-
@build_id = Time.now.to_i
|
11
|
-
@step_mother = step_mother
|
12
|
-
@client = LimitedRed::Client.new(LimitedRed::Config.load_and_validate_config)
|
13
|
-
|
14
|
-
super
|
15
|
-
end
|
16
|
-
|
17
|
-
def after_feature(feature)
|
18
|
-
if supports_feature_hash?
|
19
|
-
json = feature_hash.to_json
|
20
|
-
@client.log_result(@build_id, :result => json)
|
21
|
-
else
|
22
|
-
puts "Error: Gherkin version is out of date and does not support @feature_hash: #{gherkin_formatter.instance_variables}"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def after_features(features)
|
27
|
-
print_summary
|
28
|
-
end
|
29
|
-
|
30
|
-
def print_summary
|
31
|
-
@client.log_build(@build_id, {:fails => failing_files,
|
32
|
-
:passes => passing_files})
|
33
|
-
|
34
|
-
ThreadPool.wait_for_all_threads_to_finish
|
35
|
-
end
|
36
|
-
|
37
|
-
def failing_files
|
38
|
-
failures = @step_mother.scenarios(:failed).select { |s| s.is_a?(Cucumber::Ast::Scenario) || s.is_a?(Cucumber::Ast::OutlineTable::ExampleRow) }
|
39
|
-
failures = failures.collect { |s| (s.is_a?(Cucumber::Ast::OutlineTable::ExampleRow)) ? s.scenario_outline : s }
|
40
|
-
failures.map{|fail| fail.file_colon_line}
|
41
|
-
end
|
42
|
-
|
43
|
-
def passing_files
|
44
|
-
passing = @step_mother.scenarios(:passed).select { |s| s.is_a?(Cucumber::Ast::Scenario) || s.is_a?(Cucumber::Ast::OutlineTable::ExampleRow) }
|
45
|
-
passing = passing.collect { |s| (s.is_a?(Cucumber::Ast::OutlineTable::ExampleRow)) ? s.scenario_outline : s }
|
46
|
-
passing.map{|pass| pass.file_colon_line}
|
47
|
-
end
|
48
|
-
|
49
|
-
def supports_feature_hash?
|
50
|
-
gherkin_formatter.instance_variables.include?(:@feature_hash)
|
51
|
-
end
|
52
|
-
|
53
|
-
def feature_hash
|
54
|
-
gherkin_formatter.instance_variable_get("@feature_hash")
|
55
|
-
end
|
56
|
-
|
57
|
-
def gherkin_formatter
|
58
|
-
@gf
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|