cucumber-eclipse-steps 0.0.1
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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +38 -0
- data/Rakefile +2 -0
- data/cucumber-eclipse-steps.gemspec +21 -0
- data/lib/cucumber/eclipse/steps/json.rb +110 -0
- data/lib/cucumber/eclipse/steps/version.rb +7 -0
- metadata +55 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Graham Agnew
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Cucumber::Eclipse::Steps
|
2
|
+
|
3
|
+
This is a Cucumber formatter gem that outputs the step definitions and steps
|
4
|
+
such that the cucumber.eclipse.steps.json Eclipse plugin can know where
|
5
|
+
the steps are defined.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'cucumber-eclipse-steps'
|
12
|
+
|
13
|
+
The gem can also be fecthed directly from the source on github:
|
14
|
+
|
15
|
+
gem 'cucumber-eclipse-steps', :git => 'https://github.com/graza/cucumber-eclipse-steps.git'
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install cucumber-eclipse-steps
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
The 'cucumber' command can load a formatter if the -f option uses its
|
28
|
+
class name. Therefore to use this formatter, the command would be thus:
|
29
|
+
|
30
|
+
$ cucumber -f Cucumber::Eclipse::Steps::Json <other-args>
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
1. Fork it
|
35
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
37
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
38
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/cucumber/eclipse/steps/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Graham Agnew"]
|
6
|
+
gem.email = ["graham.agnew@gmail.com"]
|
7
|
+
gem.description = <<-EOS
|
8
|
+
This is a Cucumber formatter gem that outputs the step definitions and steps
|
9
|
+
such that the cucumber.eclipse.steps.json Eclipse plugin can know where
|
10
|
+
the steps are defined.
|
11
|
+
EOS
|
12
|
+
gem.summary = %q{JSON formatter for cucumber.eclipse.steps.json plugin}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($\)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.name = "cucumber-eclipse-steps"
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
gem.version = Cucumber::Eclipse::Steps::VERSION
|
21
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require "cucumber/eclipse/steps/version"
|
2
|
+
require 'cucumber/formatter/io'
|
3
|
+
require 'cucumber/step_definition_light'
|
4
|
+
require 'multi_json'
|
5
|
+
|
6
|
+
module Cucumber
|
7
|
+
module Eclipse
|
8
|
+
module Steps
|
9
|
+
class Json
|
10
|
+
include Cucumber::Formatter::Io
|
11
|
+
|
12
|
+
class StepDefKey < Cucumber::StepDefinitionLight
|
13
|
+
attr_accessor :mean_duration, :status
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(runtime, path_or_io, options)
|
17
|
+
@runtime = runtime
|
18
|
+
@io = ensure_io(path_or_io, "usage")
|
19
|
+
@options = options
|
20
|
+
@stepdef_to_match = Hash.new{|h,stepdef_key| h[stepdef_key] = []}
|
21
|
+
end
|
22
|
+
|
23
|
+
#def before_features(features)
|
24
|
+
# print_profile_information
|
25
|
+
#end
|
26
|
+
|
27
|
+
def before_step(step)
|
28
|
+
@step = step
|
29
|
+
@start_time = Time.now
|
30
|
+
end
|
31
|
+
|
32
|
+
def before_step_result(*args)
|
33
|
+
@duration = Time.now - @start_time
|
34
|
+
end
|
35
|
+
|
36
|
+
def after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line)
|
37
|
+
step_definition = step_match.step_definition
|
38
|
+
unless step_definition.nil? # nil if it's from a scenario outline
|
39
|
+
stepdef_key = StepDefKey.new(step_definition.regexp_source, step_definition.file_colon_line)
|
40
|
+
|
41
|
+
@stepdef_to_match[stepdef_key] << {
|
42
|
+
:keyword => keyword,
|
43
|
+
:step_match => step_match.format_args,
|
44
|
+
:status => status,
|
45
|
+
:file_colon_line => @step.file_colon_line,
|
46
|
+
:duration => @duration
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def print_summary(features)
|
52
|
+
add_unused_stepdefs
|
53
|
+
aggregate_info
|
54
|
+
|
55
|
+
if @options[:dry_run]
|
56
|
+
keys = @stepdef_to_match.keys.sort {|a,b| a.regexp_source <=> b.regexp_source}
|
57
|
+
else
|
58
|
+
keys = @stepdef_to_match.keys.sort {|a,b| a.mean_duration <=> b.mean_duration}.reverse
|
59
|
+
end
|
60
|
+
|
61
|
+
step_definitions_array = keys.collect do |stepdef_key|
|
62
|
+
h = step_definition_hash(stepdef_key)
|
63
|
+
|
64
|
+
if @stepdef_to_match[stepdef_key].any?
|
65
|
+
h[:steps] = @stepdef_to_match[stepdef_key]
|
66
|
+
end
|
67
|
+
h
|
68
|
+
end
|
69
|
+
@io.write(MultiJson.dump(step_definitions_array, :pretty => true))
|
70
|
+
@io.puts
|
71
|
+
end
|
72
|
+
|
73
|
+
def step_definition_hash(stepdef_key)
|
74
|
+
{
|
75
|
+
:mean_duration => stepdef_key.mean_duration,
|
76
|
+
:regexp_source => stepdef_key.regexp_source,
|
77
|
+
:status => stepdef_key.status,
|
78
|
+
:file_colon_line => stepdef_key.file_colon_line
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
def aggregate_info
|
83
|
+
@stepdef_to_match.each do |key, steps|
|
84
|
+
if steps.empty?
|
85
|
+
key.status = :skipped
|
86
|
+
key.mean_duration = 0
|
87
|
+
else
|
88
|
+
key.status = worst_status(steps.map{ |step| step[:status] })
|
89
|
+
total_duration = steps.inject(0) {|sum, step| step[:duration] + sum}
|
90
|
+
key.mean_duration = total_duration / steps.length
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def worst_status(statuses)
|
96
|
+
[:passed, :undefined, :pending, :skipped, :failed].find do |status|
|
97
|
+
statuses.include?(status)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def add_unused_stepdefs
|
102
|
+
@runtime.unmatched_step_definitions.each do |step_definition|
|
103
|
+
stepdef_key = StepDefKey.new(step_definition.regexp_source, step_definition.file_colon_line)
|
104
|
+
@stepdef_to_match[stepdef_key] = []
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cucumber-eclipse-steps
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Graham Agnew
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-10-28 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: ! " This is a Cucumber formatter gem that outputs the step definitions
|
15
|
+
and steps\n such that the cucumber.eclipse.steps.json Eclipse plugin can know
|
16
|
+
where\n the steps are defined.\n"
|
17
|
+
email:
|
18
|
+
- graham.agnew@gmail.com
|
19
|
+
executables: []
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- .gitignore
|
24
|
+
- Gemfile
|
25
|
+
- LICENSE
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- cucumber-eclipse-steps.gemspec
|
29
|
+
- lib/cucumber/eclipse/steps/json.rb
|
30
|
+
- lib/cucumber/eclipse/steps/version.rb
|
31
|
+
homepage: ''
|
32
|
+
licenses: []
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
requirements: []
|
50
|
+
rubyforge_project:
|
51
|
+
rubygems_version: 1.8.23
|
52
|
+
signing_key:
|
53
|
+
specification_version: 3
|
54
|
+
summary: JSON formatter for cucumber.eclipse.steps.json plugin
|
55
|
+
test_files: []
|