jira-cucumber 0.0.3.pre1

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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 35be64cd78d0556884a4a257c1ef3870da4ce2c7
4
+ data.tar.gz: 7b1341624824f068b1f07f0e1aab1ac685b0e93a
5
+ SHA512:
6
+ metadata.gz: ce9fd857c1f2cff154c6a1f3fdce913256fce2083e86e5aecbbeac9bd46ee499e8548c2604f75e5dc66290c9a5d668144f0a7a1ac13f9f64b8dd3f8ef95d7760
7
+ data.tar.gz: d08111830ca513f39971ff314bb6becb73b01051fe51ba02614062cfadb5c49b133af25a92ab5351dc3dcd764c0f2ac729daa59a7214dcb9d2e67255e21193d9
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea/*
19
+ *.swp
20
+ *.swo
21
+ jiralicious.yml
@@ -0,0 +1,12 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 1.8.7
4
+
5
+ # whitelist
6
+ branches:
7
+ only:
8
+ - master
9
+
10
+ notifications:
11
+ email:
12
+ - calebtom87@gmail.com
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ #gem 'cucumber', :git => 'git://github.com/calebTomlinson/cucumber.git', :branch => 'examples_tags'
4
+
5
+ # Specify your gem's dependencies in jira-cucumber.gemspec
6
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Caleb Tomlinson
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.
@@ -0,0 +1,29 @@
1
+ # JiraFormatter
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'jira-cucumber'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install jira-cucumber
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ task :default => :spec
5
+
6
+ RSpec::Core::RakeTask.new do |t|
7
+
8
+ end
@@ -0,0 +1 @@
1
+ This Cucumber framework is not functional for testing. It is invoked by the rspec tests for integration testing.
@@ -0,0 +1,7 @@
1
+ @feature_tag
2
+ Feature: The formatter doesn't croak
3
+
4
+ @scenario_tag_1
5
+ Scenario: A simple scenario
6
+
7
+ Given a passing step with a <parameter>
@@ -0,0 +1,37 @@
1
+ @feature-tag
2
+ Feature: A complicated feature
3
+
4
+ @basic-scenario-tag
5
+ @second-basic-scenario-tag
6
+ Scenario: passing scenario
7
+
8
+ Given a passing step with a parameter
9
+ Then it passes
10
+
11
+ @failing-basic
12
+ Scenario: failing scenario
13
+
14
+ Given a passing step with a parameter
15
+ Then it fails
16
+
17
+ @outline-tag
18
+ Scenario Outline: An outline
19
+
20
+ Given I set a resource <resource>
21
+ Given a passing step with a <param>
22
+ Then it <pass_or_fail>
23
+
24
+ @scenarios-section-tag
25
+ Scenarios: some scenarios
26
+ | param | pass_or_fail | resource |
27
+ | parameter | passes | value_a |
28
+ | parameter | fails | value_a |
29
+ | missing | irrelevant | value_a |
30
+
31
+ @examples-section-tag
32
+ Examples: some examples... because we like having two syntaxes
33
+ | param | pass_or_fail | resource |
34
+ | parameter | passes | value_b |
35
+ | parameter | fails | value_b |
36
+ | missing | irrelevant | value_b |
37
+
@@ -0,0 +1,15 @@
1
+ Given /^a passing step with a <parameter>$/ do
2
+ x=1
3
+ end
4
+ Given(/^a passing step with a parameter$/) do
5
+ x=1
6
+ end
7
+ Then(/^it passes$/) do
8
+ x=1
9
+ end
10
+ Then(/^it fails$/) do
11
+ raise StandardError
12
+ end
13
+ Given(/^I set a resource (.*)$/) do |resource|
14
+ $resource = resource
15
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jira_formatter/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jira-cucumber"
8
+ spec.version = JiraFormatter::VERSION
9
+ spec.authors = ["Caleb Tomlinson"]
10
+ spec.email = ["ctomlinson@opentable.com"]
11
+ spec.description = %q{Jira reporting for cucumber tests}
12
+ spec.summary = %q{Jira reporting for cucumber tests}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_runtime_dependency 'jiralicious'
24
+
25
+ spec.platform = Gem::Platform::RUBY
26
+ #spec.add_development_dependency 'cucumber'
27
+ spec.add_development_dependency 'rspec', '> 2.0'
28
+ spec.add_development_dependency 'vcr', '2.5.0'
29
+ end
@@ -0,0 +1 @@
1
+ require 'jira_formatter/formatter'
@@ -0,0 +1,67 @@
1
+ require "jira_formatter/version"
2
+ require 'jira_formatter/jira_interface'
3
+
4
+ module JiraFormatter
5
+ #responds to the cucumber formatter methods and parses the relevant information
6
+ #only class to talk to cucumber libs!
7
+ class Formatter
8
+ #gets called by cucumber to initialize reporting
9
+ def initialize(step_mother, io, options)
10
+ @step_mother, @io, @options = step_mother, io, options
11
+ end
12
+
13
+ #gets called by cucumber after all features have completed
14
+ #this is the starting point of all reporting
15
+ def after_features(*args)
16
+ @scenarios = failed_and_passed
17
+ JiraInterface.new.report(formatted_scenarios)
18
+ end
19
+
20
+ private
21
+
22
+ def failed_and_passed
23
+ failures = @step_mother.scenarios(:failed).select { |s|
24
+ s.is_a?(Cucumber::Ast::Scenario) || s.is_a?(Cucumber::Ast::OutlineTable::ExampleRow) }
25
+ passes = @failures = @step_mother.scenarios(:passed).select { |s| s.is_a?(Cucumber::Ast::Scenario) || s.is_a?(Cucumber::Ast::OutlineTable::ExampleRow) }
26
+ return failures + passes
27
+ end
28
+
29
+ def formatted_scenarios
30
+ @scenarios.map do |scenario|
31
+ properties = Hash.new()
32
+ properties[:run_time] = Time.new()
33
+ properties[:tags] = scenario.source_tag_names
34
+ properties[:status] = scenario.status
35
+ properties[:domain] = determine_domain(scenario)
36
+ if properties[:status] == :failed
37
+
38
+ end
39
+
40
+ if scenario.class == Cucumber::Ast::Scenario
41
+ properties.merge build_from_scenario(scenario)
42
+ elsif scenario.class == Cucumber::Ast::OutlineTable::ExampleRow
43
+ properties.merge build_from_example_row(scenario)
44
+ end
45
+ end
46
+ end
47
+
48
+ def determine_domain(scenario)
49
+
50
+ end
51
+
52
+ def build_from_scenario(scenario)
53
+ {
54
+ :feature => scenario.feature.name,
55
+ :scenario => scenario.name
56
+ }
57
+ end
58
+
59
+ def build_from_example_row(example_row)
60
+ {
61
+ :feature => example_row.scenario_outline.feature.name,
62
+ :scenario => example_row.scenario_outline.name,
63
+ :row => example_row.name
64
+ }
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,61 @@
1
+ module JiraFormatter
2
+ class Issue
3
+
4
+ def initialize(scenario)
5
+ @hash = scenario
6
+ search_results = search_for_existing_issue
7
+ if search_results.num_results == 0
8
+ build_issue
9
+ else
10
+ load_issue(search_results)
11
+ end
12
+ update_issue
13
+ end
14
+
15
+ private
16
+
17
+ def summary
18
+ "#{@hash[:feature]} | #{@hash[:scenario]} | #{@hash[:row]}"
19
+ end
20
+
21
+ def search_for_existing_issue
22
+ search_string = "project = #{JiraConfiguration.instance.project['id']} AND summary ~ '#{summary}'"
23
+ Jiralicious.search(search_string)
24
+ end
25
+
26
+ def build_issue
27
+ @jissue = Jiralicious::Issue.new
28
+ @jissue.fields.set_id("project", JiraConfiguration.instance.project['id'])
29
+ @jissue.fields.set("summary", summary)
30
+ @jissue.fields.set_id("issuetype", JiraConfiguration.instance.default_issue_type['id'])
31
+ @jissue.save!
32
+ end
33
+
34
+ def load_issue(search_results)
35
+ @jissue = Jiralicious::Issue.find(search_results.issues[0].jira_key)
36
+ end
37
+
38
+ def update_issue
39
+ @jissue.fields.set('labels', @hash[:tags])
40
+ @jissue.save
41
+ transition_issue
42
+ add_comments
43
+ end
44
+
45
+ def status
46
+ @jissue.fields.fields_current['status']['id'].to_i
47
+ end
48
+
49
+ def transition_issue
50
+ transition = JiraConfiguration.instance.transitions[status][@hash[:status].to_s]
51
+ if transition
52
+ Jiralicious::Issue.transition("#{@jissue.jira_self}/transitions", {"transition" => "#{transition}"})
53
+ end
54
+ end
55
+
56
+ def add_comments
57
+ comment = "Test #{@hash[:status]} on #{@hash[:run_time]}\nBuild: http://teamcity/viewLog.html?buildId=#{ENV['teamcity.build.id']}"
58
+ @jissue.comments.add comment
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,30 @@
1
+ require 'singleton'
2
+
3
+ module JiraFormatter
4
+ class JiraConfiguration
5
+ include Singleton
6
+
7
+ attr_accessor :project, :default_issue_type, :transitions
8
+
9
+ def configure
10
+ Jiralicious.load_yml('jiralicious.yml')
11
+ load_yml('jiralicious.yml')
12
+ end
13
+
14
+ private
15
+
16
+ #TODO: add dynamic attribute accessors
17
+ #yanked straight from the jiralicious method of the same name.
18
+ def load_yml(yml_file)
19
+ if File.exist?(yml_file)
20
+ yml_cfg = OpenStruct.new(YAML.load_file(yml_file))
21
+ yml_cfg.jira_properties.each do |k, v|
22
+ instance_variable_set("@#{k}", v)
23
+ end
24
+ else
25
+ raise StandardError, "unable to find yml config file"
26
+ end
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,22 @@
1
+ require 'jiralicious'
2
+ require 'jira_formatter/issue'
3
+ require 'jira_formatter/jira_configuration'
4
+
5
+ module JiraFormatter
6
+ class JiraInterface
7
+
8
+ def initialize
9
+ JiraConfiguration.instance.configure
10
+ end
11
+
12
+ def report(scenarios)
13
+ scenarios.each do |scenario|
14
+ begin
15
+ issue = Issue.new(scenario)
16
+ rescue => e
17
+ puts "jira reporting failed for #{scenario}\n#{e.message}\n#{e.backtrace}"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module JiraFormatter
2
+ VERSION = "0.0.3.pre1"
3
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+ require 'jira_formatter/formatter'
3
+
4
+ describe 'JiraFormatter::Formatter' do
5
+ describe '#after_features' do
6
+ before :each do
7
+ @step_mother = Cucumber::Runtime.new()
8
+ @io = StringIO.new()
9
+ @formatter = JiraFormatter::Formatter.new(@step_mother, @io, {})
10
+
11
+ stub_const('Reporter', Class.new())
12
+ @reporter = mock('Reporter')
13
+ end
14
+
15
+ it 'passes the scenarios to the reporter' do
16
+ @formatter.should_receive(:failed_and_passed).and_return([1,2,3,1,2,3])
17
+ Reporter.should_receive(:new).with([1,2,3,1,2,3]).and_return(@reporter)
18
+ @reporter.should_receive(:report)
19
+
20
+ @formatter.after_features()
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec/spec_helper'
2
+ require 'jira_formatter/jira_interface'
3
+
4
+ #find a way to get a scenario in there for me to work with...
5
+
6
+ describe 'Reporter' do
7
+ describe '#report' do
8
+ it 'just calls 3 functions' do
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+ require 'jira-cucumber'
3
+
4
+ describe JiraFormatter do
5
+ it 'runs without error' do
6
+ run_feature('everything')
7
+ end
8
+
9
+ context 'feature exists in jira in the failing state' do
10
+ context 'the run passes' do
11
+ it 'moves the feature to passed' do
12
+
13
+ end
14
+
15
+ it 'adds a comment' do
16
+
17
+ end
18
+ end
19
+ context 'the run fails' do
20
+ it 'does not move the issue' do
21
+
22
+ end
23
+ it 'adds a comment' do
24
+
25
+ end
26
+ end
27
+ end
28
+ context 'feature exists in jira in the passing state' do
29
+ context 'the run passes' do
30
+ it 'does not move the issue' do
31
+
32
+ end
33
+
34
+ it 'adds a comment' do
35
+
36
+ end
37
+ end
38
+ context 'the run fails' do
39
+ it 'moves the issue to passing' do
40
+
41
+ end
42
+ it 'adds a comment' do
43
+
44
+ end
45
+ end
46
+ end
47
+ end
48
+
@@ -0,0 +1,5 @@
1
+ require 'cucumber/cli/main'
2
+
3
+ def run_feature(feature_name)
4
+ Cucumber::Cli::Main.execute(["features/#{feature_name}.feature", '--format', 'JiraFormatter::Formatter'])
5
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jira-cucumber
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3.pre1
5
+ platform: ruby
6
+ authors:
7
+ - Caleb Tomlinson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jiralicious
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>'
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>'
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: vcr
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 2.5.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 2.5.0
83
+ description: Jira reporting for cucumber tests
84
+ email:
85
+ - ctomlinson@opentable.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .travis.yml
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - features/README
97
+ - features/basic_functionality.feature
98
+ - features/everything.feature
99
+ - features/step_definitions/steps.rb
100
+ - jira-cucumber.gemspec
101
+ - lib/jira-cucumber.rb
102
+ - lib/jira_formatter/formatter.rb
103
+ - lib/jira_formatter/issue.rb
104
+ - lib/jira_formatter/jira_configuration.rb
105
+ - lib/jira_formatter/jira_interface.rb
106
+ - lib/jira_formatter/version.rb
107
+ - spec/formatter/formatter_spec.rb
108
+ - spec/formatter/reporter_spec.rb
109
+ - spec/integration/integration_spec.rb
110
+ - spec/spec_helper.rb
111
+ homepage: ''
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - '>'
127
+ - !ruby/object:Gem::Version
128
+ version: 1.3.1
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.0.3
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: Jira reporting for cucumber tests
135
+ test_files:
136
+ - features/README
137
+ - features/basic_functionality.feature
138
+ - features/everything.feature
139
+ - features/step_definitions/steps.rb
140
+ - spec/formatter/formatter_spec.rb
141
+ - spec/formatter/reporter_spec.rb
142
+ - spec/integration/integration_spec.rb
143
+ - spec/spec_helper.rb
144
+ has_rdoc: