module MotionSpec::RubyMineOutput
Public Instance Methods
convert_time_to_java_simple_date(time)
click to toggle source
# File lib/motion-spec/output/ruby_mine.rb, line 73 def convert_time_to_java_simple_date(time) gmt_offset = time.gmt_offset gmt_sign = gmt_offset < 0 ? '-' : '+' gmt_hours = gmt_offset.abs / 3600 gmt_minutes = gmt_offset.abs % 3600 millisec = time.usec == 0 ? 0 : time.usec / 1000 # Time string in Java SimpleDateFormat sprintf("#{time.strftime('%Y-%m-%dT%H:%M:%S.')}%03d#{gmt_sign}%02d%02d", millisec, gmt_hours, gmt_minutes) end
escape_message(message)
click to toggle source
# File lib/motion-spec/output/ruby_mine.rb, line 49 def escape_message(message) copy_of_text = String.new(message) copy_of_text.gsub!(/\|/, '||') copy_of_text.gsub!(/'/, "|'") copy_of_text.gsub!(/\n/, '|n') copy_of_text.gsub!(/\r/, '|r') copy_of_text.gsub!(/\]/, '|]') copy_of_text.gsub!(/\[/, '|[') begin copy_of_text.encode!('UTF-8') if copy_of_text.respond_to? :encode! copy_of_text.gsub!(/\u0085/, '|x') # next line copy_of_text.gsub!(/\u2028/, '|l') # line separator copy_of_text.gsub!(/\u2029/, '|p') # paragraph separator rescue # it is not an utf-8 compatible string :( end copy_of_text end
handle_requirement_begin(description)
click to toggle source
# File lib/motion-spec/output/ruby_mine.rb, line 21 def handle_requirement_begin(description) @@description = description @@started = Time.now puts "##teamcity[testStarted timestamp = '#{java_time}' captureStandardOutput = 'true' name = '#{escape_message(description)}']\n\n" end
handle_requirement_end(error)
click to toggle source
# File lib/motion-spec/output/ruby_mine.rb, line 27 def handle_requirement_end(error) unless error.empty? puts "##teamcity[testFailed timestamp = '#{java_time}' message = '#{escape_message(error)}' name = '#{escape_message(@@description)}']\n\n" end duration = ((Time.now - @@started) * 1000).to_i puts "##teamcity[testFinished timestamp = '#{java_time}' duration = '#{duration}' name = '#{escape_message(@@description)}']\n\n" end
handle_specification_begin(name)
click to toggle source
# File lib/motion-spec/output/ruby_mine.rb, line 8 def handle_specification_begin(name) unless @@entered puts "##teamcity[enteredTheMatrix timestamp = '#{java_time}']\n\n" @@entered = true end @@specification = name puts "##teamcity[testSuiteStarted timestamp = '#{java_time}' name = '#{escape_message(name)}']\n\n" end
handle_specification_end()
click to toggle source
# File lib/motion-spec/output/ruby_mine.rb, line 17 def handle_specification_end puts "##teamcity[testSuiteFinished timestamp = '#{java_time}' name = '#{escape_message(@@specification)}']\n\n" if Counter[:context_depth] == 1 end
handle_summary()
click to toggle source
# File lib/motion-spec/output/ruby_mine.rb, line 35 def handle_summary print ErrorLog if Backtraces puts '%d specifications (%d requirements), %d failures, %d errors' % Counter.values_at(:specifications, :requirements, :failed, :errors) end
java_time()
click to toggle source
# File lib/motion-spec/output/ruby_mine.rb, line 45 def java_time convert_time_to_java_simple_date(Time.now) end
spaces()
click to toggle source
# File lib/motion-spec/output/ruby_mine.rb, line 41 def spaces ' ' * (Counter[:context_depth] - 1) end