gauge-ruby 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/code_parser.rb +1 -1
- data/lib/executor.rb +10 -2
- data/lib/gauge.rb +25 -11
- data/lib/gauge_messages.rb +54 -0
- data/lib/method_cache.rb +9 -4
- data/lib/processors/execution_handler.rb +2 -2
- data/lib/processors/execution_hook_processors.rb +8 -4
- data/lib/table.rb +28 -1
- metadata +15 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c12089561835ca4f98c3832d2507b37d9f0ba03f
|
4
|
+
data.tar.gz: 852373f669d336e8f828fbcb0f59d19fac3d251a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6aa6d61e8fa9f9904f49f646971efac4aa4f34a0f72f620f08fb95d4b47450f326d11242fc6e434339aa45bb0a21678bfcb7806d6d8e76e98224be7c93f849d
|
7
|
+
data.tar.gz: af4914cf14c84260a9c97a66e14ed124a9ae3ca9e29d31dc1fe2c7b8be1fb531c0b8c5c12e74ce233f59d869e0200d3c1a3d8f283216dfe0785ed52b55b5633d
|
data/lib/code_parser.rb
CHANGED
@@ -34,7 +34,7 @@ module Gauge
|
|
34
34
|
args = step_args_from_code code
|
35
35
|
param_positions.sort_by!(&:newPosition).each { |e|
|
36
36
|
if e.oldPosition == -1
|
37
|
-
new_params[e.newPosition] = new_param_values[e.newPosition]
|
37
|
+
new_params[e.newPosition] = "arg_#{new_param_values[e.newPosition].downcase.split.join('_')}"
|
38
38
|
else
|
39
39
|
new_params[e.newPosition] = args[e.oldPosition].children[0]
|
40
40
|
end
|
data/lib/executor.rb
CHANGED
@@ -33,10 +33,18 @@ module Gauge
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
def self.execute_hooks(hooks, currentExecutionInfo)
|
36
|
+
def self.execute_hooks(hooks, currentExecutionInfo, should_filter)
|
37
37
|
begin
|
38
38
|
hooks.each do |hook|
|
39
|
-
hook.
|
39
|
+
if !should_filter || hook[:options][:tags].length == 0
|
40
|
+
next hook[:block].call(currentExecutionInfo)
|
41
|
+
end
|
42
|
+
tags = currentExecutionInfo.currentSpec.tags + currentExecutionInfo.currentScenario.tags
|
43
|
+
intersection = (tags & hook[:options][:tags])
|
44
|
+
if (hook[:options][:operator] == 'OR' && intersection.length > 0) ||
|
45
|
+
(hook[:options][:operator] == 'AND' && intersection.length == hook[:options][:tags].length)
|
46
|
+
hook[:block].call(currentExecutionInfo)
|
47
|
+
end
|
40
48
|
end
|
41
49
|
return nil
|
42
50
|
rescue Exception => e
|
data/lib/gauge.rb
CHANGED
@@ -26,16 +26,30 @@ module Kernel
|
|
26
26
|
# @!macro [attach] self.hook
|
27
27
|
# @method $1(&block)
|
28
28
|
# @api public
|
29
|
-
# @param block [block]
|
29
|
+
# @param block [block] this block is called while executing the $1 hook
|
30
30
|
# @example
|
31
31
|
# $1 do
|
32
32
|
# puts "I am the $1 hook"
|
33
33
|
# end
|
34
34
|
def hook(hook)
|
35
|
-
define_method hook do
|
36
|
-
Gauge::MethodCache.send("add_#{hook}_hook".to_sym, &block)
|
35
|
+
define_method hook do |options={}, &block|
|
36
|
+
Gauge::MethodCache.send("add_#{hook}_hook".to_sym, options, &block)
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
# @!macro [attach] self.tagged_hook
|
41
|
+
# @method $1(options, &block)
|
42
|
+
# @api public
|
43
|
+
# @param block [block] this block is called while executing the $1 hook
|
44
|
+
# @param {{tags: ['list', 'of', 'tags'], operator: 'OR' | 'AND'}} options specify tags and operator for which this $1 execution hook should run.
|
45
|
+
# @example
|
46
|
+
# $1({tags: ['tag2', 'tag1'], operator: 'OR'}) do
|
47
|
+
# puts "I am the $1 hook"
|
48
|
+
# end
|
49
|
+
def tagged_hook(hook)
|
50
|
+
hook(hook)
|
51
|
+
end
|
52
|
+
|
39
53
|
end
|
40
54
|
|
41
55
|
# Specify implementation for a given step
|
@@ -69,7 +83,7 @@ module Kernel
|
|
69
83
|
# # |Mingle |Agile project management |
|
70
84
|
# # |Snap |Hosted continuous integration|
|
71
85
|
# # |Gocd |Continuous delivery platform |
|
72
|
-
#
|
86
|
+
#
|
73
87
|
# step 'Step that takes a table <table>' do |table|
|
74
88
|
# # note the extra <table> that is added to the description
|
75
89
|
# puts x.columns.join("|")
|
@@ -87,19 +101,19 @@ module Kernel
|
|
87
101
|
end
|
88
102
|
|
89
103
|
# Invoked before execution of every step.
|
90
|
-
|
104
|
+
tagged_hook "before_step"
|
91
105
|
# Invoked after execution of every step.
|
92
|
-
|
106
|
+
tagged_hook "after_step"
|
93
107
|
# Invoked before execution of every specification.
|
94
|
-
|
108
|
+
tagged_hook "before_spec"
|
95
109
|
# Invoked after execution of every specification.
|
96
|
-
|
110
|
+
tagged_hook "after_spec"
|
97
111
|
# Invoked before execution of every scenario.
|
98
|
-
|
112
|
+
tagged_hook "before_scenario"
|
99
113
|
# Invoked after execution of every scenario.
|
100
|
-
|
114
|
+
tagged_hook "after_scenario"
|
101
115
|
# Invoked before execution of the entire suite.
|
102
116
|
hook "before_suite"
|
103
117
|
# Invoked after execution of the entire suite.
|
104
118
|
hook "after_suite"
|
105
|
-
end
|
119
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Copyright 2015 ThoughtWorks, Inc.
|
2
|
+
|
3
|
+
# This file is part of Gauge-Ruby.
|
4
|
+
|
5
|
+
# Gauge-Ruby is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
|
10
|
+
# Gauge-Ruby is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with Gauge-Ruby. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
# @api public
|
19
|
+
module Gauge
|
20
|
+
class << self
|
21
|
+
# @api public
|
22
|
+
# Custom Messages for Gauge
|
23
|
+
# Lets you send custom execution messages to Gauge which are printed in reports.
|
24
|
+
#
|
25
|
+
# @example
|
26
|
+
# Gauge.write_message 'The answer is 42.'
|
27
|
+
def write_message(message)
|
28
|
+
GaugeMessages.instance.write(message)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# @api private
|
33
|
+
class GaugeMessages
|
34
|
+
def initialize
|
35
|
+
@messages = []
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.instance
|
39
|
+
@gauge_messages ||= GaugeMessages.new
|
40
|
+
end
|
41
|
+
|
42
|
+
def write(message)
|
43
|
+
@messages.push(message)
|
44
|
+
end
|
45
|
+
|
46
|
+
def get
|
47
|
+
@messages
|
48
|
+
end
|
49
|
+
|
50
|
+
def clear
|
51
|
+
@messages = []
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/method_cache.rb
CHANGED
@@ -20,14 +20,19 @@ module Gauge
|
|
20
20
|
# @api private
|
21
21
|
class MethodCache
|
22
22
|
["before_step", "after_step", "before_spec", "after_spec", "before_scenario", "after_scenario", "before_suite", "after_suite"].each { |hook|
|
23
|
-
define_singleton_method "add_#{hook}_hook" do
|
24
|
-
|
23
|
+
define_singleton_method "add_#{hook}_hook" do |options={}, &block|
|
24
|
+
options = {operator: "AND", tags: []}.merge options
|
25
|
+
self.class_variable_get("@@#{hook}_hooks").push :block=> block, :options=> options
|
25
26
|
end
|
26
27
|
define_singleton_method "get_#{hook}_hooks" do
|
27
28
|
self.class_variable_get("@@#{hook}_hooks")
|
28
29
|
end
|
29
30
|
}
|
30
|
-
|
31
|
+
|
32
|
+
def self.clear_hooks(hook)
|
33
|
+
self.class_variable_get("@@#{hook}_hooks").clear
|
34
|
+
end
|
35
|
+
|
31
36
|
def self.add_step(parameterized_step_text, &block)
|
32
37
|
@@steps_map[parameterized_step_text] = block
|
33
38
|
end
|
@@ -77,4 +82,4 @@ module Gauge
|
|
77
82
|
# hack : get the 'main' object and include the configured includes there.
|
78
83
|
# can be removed once we have scoped execution.
|
79
84
|
MethodCache.add_before_suite_hook { Configuration.include_configured_modules }
|
80
|
-
end
|
85
|
+
end
|
@@ -21,9 +21,9 @@ module Gauge
|
|
21
21
|
module Processors
|
22
22
|
# @api private
|
23
23
|
module ExecutionHandler
|
24
|
-
def handle_hooks_execution(hooks, message, currentExecutionInfo)
|
24
|
+
def handle_hooks_execution(hooks, message, currentExecutionInfo, should_filter=true)
|
25
25
|
start_time= Time.now
|
26
|
-
execution_error = Executor.execute_hooks(hooks, currentExecutionInfo)
|
26
|
+
execution_error = Executor.execute_hooks(hooks, currentExecutionInfo, should_filter)
|
27
27
|
if execution_error == nil
|
28
28
|
return handle_pass message, time_elapsed_since(start_time)
|
29
29
|
else
|
@@ -16,17 +16,18 @@
|
|
16
16
|
# along with Gauge-Ruby. If not, see <http://www.gnu.org/licenses/>.
|
17
17
|
|
18
18
|
require_relative "execution_handler"
|
19
|
+
require_relative "../gauge_messages"
|
19
20
|
|
20
21
|
module Gauge
|
21
22
|
module Processors
|
22
23
|
include ExecutionHandler
|
23
24
|
|
24
25
|
def process_execution_start_request(message)
|
25
|
-
handle_hooks_execution(MethodCache.get_before_suite_hooks, message, message.executionStartingRequest.currentExecutionInfo)
|
26
|
+
handle_hooks_execution(MethodCache.get_before_suite_hooks, message, message.executionStartingRequest.currentExecutionInfo,false)
|
26
27
|
end
|
27
28
|
|
28
29
|
def process_execution_end_request(message)
|
29
|
-
handle_hooks_execution(MethodCache.get_after_suite_hooks, message, message.executionEndingRequest.currentExecutionInfo)
|
30
|
+
handle_hooks_execution(MethodCache.get_after_suite_hooks, message, message.executionEndingRequest.currentExecutionInfo, false)
|
30
31
|
end
|
31
32
|
|
32
33
|
def process_spec_execution_start_request(message)
|
@@ -46,11 +47,14 @@ module Gauge
|
|
46
47
|
end
|
47
48
|
|
48
49
|
def process_step_execution_start_request(message)
|
50
|
+
Gauge::GaugeMessages.instance.clear
|
49
51
|
handle_hooks_execution(MethodCache.get_before_step_hooks, message, message.stepExecutionStartingRequest.currentExecutionInfo)
|
50
52
|
end
|
51
53
|
|
52
54
|
def process_step_execution_end_request(message)
|
53
|
-
handle_hooks_execution(MethodCache.get_after_step_hooks, message, message.stepExecutionEndingRequest.currentExecutionInfo)
|
55
|
+
response = handle_hooks_execution(MethodCache.get_after_step_hooks, message, message.stepExecutionEndingRequest.currentExecutionInfo)
|
56
|
+
response.executionStatusResponse.executionResult.message = Gauge::GaugeMessages.instance.get
|
57
|
+
return response
|
54
58
|
end
|
55
59
|
end
|
56
|
-
end
|
60
|
+
end
|
data/lib/table.rb
CHANGED
@@ -30,14 +30,41 @@ module Gauge
|
|
30
30
|
|
31
31
|
# Gets the column headers of the table
|
32
32
|
# @return [string[]]
|
33
|
+
# @deprecated Use [] accessor instead
|
33
34
|
def columns
|
34
35
|
@columns
|
35
36
|
end
|
36
37
|
|
37
38
|
# Gets the rows of the table. The rows are two dimensional arrays.
|
38
39
|
# @return [string[][]]
|
40
|
+
# @deprecated Use {#[]} accessor instead
|
39
41
|
def rows
|
40
42
|
@rows
|
41
43
|
end
|
44
|
+
|
45
|
+
# Gets the table data.
|
46
|
+
# @param index Either row index, or Column name.
|
47
|
+
# @return [Hash] When an integer index is passed. Values correspond to a the row in the table with the index.
|
48
|
+
# @example
|
49
|
+
# table[0] => {"Col1" => "Row1.Cell1", "Col2" => "Row2.Col1", ...}
|
50
|
+
# table[i] => nil # when index is out of range
|
51
|
+
# @return [string[]] When a string key is passed. Values correspond to the respective cells in a row, matching the index of value in Column headers.
|
52
|
+
# @example
|
53
|
+
# table["Col1"] => ["Row1.Cell1", "Row1.Cell1", ...]
|
54
|
+
# table["Invalid_Col_Name"] => nil
|
55
|
+
def [](index)
|
56
|
+
return row_values_as_hash(@rows[index]) if index.is_a?(Integer)
|
57
|
+
column_values_as_array(index)
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
def row_values_as_hash(row)
|
62
|
+
row.nil? ? nil : Hash[@columns.zip(row)]
|
63
|
+
end
|
64
|
+
|
65
|
+
def column_values_as_array(col_name)
|
66
|
+
i = @columns.index col_name
|
67
|
+
i.nil? ? nil : @rows.map { |r| r[i] }
|
68
|
+
end
|
42
69
|
end
|
43
|
-
end
|
70
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gauge-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gauge Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-protocol-buffers
|
@@ -42,28 +42,28 @@ dependencies:
|
|
42
42
|
name: parser
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '2.
|
47
|
+
version: '2.3'
|
48
48
|
type: :runtime
|
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: '2.
|
54
|
+
version: '2.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: method_source
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.8.2
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.8.2
|
69
69
|
description: Adds Ruby support into Gauge tests
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- lib/datastore.rb
|
81
81
|
- lib/executor.rb
|
82
82
|
- lib/gauge.rb
|
83
|
+
- lib/gauge_messages.rb
|
83
84
|
- lib/gauge_runtime.rb
|
84
85
|
- lib/message_processor.rb
|
85
86
|
- lib/messages.pb.rb
|
@@ -97,7 +98,7 @@ files:
|
|
97
98
|
- lib/table.rb
|
98
99
|
homepage: http://www.getgauge.io
|
99
100
|
licenses:
|
100
|
-
-
|
101
|
+
- GPL-3.0
|
101
102
|
metadata: {}
|
102
103
|
post_install_message:
|
103
104
|
rdoc_options: []
|
@@ -105,17 +106,17 @@ require_paths:
|
|
105
106
|
- lib
|
106
107
|
required_ruby_version: !ruby/object:Gem::Requirement
|
107
108
|
requirements:
|
108
|
-
- -
|
109
|
+
- - ">="
|
109
110
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
111
|
+
version: '1.9'
|
111
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
113
|
requirements:
|
113
|
-
- -
|
114
|
+
- - ">="
|
114
115
|
- !ruby/object:Gem::Version
|
115
|
-
version: '
|
116
|
+
version: '1.9'
|
116
117
|
requirements: []
|
117
118
|
rubyforge_project:
|
118
|
-
rubygems_version: 2.
|
119
|
+
rubygems_version: 2.4.6
|
119
120
|
signing_key:
|
120
121
|
specification_version: 4
|
121
122
|
summary: Ruby support for Gauge
|