cucumber-to-rally 0.1.1 → 0.1.2

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.
@@ -1,8 +1,11 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cucumber-to-rally"
3
- s.version = "0.1.1"
4
- s.description = "A gem to configure a connection with Cucumber to work with Rally"
5
- s.summary = "Version 0.1.1"
3
+ s.version = "0.1.2"
4
+ s.description = "A gem to make a bridge between Rally and Cucumber Steps"
5
+ s.summary = "Version 0.1.2"
6
6
  s.author = "Pablo Menezes"
7
- s.files = Dir["{lib/**/*.rb,README.rdoc,test/**/*.rb,Rakefile,*.gemspec}"]
7
+ s.add_dependency 'rally_rest_api','>= 1.0.3'
8
+ s.add_dependency 'logger','>= 1.2.8'
9
+ s.add_dependency 'activeresource', '2.3.4'
10
+ s.files = Dir["{lib/**/*.rb,README.rdoc,*.gemspec}"]
8
11
  end
@@ -1,293 +1,173 @@
1
- $VERBOSE = nil
2
-
3
- require 'rubygems'
4
- require 'active_resource'
5
- require 'logger'
6
- require 'rally_rest_api'
7
- require 'date'
8
- require 'time'
9
- require 'cucumber'
10
- require 'fileutils'
11
-
12
- CONTENT = '# -*- encoding : utf-8 -*-
13
-
14
-
15
- # => The function createTestCase, used in this example, don\'t use the complete params, so, all Test Cases created with
16
- # => this hooks example will be this following values: Type: Functional, Method: Automated and Priority: Critical.
17
- #
18
- # => The order of params of this function are: workspace, project, name, description,owner, type, method, priority,id*
19
- #
20
- # => At the moment, the id param is useless. For the next review, your use will be studied
21
- #
22
-
23
- cucumber = CucumberToRally::CucumberToRally.new
24
-
25
- #Params to Connect on Rally
26
- LOGIN = #Insert here your Rally login
27
- PASSWORD = #Insert here your password
28
-
29
- #Params to create a Test Case Result
30
- WORKSPACE = #Workspace of the Project
31
- PROJECT = #Id of the Project
32
- BUILD = #Default build, case you want to define a default Build Name
33
-
34
-
35
-
36
-
37
- # The Before do "function" run before each scenario. In this hooks.rb file example, Before the scenario runs, I connect on Rally.
38
-
39
- Before do
40
- # Connect to Rally before the Scenario run. Can be used after the scenario run too.
41
- cucumber.connect(LOGIN,PASSWORD)
42
- end
43
-
44
- #The After do |scenario| "function" runs after each scenario. The scenario variable allow us to make some validations before save the Test Case Result or create a Test Case, if the scenario hasn\'t been created yet.
45
-
46
- After do |scenario|
47
-
48
- #
49
- # => The following lines are ways to identfy existing Test Cases, but nothing prevents you of using other ways
50
- # => to identify existings Test Cases.
51
- #
52
-
53
- if scenario.source_tag_names.first == nil
54
- TC_ID = 0
55
- isId = "none"
56
- else
57
- isId = scenario.source_tag_names.first;
58
- isId = isId.gsub("@","")
59
- end
60
-
61
- if isId.start_with?("TC")
62
- TC_ID = isId
63
- end
64
-
65
- #This "if" will be executed only if the scenario fail.
66
- if (scenario.failed?)
67
- begin
68
- Kernel.puts "The scenario #{scenario.name} failed!" #Sends a message to the prompt!
69
- if (TC_ID == 0) # Case the TC_ID constant isn\'t defined, a new Test Case will be created!
70
- begin
71
- Kernel.puts "Creating Test Case\n" #Sends a message to the prompt!
72
- newTC = cucumber.createTestCase(WORKSPACE,PROJECT,scenario.name,"Cucumber Execution Test")
73
- Kernel.puts "Test Case created: " + newTC.to_s # Sends to the prompt, if the Test Case was created.
74
- cucumber.createFirstTestCaseResult(WORKSPACE,PROJECT,newTC.to_s,BUILD,"Fail") #Create a result for the Test Case created
75
- end
76
- else
77
- cucumber.createTestCaseResult(WORKSPACE,PROJECT,TC_ID,BUILD,"Fail") #Just runs if the ID was informated.
78
- end
79
- end
80
- end
81
-
82
- #This if will be executed only if the scenario pass.
83
- if (scenario.passed?)
84
- begin
85
- Kernel.puts "The scenario #{scenario.name} passed!" #Sends a message to the prompt
86
- if (TC_ID == 0) # Case the TC_ID constant isn\'t defined, a new Test Case will be created!
87
- begin
88
- Kernel.puts "Creating Test Case\n" #Sends a message to the prompt
89
- newTC = cucumber.createTestCase(WORKSPACE,PROJECT,scenario.name,"Cucumber Execution Test")
90
- Kernel.puts "Test Case created: " + newTC.to_s # Sends to the prompt, if the Test Case was created.
91
- cucumber.createFirstTestCaseResult(WORKSPACE,PROJECT,newTC.to_s,BUILD,"Pass") #Create a result for the Test Case created
92
- end
93
- else
94
- cucumber.createTestCaseResult(WORKSPACE,PROJECT,TC_ID,BUILD,"Pass") #Just runs if the ID was informated
95
- end
96
- end
97
- end
98
- end'
99
-
100
-
101
- module CucumberToRally
102
- class CucumberToRally
103
-
104
- def hook
105
- if !File.exist?("features/support/hooks.rb")
106
- newHook = File.new("features/support/hooks.rb","w")
107
- newHook.write(CONTENT)
108
- end
109
- end
110
-
111
- def connect(login,pass)
112
- begin
113
- $LOGIN = login
114
- print "Conecting with Rally...\n"
115
- rally_logger = Logger.new STDOUT
116
- rally_logger.level = Logger::INFO
117
- @rally = RallyRestAPI.new(:username => login, :password => pass, :api_version => "1.29", :logger => rally_logger)
118
- rescue
119
- print "Error on connect. Try again...\n"
120
- else
121
- print "Logged with success!\n"
122
- end
123
- end
124
-
125
-
126
- def findTestCaseFull(workspace,project,formattedId)
127
- begin
128
- print "Searching Test Case...\n"
129
-
130
- work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
131
- proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project
132
-
133
- fullResult = @rally.find(:test_case, :fetch => true, :workspace => ref=work, :project => ref=proj){ equal :formattedId, formattedId}
134
- rescue
135
- print "Error on search. Try again...\n"
136
- else
137
- if fullResult.results.length > 0
138
- begin
139
- print "Test Case found:#{fullResult.results.first}\n"
140
- return fullResult.results.first
141
- end
142
- else
143
- begin
144
- print "Test Case not found\n"
145
- return nil
146
- end
147
- end
148
- end
149
- end
150
-
151
-
152
- def findTestCaseCompact(workspace,project,formattedId,name="none")
153
- begin
154
- print "Searching Test Case.\n"
155
-
156
- work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
157
- proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project
158
-
159
- if (name == "none")
160
- compactResult = @rally.find(:test_case, :workspace => ref=work, :project => ref=proj){ equal :formattedId, formattedId}
161
- else
162
- compactResult = @rally.find(:test_case,:workspace => ref=work, :project => ref=proj){ equal :name, name}
163
- end
164
- rescue
165
- print "Error on search. Try again...\n"
166
- else
167
- if compactResult.results.length > 0
168
- begin
169
- print "Test Case found:#{compactResult.results.first}\n"
170
- if (name == "none")
171
- return compactResult.results.first
172
- else
173
- return compactResult.results.last
174
- end
175
- end
176
- else
177
- begin
178
- print "Test Case not found...\n"
179
- return nil
180
- end
181
- end
182
- end
183
- end
184
-
185
- def findTestCaseById(workspace,project,formattedId)
186
- begin
187
- work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
188
- proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project
189
-
190
- returnId = @rally.find(:test_case,:workspace => ref=work, :project =>ref=proj){ equal :formattedID, formattedId}
191
-
192
- if (returnId.results.first != nil)
193
- return true
194
- else
195
- return false
196
- end
197
-
198
- end
199
- end
200
-
201
- def createTestCase(workspace, project, name, description,owner=$LOGIN, type="Functional", method="Automated", priority="Critical",id=nil)
202
- if (id != nil)
203
- exist = findTestCaseById(workspace,project,id)
204
- end
205
-
206
- if (exist)
207
- print ("Test Case exist. Skipping creation\n")
208
-
209
- else
210
- begin
211
-
212
- tc = findTestCaseCompact(workspace,project,name)
213
-
214
- print "Creating Test Case..\n"
215
-
216
- work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
217
- proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project
218
-
219
- teste = @rally.create(:test_case, :workspace => ref=work, :project => ref=proj, :name => name, :description => description, :owner => owner, :type => type, :method => method, :priority => priority)
220
-
221
- end
222
- end
223
-
224
- end
225
-
226
- def findTestCaseResult(workspace,project,formattedId)
227
- begin
228
- print "Searching Test Case results\n"
229
-
230
- testCase = findTestCaseCompact(workspace,project,formattedId)
231
-
232
- work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
233
- proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project
234
-
235
- testCaseResult = @rally.find(:test_case_result, :workspace => ref=work, :project => ref=proj, :fetch => true){ equal :test_case, testCase }
236
- rescue
237
- print "Error on search. Try again...\n"
238
- else
239
- if testCaseResult.results.length > 0
240
- begin
241
- print "Founded #{testCaseResult.results.length} Test Cases Results\n"
242
- end
243
- else
244
- begin
245
- print "No Test Case founded\n"
246
- end
247
- end
248
- end
249
- end
250
-
251
- def createTestCaseResult(workspace,project,formattedId,build,verdict)
252
- begin
253
- print "Creating Test Case Result\n"
254
-
255
- date = Time.now
256
-
257
- work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
258
- proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project
259
-
260
- tc = findTestCaseCompact(workspace,project,formattedId)
261
-
262
- @rally.create(:test_case_result, :workspace => ref=work, :test_case => tc, :build => build, :date => date.iso8601, :verdict => verdict)
263
-
264
- rescue
265
- print "Error on create Test Case Result. Try again\n"
266
-
267
- else
268
- print "Test Case Result created with success.\n"
269
- end
270
- end
271
-
272
- def createFirstTestCaseResult(workspace,project,name,build,verdict)
273
- begin
274
- print "Creating first Test Case result\n"
275
-
276
- date = Time.now
277
-
278
- work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
279
- proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project
280
-
281
- tc = findTestCaseCompact(workspace,project,"none",name)
282
-
283
- @rally.create(:test_case_result, :workspace => ref=work, :test_case => tc, :build => build, :date => date.iso8601, :verdict => verdict)
284
-
285
- rescue
286
- print "Error on create Test Case result. Try again...\n"
287
-
288
- else
289
- print "Test Case Result created with success.\n"
290
- end
291
- end
292
- end
293
- end
1
+ $VERBOSE = nil
2
+
3
+ require 'rubygems'
4
+ require 'active_resource'
5
+ require 'logger'
6
+ require 'rally_rest_api'
7
+ require 'date'
8
+ require 'time'
9
+
10
+ module CucumberToRally
11
+ class CucumberToRally
12
+
13
+ def connect(login,password)
14
+ begin
15
+ $LOGIN = login
16
+ print "Conecting with Rally...\n"
17
+ rally_logger = Logger.new STDOUT
18
+ rally_logger.level = Logger::INFO
19
+ @rally = RallyRestAPI.new(:username => login, :password => password, :api_version => "1.29", :logger => rally_logger)
20
+ rescue Exception => err
21
+ puts "Error found: " + err.message
22
+ else
23
+ puts "Connected to Rally!"
24
+ end
25
+ end
26
+
27
+ def createTestCase(workspace,project,name,description, usId = nil, owner = $LOGIN,type = "Functional", method = "Automated", priority = "Critical")
28
+
29
+ begin
30
+
31
+ work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
32
+ proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project
33
+
34
+ if usId != nil #if principal
35
+ begin
36
+ us = findUS(project,usId)
37
+
38
+ if us == false #segundo if
39
+ begin #segundo begin
40
+ puts "No User Story found! Creating Test Case without User Story attached"
41
+ @rally.create(:test_case, :workspace => ref=work, :project => ref=proj, :name => name, :description => description, :owner => owner, :type => type, :method => method, :priority => priority)
42
+ end #fim segundo begin
43
+ else #else segundo if
44
+ begin #terceiro begin
45
+ @rally.create(:test_case, :workspace => ref=work, :project => ref=proj, :name => name, :description => description, :owner => owner, :type => type, :method => method, :priority => priority, :work_product => us)
46
+ end #fim terceiro begin
47
+ end #end segundo if
48
+ end
49
+ else
50
+ begin
51
+ @rally.create(:test_case, :workspace => ref=work, :project => ref=proj, :name => name, :description => description, :owner => owner, :type => type, :method => method, :priority => priority)
52
+ end
53
+ end
54
+
55
+ rescue Exception => err
56
+
57
+ puts "Error found on creation of test case: " + err.message
58
+
59
+ else
60
+
61
+ puts "Test Case created with success!"
62
+
63
+ end # final do begin do método
64
+ end
65
+
66
+ def findTestCaseCompact(workspace,project,formattedId,name="none")
67
+ begin
68
+ print "Searching Test Case.\n"
69
+
70
+ work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
71
+ proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project
72
+
73
+ if (name == "none")
74
+ compactResult = @rally.find(:test_case, :workspace => ref=work, :project => ref=proj){ equal :formattedId, formattedId}
75
+ else
76
+ compactResult = @rally.find(:test_case,:workspace => ref=work, :project => ref=proj){ equal :name, name}
77
+ end
78
+ rescue Exception => err
79
+ print "Error on search Test Case: " + err.message
80
+ else
81
+ if compactResult.results.length > 0
82
+ begin
83
+ print "Test Case found:#{compactResult.results.first}\n"
84
+ if (name == "none")
85
+ return compactResult.results.first
86
+ else
87
+ return compactResult.results.last
88
+ end
89
+ end
90
+ else
91
+ begin
92
+ print "Test Case not found...\n"
93
+ return nil
94
+ end
95
+ end
96
+ end
97
+ end
98
+
99
+ def createTestCaseResult(workspace,project,formattedId,build,verdict,name = "none")
100
+ begin
101
+ print "Creating Test Case Result\n"
102
+
103
+ date = Time.now
104
+
105
+ work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
106
+ proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project
107
+
108
+ if (name != "none")
109
+ tc = findTestCaseCompact(workspace,project,formattedId)
110
+ else
111
+ tc = findTestCaseCompact(workspace,project,formattedId, name)
112
+ end
113
+
114
+ @rally.create(:test_case_result, :workspace => ref=work, :test_case => tc, :build => build, :date => date.iso8601, :verdict => verdict)
115
+
116
+ rescue Exception => err
117
+ print "Error on create Test Case Result: " + err.message
118
+
119
+ else
120
+ print "Test Case Result created with success.\n"
121
+ end
122
+ end
123
+
124
+ def findTestCaseResult(workspace,project,formattedId)
125
+ begin
126
+ print "Searching Test Case results\n"
127
+
128
+ testCase = findTestCaseCompact(workspace,project,formattedId)
129
+
130
+ work = "https://rally1.rallydev.com/slm/webservice/1.17/workspace/" + workspace
131
+ proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project
132
+
133
+ testCaseResult = @rally.find(:test_case_result, :workspace => ref=work, :project => ref=proj, :fetch => true){ equal :test_case, testCase }
134
+ rescue Exception => err
135
+ print "Error on search: " + err.message
136
+ else
137
+ if testCaseResult.results.length > 0
138
+ begin
139
+ print "Found #{testCaseResult.results.length} Test Case Result(s)\n"
140
+ end
141
+ else
142
+ begin
143
+ print "No Test Case founded\n"
144
+ end
145
+ end
146
+ end
147
+ end
148
+
149
+
150
+ private
151
+
152
+ def findUS(project,id)
153
+ begin
154
+
155
+ proj = "https://rally1.rallydev.com/slm/webservice/1.17/project/" + project
156
+
157
+ user_story = @rally.find(:hierarchical_requirement, :project => ref=proj){equal :formattedId, id}
158
+
159
+ if user_story.results.length > 0
160
+ return user_story.results.first
161
+ else
162
+ return false
163
+ end
164
+
165
+ rescue Exception => err
166
+ puts "Error found on search: " + err.message
167
+ else
168
+ puts "User Story found!"
169
+ end
170
+ end
171
+
172
+ end
173
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-to-rally
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,17 +9,63 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-23 00:00:00.000000000 Z
13
- dependencies: []
14
- description: A gem to configure a connection with Cucumber to work with Rally
12
+ date: 2012-07-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rally_rest_api
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.3
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.3
30
+ - !ruby/object:Gem::Dependency
31
+ name: logger
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 1.2.8
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.2.8
46
+ - !ruby/object:Gem::Dependency
47
+ name: activeresource
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - '='
52
+ - !ruby/object:Gem::Version
53
+ version: 2.3.4
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.3.4
62
+ description: A gem to make a bridge between Rally and Cucumber Steps
15
63
  email:
16
64
  executables: []
17
65
  extensions: []
18
66
  extra_rdoc_files: []
19
67
  files:
20
68
  - lib/cucumber-to-rally.rb
21
- - test/cucumber-to-rally_test.rb
22
- - Rakefile
23
69
  - cucumber-to-rally.gemspec
24
70
  homepage:
25
71
  licenses: []
@@ -44,6 +90,6 @@ rubyforge_project:
44
90
  rubygems_version: 1.8.21
45
91
  signing_key:
46
92
  specification_version: 3
47
- summary: Version 0.1.1
93
+ summary: Version 0.1.2
48
94
  test_files: []
49
95
  has_rdoc:
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require 'rake/testtask'
2
-
3
- Rake::TestTask.new do |t|
4
- t.libs << "lib"
5
- t.test_files = Dir["test/**/*.rb"]
6
- end
@@ -1,8 +0,0 @@
1
- require 'test/unit'
2
- require 'cucumberToRally'
3
-
4
- class CucumberTest < Test::Unit::TestCase
5
- def testInitialize
6
- assert_equal "Iniciando...", CucumberToRally.say
7
- end
8
- end