Module: Bdd::Adapters::RSpecAdapter::ExampleGroup

Defined in:
lib/bdd/adapters/rspec_adapter.rb

Instance Method Summary collapse

Instance Method Details

#bdd_containerObject



68
69
70
# File 'lib/bdd/adapters/rspec_adapter.rb', line 68

def bdd_container
  Bdd.get_container(::RSpec.current_example)
end

#bdd_step(title, string, &block) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/bdd/adapters/rspec_adapter.rb', line 43

def bdd_step(title, string, &block)
  @bdd_nesting ||= 0
  @bdd_nesting += 1
  sb = StringBuilder.new(title)

  if block_given?
    yield
    sb.append_success(string)
  else
    skip
  end

rescue ::RSpec::Core::Pending::SkipDeclaredInExample
  sb.append_pending(string)
  raise
rescue ::RSpec::Expectations::ExpectationNotMetError
  sb.append_failure(string)
  raise
ensure
  @bdd_nesting -= 1
  if @bdd_nesting.zero?
    bdd_container << sb.string
  end
end