stddtool 0.0.4

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/stddtool.rb +146 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cd6380c7fe697deb0ad49faab291dd77cc47cd8d
4
+ data.tar.gz: 50ac7e736ddcdda9b391bad1262446ccef2f5dbf
5
+ SHA512:
6
+ metadata.gz: 4b823b5d004bd6b2d877c5927230bbcc2126815f51a166b170f32789ccd44dacfe0dcaa3249daac77d1b7183c0760a78f3de639ae7cfc2b14f0200fbf8fbb6c0
7
+ data.tar.gz: 7de6a64730b4d05ab561105821f22e79a9d1c7b33f23e88897ab15b35bc72c51c5d2907a88e8c6853de8cc2ca99d69be604697b7a5d481915eda5f2f9ec6ac29
data/lib/stddtool.rb ADDED
@@ -0,0 +1,146 @@
1
+ # features/support/twitter_formatter.rb
2
+ require 'rubygems'
3
+ require 'json'
4
+
5
+
6
+ class STDDTool
7
+
8
+ def self.works
9
+ puts "gem working wihoo"
10
+ end
11
+
12
+ def initialize(step_mother, io, options)
13
+ @job = 'cucumber plugin'
14
+ @buildnr = Random.rand(500).to_s()
15
+ @url = "http://194.218.9.52:2000/"
16
+ puts "Initiating STDDTool formatter"
17
+ end
18
+
19
+ def before_feature(feature)
20
+ # puts feature.source_tag_names
21
+ featureObj=FeatureObj.new(@job,@buildnr,feature.title,feature.description,feature.file,feature.source_tag_names)
22
+ postFeature(featureObj)
23
+ end
24
+
25
+ def before_step(step)
26
+ @start_time = Time.now
27
+ end
28
+
29
+ def before_step_result(*args)
30
+ @duration = Time.now - @start_time
31
+ end
32
+
33
+ def scenario_name(keyword, name, file_colon_line, source_indent)
34
+ puts "scenario #{name}"
35
+ scenarioObj=ScenarioObj.new(@featureID,keyword,name)
36
+ postScenario(scenarioObj)
37
+ end
38
+
39
+
40
+ def after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line)
41
+ step_name = step_match.format_args(lambda{|param| "*#{param}*"})
42
+ # message = "#{step_name} #{status}"
43
+ # puts keyword + " " + message
44
+ stepObj=StepObj.new(keyword,step_name,status,exception, @duration)
45
+ postStep(@scenarioID,stepObj)
46
+ end
47
+
48
+ def step_name(keyword, step_match, status, source_indent, background, file_colon_line)
49
+
50
+ end
51
+
52
+ def postFeature(featureObj)
53
+ uri = URI.parse(@url)
54
+ http = Net::HTTP.new(uri.host, uri.port)
55
+ request = Net::HTTP::Post.new("/collectionapi/features")
56
+ request.add_field('X-Auth-Token', '97f0ad9e24ca5e0408a269748d7fe0a0')
57
+ request.body = featureObj.to_json
58
+ response = http.request(request)
59
+ # puts response.body
60
+ parsed = JSON.parse(response.body)
61
+ @featureID = parsed["_id"]
62
+
63
+ end
64
+
65
+
66
+ def postStep(scenarioID,stepObj)
67
+ uri = URI.parse(@url)
68
+ path = "/collectionapi/scenarios/#{scenarioID}"
69
+ req = Net::HTTP::Put.new(path, initheader = { 'X-Auth-Token' => '97f0ad9e24ca5e0408a269748d7fe0a0'})
70
+ req.body = stepObj.to_json
71
+ response = Net::HTTP.new(uri.host, uri.port).start {|http| http.request(req) }
72
+ # puts response.body
73
+
74
+ end
75
+
76
+ def postScenario(scenarioObj)
77
+ uri = URI.parse(@url)
78
+ http = Net::HTTP.new(uri.host, uri.port)
79
+ request = Net::HTTP::Post.new("/collectionapi/scenarios")
80
+ request.add_field('X-Auth-Token', '97f0ad9e24ca5e0408a269748d7fe0a0')
81
+ request.body = scenarioObj.to_json
82
+ response = http.request(request)
83
+ # puts response.body
84
+ parsed = JSON.parse(response.body)
85
+ @scenarioID = parsed["_id"]
86
+ end
87
+
88
+ end
89
+
90
+ class FeatureObj
91
+ def initialize(job,build,title,description,file,tags)
92
+ @id = title.downcase.gsub(' ', '-')
93
+ @job = job
94
+ @build = build
95
+ @feature_title=title
96
+ @feature_description = description
97
+ @feature_file = file
98
+
99
+ tagArr = Array.new
100
+ tags.each do |tag|
101
+ tagArr.push({'name' => tag})
102
+ end
103
+
104
+ @feature_tags = tagArr
105
+
106
+ end
107
+ def to_json
108
+ {
109
+ 'id' => @id,
110
+ 'job' => @job,
111
+ 'build' => @build,
112
+ 'title' => @feature_title,
113
+ 'description' => @feature_description ,
114
+ 'file' => @feature_file,
115
+ 'tags' => @feature_tags,
116
+ }.to_json
117
+ end
118
+ end
119
+
120
+
121
+ class StepObj
122
+ def initialize(keyword, name, status,exception,duration)
123
+ @step_keyword=keyword
124
+ @step_name=name
125
+ @step_status=status
126
+ @step_exception = exception
127
+ @step_duration = duration
128
+ end
129
+ def to_json
130
+ {'$addToSet' => {'steps' =>{'keyword' => @step_keyword,
131
+ 'name' => @step_name ,
132
+ 'result' => {'status' =>@step_status,'error_message'=> @step_exception,'duration'=>@step_duration},
133
+ }}}.to_json
134
+ end
135
+ end
136
+
137
+ class ScenarioObj
138
+ def initialize(featureID,keyword, name)
139
+ @feature_ID = featureID
140
+ @scenario_keyword=keyword
141
+ @scenario_name=name
142
+ end
143
+ def to_json
144
+ {'featureId' => @feature_ID,'keyword' => @scenario_keyword, 'name' => @scenario_name}.to_json
145
+ end
146
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stddtool
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Anton Danielsson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Cucumber formatter that reports the cucumber-test-results to STDDTool
14
+ email: anton.danielsson@learningwell.se
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/stddtool.rb
20
+ homepage: https://github.com/antda/cucumber-stddtool
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.0.3
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Cucumber formatter for STDD-Tool
44
+ test_files: []