module AllureTurnip::DSL::Example

Public Instance Methods

allure_step(step, &block) click to toggle source
# File lib/allure_turnip/dsl.rb, line 16
def allure_step(step, &block)
  begin
    locked = __mutex.try_lock
    if locked
      @@__current_step = step
      __with_allure_step(step, &block)
    else
      __with_step(step,&block)
    end
  ensure
    if locked
      @@__current_step = nil
      __mutex.unlock
    end
  end
end
attach_file(title, file, opts = {}) click to toggle source
# File lib/allure_turnip/dsl.rb, line 33
def attach_file(title, file, opts = {})
  step = current_step
  AllureRubyAdaptorApi::Builder.add_attachment __suite, __test, opts.merge(:title => title, :file => file, :step => step)
end
current_step() click to toggle source
# File lib/allure_turnip/dsl.rb, line 8
def current_step
  if defined? @@__current_step
    @@__current_step
  else
    nil
  end
end

Private Instance Methods

__description(data) click to toggle source
# File lib/allure_turnip/dsl.rb, line 54
def __description(data)
  data[:full_description] || data[:description]
end
__mutex() click to toggle source
# File lib/allure_turnip/dsl.rb, line 58
def __mutex
  @@__mutex ||= Mutex.new
end
__suite() click to toggle source
# File lib/allure_turnip/dsl.rb, line 40
def __suite
  parent_group = metadata[:example_group][:parent_example_group]
  parent_group = parent_group.has_key?(:parent_example_group) ? parent_group[:parent_example_group] : parent_group
  if AllureTurnip::Config.feature_with_filename?
    "#{File.split(parent_group[:file_path])[1]} -> #{parent_group[:description]}"
  else
    parent_group[:description]
  end
end
__test() click to toggle source
# File lib/allure_turnip/dsl.rb, line 50
def __test
  metadata[:example_group][:full_description]
end
__with_allure_step(step, &block) click to toggle source
# File lib/allure_turnip/dsl.rb, line 62
def __with_allure_step(step, &block)
  begin
    AllureRubyAdaptorApi::Builder.start_step(__suite, __test, step)
    __with_step(step, &block)
    AllureRubyAdaptorApi::Builder.stop_step(__suite, __test, step)
  rescue Exception => e
    AllureRubyAdaptorApi::Builder.stop_step(__suite, __test, step, :failed)
    raise e
  end
end
__with_step(step) { |self| ... } click to toggle source
# File lib/allure_turnip/dsl.rb, line 73
def __with_step(step, &block)
  AllureTurnip.context.rspec.hooks.send :run, :before, :step, self
  yield self
  AllureTurnip.context.rspec.hooks.send :run, :after, :step, self
end