lib/allure_turnip/dsl.rb in allure_turnip-0.2.0 vs lib/allure_turnip/dsl.rb in allure_turnip-0.2.1
- old
+ new
@@ -13,16 +13,22 @@
end
end
def 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
+ 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
def attach_file(title, file, opts = {})
step = current_step
@@ -49,24 +55,24 @@
def __mutex
@@__mutex ||= Mutex.new
end
- def __with_step(step, &block)
+ def __with_allure_step(step, &block)
begin
- locked = __mutex.try_lock
- if locked
- @@__current_step = step
- AllureTurnip.context.rspec.hooks.send :run, :before, :step, self
- yield self
- end
- ensure
- if locked
- AllureTurnip.context.rspec.hooks.send :run, :after, :step, self
- @@__current_step = nil
- __mutex.unlock
- end
+ 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
+
+ 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
end
end
end