module Hiptest::GroovySpockAddon

Public Instance Methods

walk_call(call) click to toggle source
Calls superclass method
# File lib/hiptest-publisher/renderer_addons/groovy_spock_addon.rb, line 5
def walk_call(call)
  base = super(call)
  use_annotation(call, base)
end

Private Instance Methods

ignore_case_equal?(string1, string2) click to toggle source
# File lib/hiptest-publisher/renderer_addons/groovy_spock_addon.rb, line 30
def ignore_case_equal?(string1, string2)
  string1.casecmp(string2) == 0
end
needs_fixing?(call) click to toggle source
# File lib/hiptest-publisher/renderer_addons/groovy_spock_addon.rb, line 19
def needs_fixing?(call)
  scenario = call.parent

  return false unless scenario.is_a?(Hiptest::Nodes::Scenario)
  return false unless call.children[:annotation].nil? || ignore_case_equal?(call.children[:annotation], 'then')

  return call.parent.children[:body].select do |step|
    step.is_a?(Hiptest::Nodes::Call) && !step.children[:annotation].nil? && ignore_case_equal?(step.children[:annotation], 'when')
  end.empty?
end
use_annotation(call, base) click to toggle source
# File lib/hiptest-publisher/renderer_addons/groovy_spock_addon.rb, line 12
def use_annotation(call, base)
  base[:use_expect_annotation] = needs_fixing?(call)
  base[:use_main_annotation?] = !(call.children[:annotation].nil? || ['and', 'but'].include?(call.children[:annotation]))

  base
end