Class: LimitedRed::Cucumber::Formatter::Stats
- Inherits:
-
Cucumber::Formatter::Json
- Object
- Cucumber::Formatter::Json
- LimitedRed::Cucumber::Formatter::Stats
- Defined in:
- lib/limited_red/cucumber/formatter/stats.rb
Instance Method Summary collapse
- #after_feature(feature) ⇒ Object
- #after_features(features) ⇒ Object
- #failing_files ⇒ Object
- #feature_hash ⇒ Object
- #gherkin_formatter ⇒ Object
-
#initialize(step_mother, path_or_io, options) ⇒ Stats
constructor
A new instance of Stats.
- #passing_files ⇒ Object
- #print_summary ⇒ Object
- #supports_feature_hash? ⇒ Boolean
Constructor Details
#initialize(step_mother, path_or_io, options) ⇒ Stats
Returns a new instance of Stats.
10 11 12 13 14 15 16 17 |
# File 'lib/limited_red/cucumber/formatter/stats.rb', line 10 def initialize(step_mother, path_or_io, ) @t = Time.now @build_id = Time.now.to_i @step_mother = step_mother @client = LimitedRed::Client.new(LimitedRed::Config.load_and_validate_config('cucumber')) super end |
Instance Method Details
#after_feature(feature) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/limited_red/cucumber/formatter/stats.rb', line 19 def after_feature(feature) if supports_feature_hash? json = feature_hash.to_json @client.log_result(@build_id, :result => json, :uri => feature_hash['uri']) else puts "[limited_red]:Error: Having trouble working with your Gherkin version. Is it upto date? Report this to [email protected], its his fault.", "" end end |
#after_features(features) ⇒ Object
29 30 31 |
# File 'lib/limited_red/cucumber/formatter/stats.rb', line 29 def after_features(features) print_summary end |
#failing_files ⇒ Object
40 41 42 43 44 |
# File 'lib/limited_red/cucumber/formatter/stats.rb', line 40 def failing_files failures = @step_mother.scenarios(:failed).select { |s| s.is_a?(::Cucumber::Ast::Scenario) || s.is_a?(::Cucumber::Ast::OutlineTable::ExampleRow) } failures = failures.collect { |s| (s.is_a?(::Cucumber::Ast::OutlineTable::ExampleRow)) ? s.scenario_outline : s } failures.map{|fail| fail.file_colon_line} end |
#feature_hash ⇒ Object
56 57 58 |
# File 'lib/limited_red/cucumber/formatter/stats.rb', line 56 def feature_hash gherkin_formatter.instance_variable_get("@feature_hash") || gherkin_formatter.instance_variable_get(:@feature_hash) end |
#gherkin_formatter ⇒ Object
60 61 62 |
# File 'lib/limited_red/cucumber/formatter/stats.rb', line 60 def gherkin_formatter @gf end |
#passing_files ⇒ Object
46 47 48 49 50 |
# File 'lib/limited_red/cucumber/formatter/stats.rb', line 46 def passing_files passing = @step_mother.scenarios(:passed).select { |s| s.is_a?(::Cucumber::Ast::Scenario) || s.is_a?(::Cucumber::Ast::OutlineTable::ExampleRow) } passing = passing.collect { |s| (s.is_a?(::Cucumber::Ast::OutlineTable::ExampleRow)) ? s.scenario_outline : s } passing.map{|pass| pass.file_colon_line} end |
#print_summary ⇒ Object
33 34 35 36 37 38 |
# File 'lib/limited_red/cucumber/formatter/stats.rb', line 33 def print_summary @client.log_build(@build_id, {:fails => failing_files, :passes => passing_files}) ThreadPool.wait_for_all_threads_to_finish end |
#supports_feature_hash? ⇒ Boolean
52 53 54 |
# File 'lib/limited_red/cucumber/formatter/stats.rb', line 52 def supports_feature_hash? gherkin_formatter.instance_variables.include?(:@feature_hash) || gherkin_formatter.instance_variables.include?('@feature_hash') end |