probedock-cucumber 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51a99b927ad1d4edd9c1c4a90c407b8a4743d262
4
- data.tar.gz: 3e264ed7f2ec4beb507fe2b472c0fafa06d4bf0e
3
+ metadata.gz: 3b8a22ced5c64326d8fe13be2993089380e56a6b
4
+ data.tar.gz: 60576e7c51c2f57a15161f1862415b8f6a0cb55a
5
5
  SHA512:
6
- metadata.gz: cdc350bb64b6b7a8630d76c36bd8df034d5c41512ae51480fb8ee3abf7905bd7279a6b0db44fc35aa2f7eebfa72dc3c1ace97b4d8e77da81d5bb5a044c78608d
7
- data.tar.gz: 21b1f8676d432f3276a92c26fafb7dbb363cfc1a612cb2e50337625d55a29ef3913c16e88c5e2ad641fb47f31e0d515a8c3914f8dccbc045f89da5b28ae0a1eb
6
+ metadata.gz: 0adc1369ff54f454bbe6f29b191114d41a73412dfc7ec459476e579a7e2cddab597768899a1b8da739da5225d0e4a83898aed2048900815f8e848382fcf21435
7
+ data.tar.gz: 797546ca2ed0ae4ff7793e631f4af281d7cdd6b37ac5550d5b6f6e11a9d293f777b68f3a212c154242131384eb9ab6ce7910393c2ef4918a2c40b4a6d87bfaba
data/Gemfile CHANGED
@@ -3,13 +3,13 @@ source "http://rubygems.org"
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
 
6
- gem 'probedock-ruby', '~> 0.1'
6
+ gem 'probedock-ruby', '~> 0.2.1'
7
7
 
8
8
  # Add dependencies to develop your gem here.
9
9
  # Include everything needed to run rake, tests, features, etc.
10
10
  group :development do
11
11
  gem 'jeweler', '~> 2.0'
12
- gem 'rake-version', '~> 0.4'
12
+ gem 'rake-version', '~> 1.0'
13
13
  gem 'simplecov', '~> 0.10', require: false
14
14
  gem 'fakefs', '~> 0.6', require: 'fakefs/safe'
15
15
  gem 'rspec', '~> 3.1'
data/README.md CHANGED
@@ -8,16 +8,34 @@
8
8
  [![Coverage Status](https://coveralls.io/repos/probedock/probedock-cucumber-ruby/badge.svg)](https://coveralls.io/r/probedock/probedock-cucumber-ruby?branch=master)
9
9
  [![License](https://img.shields.io/github/license/probedock/probedock-cucumber-ruby.svg)](LICENSE.txt)
10
10
 
11
+
12
+
11
13
  ## Installation
12
14
 
13
15
  In your Gemfile:
14
16
 
15
17
  ```rb
16
- gem 'probedock-cucumber', '~> 0.1.1'
18
+ gem 'probedock-cucumber', '~> 0.1.2'
17
19
  ```
18
20
 
19
21
  Then run `bundle install`.
20
22
 
23
+
24
+
25
+ ## Usage
26
+
27
+ In your specification configuration file, configure the probe:
28
+
29
+ ```rb
30
+ ProbeDockCucumber.configure do |config|
31
+ config.project.category = 'Cucumber'
32
+ end
33
+ ```
34
+
35
+ With [cucumber-rails](https://github.com/cucumber/cucumber-rails), the configuration file is `features/support/env.rb` with the default setup.
36
+
37
+
38
+
21
39
  ## Contributing
22
40
 
23
41
  * [Fork](https://help.github.com/articles/fork-a-repo)
@@ -27,6 +45,8 @@ Then run `bundle install`.
27
45
 
28
46
  Please add a [changelog](CHANGELOG.md) entry with your name for new features and bug fixes.
29
47
 
48
+
49
+
30
50
  ## License
31
51
 
32
52
  Probe Dock Cucumber is licensed under the [MIT License](http://opensource.org/licenses/MIT).
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -2,7 +2,7 @@
2
2
  require 'probedock-ruby'
3
3
 
4
4
  module ProbeDockCucumber
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
 
7
7
  class Error < StandardError; end
8
8
  end
@@ -1,6 +1,15 @@
1
1
  module ProbeDockCucumber
2
+ def self.config
3
+ @config ||= ProbeDockProbe::Config.new
4
+ end
5
+
6
+ def self.config= config
7
+ @config = config
8
+ end
9
+
2
10
  def self.configure options = {}, &block
3
- ProbeDockProbe.config.load! &block
4
- ProbeDockProbe.config
11
+ config.project.category = 'Cucumber'
12
+ config.load! &block
13
+ config
5
14
  end
6
15
  end
@@ -32,14 +32,15 @@ require 'digest/sha1'
32
32
  module ProbeDockCucumber
33
33
  class Formatter
34
34
 
35
- def initialize step_mother, io, options
35
+ def initialize(step_mother, io, options)
36
36
 
37
37
  # Initialize the Probe Dock client and an empty test run.
38
- config = ProbeDockProbe.config
39
- @client = ProbeDockProbe::Client.new config.server, config.client_options
40
- @test_run = ProbeDockProbe::TestRun.new config.project
38
+ config = ProbeDockCucumber.config
39
+ @client = ProbeDockProbe::Client.new(config.server, config.client_options)
40
+ @test_run = ProbeDockProbe::TestRun.new(config.project)
41
41
 
42
42
  # Current feature data.
43
+ @current_feature_started = false
43
44
  @current_feature = nil
44
45
  @current_feature_tags = []
45
46
 
@@ -50,12 +51,12 @@ module ProbeDockCucumber
50
51
  end
51
52
 
52
53
  # Called when the test suite starts.
53
- def before_features *args
54
+ def before_features(*args)
54
55
  @suite_start_time = Time.now
55
56
  end
56
57
 
57
58
  # Called before each feature is tested.
58
- def before_feature feature, *args
59
+ def before_feature(feature, *args)
59
60
 
60
61
  # Store the first line of the feature's description.
61
62
  # It will be used in #add_result to build the complete name of the test.
@@ -68,8 +69,13 @@ module ProbeDockCucumber
68
69
  @current_scenario_error = nil
69
70
  end
70
71
 
72
+ # Called for the feature name and after the before feature has been called
73
+ def feature_name(*args)
74
+ @current_feature_started = true
75
+ end
76
+
71
77
  # Called every time a tag is encountered, either at the feature or the scenario level.
72
- def tag_name name, *args
78
+ def tag_name(name, *args)
73
79
  if @current_scenario
74
80
  @current_scenario_tags << name.sub(/^@/, '').strip
75
81
  else
@@ -78,7 +84,7 @@ module ProbeDockCucumber
78
84
  end
79
85
 
80
86
  # Called before each scenario is tested.
81
- def before_feature_element feature_element, *args
87
+ def before_feature_element(feature_element, *args)
82
88
 
83
89
  # Store the first line of the scenario's description.
84
90
  # It will be used in #add_result to build the complete name of the test.
@@ -90,23 +96,46 @@ module ProbeDockCucumber
90
96
  @current_scenario_start_time = Time.now
91
97
  end
92
98
 
99
+ # Called for each comment line
100
+ def comment_line(comment)
101
+ # Take care of annotation only if matched
102
+ if comment.match(ProbeDockProbe::Annotation::ANNOTATION_REGEXP)
103
+ # If the feature already started, the annotations are for scenarios
104
+ if @current_feature_started
105
+ @annotation = ProbeDockProbe::Annotation.new(comment)
106
+ else
107
+ @feature_annotation = ProbeDockProbe::Annotation.new(comment)
108
+ end
109
+ end
110
+ end
111
+
112
+ def scenario_name(keyword, name, file_colon_line, *args)
113
+ @current_scenario_file_colon_line = file_colon_line
114
+ end
115
+
93
116
  # Called after each scenario step (Given, When, Then) is executed.
94
- def after_step_result keyword, step_match, multiline_arg, status, exception, *args
117
+ def after_step_result(keyword, step_match, multiline_arg, status, exception, *args)
95
118
  # If a step fails, the exception is provided here.
96
119
  # It will be used in #add_result to build the error message of the test.
97
120
  @current_scenario_error = exception if exception
98
121
  end
99
122
 
100
123
  # Called after each completed scenario.
101
- def after_feature_element *args
124
+ def after_feature_element(*args)
102
125
  add_result
103
126
  end
104
127
 
128
+ # Called after the feature has been executed
129
+ def after_feature(*args)
130
+ @current_feature_started = false
131
+ @feature_annotation = nil
132
+ end
133
+
105
134
  # Called when the test suite ends.
106
- def after_features *args
135
+ def after_features(*args)
107
136
  end_time = Time.now
108
137
  @test_run.duration = ((end_time - @suite_start_time) * 1000).round
109
- @client.process @test_run
138
+ @client.process(@test_run)
110
139
  end
111
140
 
112
141
  private
@@ -122,6 +151,17 @@ module ProbeDockCucumber
122
151
  data: {}
123
152
  }
124
153
 
154
+ if @annotation && @feature_annotation # Annotation on current feature and current scenario
155
+ @feature_annotation.merge!(@annotation)
156
+ result_options[:annotation] = @feature_annotation
157
+ elsif @annotation # Annotation only for current scenario
158
+ result_options[:annotation] = @annotation
159
+ elsif @feature_annotation # Annotation for the current feature
160
+ result_options[:annotation] = @feature_annotation
161
+ end
162
+
163
+ @annotation = nil
164
+
125
165
  result_options[:duration] = ((Time.now - @current_scenario_start_time) * 1000).round
126
166
 
127
167
  # Combine the tags of the feature and of the scenario.
@@ -130,13 +170,21 @@ module ProbeDockCucumber
130
170
  # The fingerprint identifying the test contains the first line of the
131
171
  # feature's and the scenario's descriptions joined with a separator.
132
172
  fingerprint_data = [ @current_feature, @current_scenario ]
133
- result_options[:fingerprint] = Digest::SHA1.hexdigest fingerprint_data.join('|||')
173
+ result_options[:fingerprint] = Digest::SHA1.hexdigest(fingerprint_data.join('|||'))
134
174
  result_options[:data][:fingerprint] = result_options[:fingerprint]
135
175
 
136
176
  # Build the message from the error's message and backtrace if an error occurred.
137
177
  result_options[:message] = failure_message @current_scenario_error if @current_scenario_error
138
178
 
139
- @test_run.add_result result_options
179
+ metadata = result_options[:data]
180
+
181
+ # Add the file and line number to the metadata.
182
+ if @current_scenario_file_colon_line && m = @current_scenario_file_colon_line.match(/^([^:]+):(\d+)$/)
183
+ metadata['file.path'] = m[1].to_s
184
+ metadata['file.line'] = m[2].to_i
185
+ end
186
+
187
+ @test_run.add_result(result_options)
140
188
  end
141
189
 
142
190
  # Builds the complete test name.
@@ -147,7 +195,7 @@ module ProbeDockCucumber
147
195
  def complete_name
148
196
 
149
197
  name = @current_feature.dup
150
- if name.match /\.$/
198
+ if name.match(/\.$/)
151
199
  name << ' '
152
200
  else
153
201
  name << ': '
@@ -156,7 +204,7 @@ module ProbeDockCucumber
156
204
  name << @current_scenario
157
205
  end
158
206
 
159
- def failure_message error
207
+ def failure_message(error)
160
208
  String.new.tap do |m|
161
209
  m << error.message
162
210
  m << "\n"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: probedock-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Oulevay (Alpha Hydrae)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-03 00:00:00.000000000 Z
11
+ date: 2016-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: probedock-ruby
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.1'
19
+ version: 0.2.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.1'
26
+ version: 0.2.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: jeweler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.4'
47
+ version: '1.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.4'
54
+ version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: simplecov
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  version: '0'
174
174
  requirements: []
175
175
  rubyforge_project:
176
- rubygems_version: 2.4.8
176
+ rubygems_version: 2.4.6
177
177
  signing_key:
178
178
  specification_version: 4
179
179
  summary: Cucumber client to publish test results to Probe Dock.