timestamped-scenarios 0.1.0

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.
@@ -0,0 +1,4 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ example/cuke.html
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in timestamped-scenarios.gemspec
4
+ gemspec
@@ -0,0 +1,23 @@
1
+ What?
2
+ ==
3
+ This gem provides custom cucumber formatters which append a test run timestamp to each scenario name as it is generated. a `Timestamped::PrettyFormatter` and `Timestamped::HtmlFormatter` are supplied already, but you can use the `AddsTimestamp` module to dynamically add timestamping to pretty much any Cucumber formatter.
4
+
5
+ Why?
6
+ ==
7
+ My CI system is set up to record a screen capture movie of each test run. I use these timestamps to easily find a specific scenario's behaviour as recorded in the movie.
8
+
9
+ How?
10
+ ==
11
+ Install the gem with
12
+ gem install timestamped-scenarios
13
+ and then simply ask cucumber to use the custom formatters with
14
+ --format 'Timestamped::HtmlFormatter'
15
+ --format 'Timestamped::PrettyFormatter'
16
+
17
+ You can also configure cucumber to use the formatters in your rake cucumber task, or by using a cucumber.yml config file. Check out the cucumber.yml file in the example directory to see how this is done.
18
+
19
+ You can create additional Formatter subclasses as required by using the `Timestamped::AddsTimestamp#formatter_with_timestamped_scenario_names` method.
20
+
21
+ Credits
22
+ ==
23
+ Many thanks to Caleb Clausen for his metaprogramming wizardry, which cleaned up my implementation of `AddsTimestamp` greatly.
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1 @@
1
+ default: --format 'Timestamped::HtmlFormatter' --out cuke.html --format 'Timestamped::PrettyFormatter' the.feature
@@ -0,0 +1,4 @@
1
+ Given /^I wait (\d+\.?\d*) seconds$/ do |seconds|
2
+ seconds = seconds.to_f
3
+ sleep(seconds)
4
+ end
@@ -0,0 +1,10 @@
1
+ Feature: demonstration
2
+
3
+ Scenario: The First
4
+ Given I wait 5 seconds
5
+
6
+ Scenario: The Second
7
+ Given I wait 0.7 seconds
8
+ Given I wait 3 seconds
9
+
10
+ Scenario: The Third
@@ -0,0 +1,25 @@
1
+ module Timestamped
2
+ module AddsTimestamp
3
+
4
+ # we'll assume that the test run starts around the time this
5
+ # file is evaluated. Pretty hacky, and not terribly accurate, but
6
+ # I think it's good enough
7
+ TEST_RUN_START = Time.now
8
+
9
+ def self.formatter_with_timestamped_scenario_names(formatter_class)
10
+ Class.new( formatter_class ){ include AddsTimestamp }
11
+ end
12
+
13
+ def scenario_name(keyword, name, file_colon_line, source_indent)
14
+ name = append_timestamp_to(name)
15
+ super( keyword, name, file_colon_line, source_indent )
16
+ end
17
+
18
+
19
+ def append_timestamp_to( name )
20
+ ts = Time.now - TEST_RUN_START
21
+ formatted_timestamp = "%i:%02i" % [ts.to_i/60,(ts%60).round]
22
+ "#{name} [#{formatted_timestamp}]"
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,7 @@
1
+ require 'timestamped/adds_timestamp'
2
+
3
+ require 'cucumber/formatter/html'
4
+ module Timestamped
5
+ HtmlFormatter = AddsTimestamp.formatter_with_timestamped_scenario_names(Cucumber::Formatter::Html)
6
+ end
7
+
@@ -0,0 +1,7 @@
1
+ require 'timestamped/adds_timestamp'
2
+
3
+ require 'cucumber/formatter/pretty'
4
+ module Timestamped
5
+ PrettyFormatter = AddsTimestamp.formatter_with_timestamped_scenario_names(Cucumber::Formatter::Pretty)
6
+ end
7
+
@@ -0,0 +1,3 @@
1
+ module Timestamped
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "timestamped/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "timestamped-scenarios"
7
+ s.version = Timestamped::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Pete Hodgson"]
10
+ s.email = ["gems@thepete.net"]
11
+ s.homepage = "http://rubygems.org/gems/timestamped-scenarios"
12
+ s.summary = %q{custom cucumber formatters which append timestamps to each scenario's name as it is executed}
13
+ s.description = %q{custom cucumber formatters which append timestamps to each scenario's name as it is executed}
14
+
15
+ s.add_dependency "cucumber"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: timestamped-scenarios
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Pete Hodgson
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-11-20 00:00:00 -08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: cucumber
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ description: custom cucumber formatters which append timestamps to each scenario's name as it is executed
33
+ email:
34
+ - gems@thepete.net
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files: []
40
+
41
+ files:
42
+ - .gitignore
43
+ - Gemfile
44
+ - README.md
45
+ - Rakefile
46
+ - example/cucumber.yml
47
+ - example/step_definitions/steps.rb
48
+ - example/the.feature
49
+ - lib/timestamped/adds_timestamp.rb
50
+ - lib/timestamped/html_formatter.rb
51
+ - lib/timestamped/pretty_formatter.rb
52
+ - lib/timestamped/version.rb
53
+ - timestamped-scenarios.gemspec
54
+ has_rdoc: true
55
+ homepage: http://rubygems.org/gems/timestamped-scenarios
56
+ licenses: []
57
+
58
+ post_install_message:
59
+ rdoc_options: []
60
+
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ segments:
68
+ - 0
69
+ version: "0"
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ requirements: []
78
+
79
+ rubyforge_project:
80
+ rubygems_version: 1.3.6
81
+ signing_key:
82
+ specification_version: 3
83
+ summary: custom cucumber formatters which append timestamps to each scenario's name as it is executed
84
+ test_files: []
85
+