Class: Cucumber::Formatter::STDDTool
- Inherits:
-
Object
- Object
- Cucumber::Formatter::STDDTool
- Includes:
- Io
- Defined in:
- lib/stddtool.rb
Constant Summary collapse
- AST_CLASSES =
{ Cucumber::Ast::Scenario => 'scenario', Cucumber::Ast::ScenarioOutline => 'scenario_outline' }
Instance Attribute Summary collapse
-
#runtime ⇒ Object
readonly
Returns the value of attribute runtime.
Instance Method Summary collapse
- #after_features(features) ⇒ Object
- #after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line) ⇒ Object
- #background_name(keyword, name, file_colon_line, source_indent) ⇒ Object
- #before_feature(feature) ⇒ Object
- #before_feature_element(feature_element) ⇒ Object
- #before_step(step) ⇒ Object
- #before_step_result(*args) ⇒ Object
- #create_customer_if_not_exist(customer_name) ⇒ Object
- #create_project_if_not_exists(customer_id, project_name) ⇒ Object
- #create_run_if_not_exists(project_id, run_name, run_source, run_revision) ⇒ Object
- #embed(src, mime_type, label) ⇒ Object
- #init_customer_project_and_run(customer_name, project_name, run_name, run_source, run_revision) ⇒ Object
- #init_module(name) ⇒ Object
-
#initialize(runtime, path_or_io, options) ⇒ STDDTool
constructor
A new instance of STDDTool.
- #post_scenario ⇒ Object
- #scenario_name(keyword, name, file_colon_line, source_indent) ⇒ Object
- #tag_name(tag_name) ⇒ Object
Constructor Details
#initialize(runtime, path_or_io, options) ⇒ STDDTool
Returns a new instance of STDDTool.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/stddtool.rb', line 27 def initialize(runtime, path_or_io, ) @runtime, @io, @options = runtime, ensure_io(path_or_io, "stddtool"), @delayed_messages = [] @io.puts @runID @connection_error = nil @io.puts "Initiating STDDTool(#{@url}) formatter for #{@project} : #{@module}" @inside_outline = false @io.flush @stdd_client = STDDAPI::Client.new(ENV['STDD_URL'],ENV['http_proxy']) #Collect all enviroment-variables @customer_name = ENV['CUSTOMER'] @project_name = ENV['PROJECT'] @run_name = ENV['RUN'] @run_source = ENV['SOURCE'] @run_revision = ENV['REV'] init_customer_project_and_run(@customer_name,@project_name,@run_name,@run_source,@run_revision) @module_name = ENV['MODULE'] init_module(@module_name) end |
Instance Attribute Details
#runtime ⇒ Object (readonly)
Returns the value of attribute runtime.
20 21 22 |
# File 'lib/stddtool.rb', line 20 def runtime @runtime end |
Instance Method Details
#after_features(features) ⇒ Object
264 265 266 267 268 269 270 271 272 273 |
# File 'lib/stddtool.rb', line 264 def after_features(features) return if @connection_error valid, response = @stdd_client.update_module_stopTime(@module.id,(Time.now.to_f * 1000).to_i) if(valid) @module = response else @connection_error = response @io.puts @connection_error end end |
#after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line) ⇒ Object
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/stddtool.rb', line 246 def after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line) return if @connection_error step_name = step_match.format_args(lambda{|param| "*#{param}*"}) @step = STDDAPI::Objects::Step.new(@scenario.id,keyword, step_name) @step.status=status @step. = exception @step.duration = @step_duration @step. = @delayed_messages valid,response = @stdd_client.add_step_to_scenario(@step) if(valid) # success else @connection_error = response @io.puts @connection_error end end |
#background_name(keyword, name, file_colon_line, source_indent) ⇒ Object
217 218 219 220 221 222 223 224 |
# File 'lib/stddtool.rb', line 217 def background_name(keyword, name, file_colon_line, source_indent) return if @connection_error @io.puts "Background #{name}" @scenario.name=name @scenario.keyword = keyword post_scenario end |
#before_feature(feature) ⇒ Object
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/stddtool.rb', line 172 def before_feature(feature) return if @connection_error # @io.puts feature.source_tag_names @feature = STDDAPI::Objects::Feature.new(@module.id,feature.title,Time.now) @feature.description = feature.description @feature. = feature.source_tag_names @feature.file = feature.file valid,response = @stdd_client.create_feature(@feature) if(valid) @feature.id = response else @connection_error = response @io.puts @connection_error end # @feature_element = FeatureElement.new # @feature_element.tags = Array.new # @feature_element.feature_ID = @featureID @scenario = STDDAPI::Objects::Scenario.new(@feature.id, "",'scenario','Scenario') @scenario.=Array.new end |
#before_feature_element(feature_element) ⇒ Object
212 213 214 215 |
# File 'lib/stddtool.rb', line 212 def before_feature_element(feature_element) return if @connection_error @scenario.element_type = AST_CLASSES[feature_element.class] end |
#before_step(step) ⇒ Object
201 202 203 204 205 |
# File 'lib/stddtool.rb', line 201 def before_step(step) return if @connection_error @delayed_messages = [] @step_start_time = Time.now end |
#before_step_result(*args) ⇒ Object
207 208 209 210 |
# File 'lib/stddtool.rb', line 207 def before_step_result(*args) return if @connection_error @step_duration = Time.now - @step_start_time end |
#create_customer_if_not_exist(customer_name) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/stddtool.rb', line 78 def create_customer_if_not_exist customer_name return if @connection_error # Kontrollera om kunden finns valid, response = @stdd_client.get_customer customer_name # Om kunden finns if(valid && response) @io.puts "Customer already exists" else @io.puts "Customer does not exist, creating new.." # Skapa en kund valid, response = @stdd_client.create_customer customer_name end if(valid) @customer = response return true else @connection_error = response @io.puts @connection_error return false end end |
#create_project_if_not_exists(customer_id, project_name) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/stddtool.rb', line 103 def create_project_if_not_exists customer_id,project_name return if @connection_error # Kontrollera om projektet finns valid, response = @stdd_client.get_project customer_id, project_name # Om projektet finns if(valid) @io.puts "Project already exists" @project = response return true end @io.puts "Project does not exist, creating new.." # Skapa ett projekt valid, response = @stdd_client.create_project customer_id, project_name if valid @project = response return true else @connection_error = response @io.puts @connection_error return false end end |
#create_run_if_not_exists(project_id, run_name, run_source, run_revision) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/stddtool.rb', line 129 def create_run_if_not_exists project_id,run_name,run_source,run_revision return if @connection_error # Check if run exists valid, response = @stdd_client.get_run project_id, run_name # If run exist if(valid) @io.puts "Run already exists" @run = response return true end @io.puts "Run does not exist, creating new.." # Create run #Run valid, response = @stdd_client.create_run(@project.id,run_name,run_source,run_revision) if(valid) @run = response else @connection_error = response @io.puts @connection_error end end |
#embed(src, mime_type, label) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/stddtool.rb', line 154 def (src, mime_type, label) return if @connection_error @io.puts "got embedding" case mime_type when /^image\/(png|gif|jpg|jpeg)/ buf = Base64.encode64(open(src,'rb') { |io| io.read }) =STDDAPI::Objects::Embedding.new(@scenario.id,mime_type,buf) valid,response = @stdd_client.() if(valid) #success else @connection_error = response @io.puts @connection_error end end end |
#init_customer_project_and_run(customer_name, project_name, run_name, run_source, run_revision) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/stddtool.rb', line 64 def init_customer_project_and_run customer_name, project_name, run_name, run_source, run_revision return if @connection_error #Customer create_customer_if_not_exist(customer_name) #Project create_project_if_not_exists(@customer.id,project_name) #Run create_run_if_not_exists(@project.id,run_name,run_source,run_revision) end |
#init_module(name) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/stddtool.rb', line 53 def init_module name return if @connection_error valid,response = @stdd_client.create_module(@run.id,name,'cucumber',(Time.now.to_f * 1000).to_i) if(valid) @module = response else @connection_error = response @io.puts @connection_error end end |
#post_scenario ⇒ Object
235 236 237 238 239 240 241 242 243 244 |
# File 'lib/stddtool.rb', line 235 def post_scenario return if @connection_error valid,response = @stdd_client.create_scenario(@scenario) if(valid) @scenario.id = response else @connection_error = response @io.puts @connection_error end end |
#scenario_name(keyword, name, file_colon_line, source_indent) ⇒ Object
226 227 228 229 230 231 232 233 |
# File 'lib/stddtool.rb', line 226 def scenario_name(keyword, name, file_colon_line, source_indent) return if @connection_error @io.puts "scenario #{name}" @scenario.name=name @scenario.keyword = keyword post_scenario end |
#tag_name(tag_name) ⇒ Object
196 197 198 199 |
# File 'lib/stddtool.rb', line 196 def tag_name(tag_name) return if @connection_error @scenario ? @scenario..push({'name' => tag_name}) : true end |