Class: FixtureKit::RSpecAdapter

Inherits:
Adapter
  • Object
show all
Defined in:
lib/fixture_kit/adapters/rspec_adapter.rb

Instance Attribute Summary

Attributes inherited from Adapter

#options

Instance Method Summary collapse

Methods inherited from Adapter

#initialize

Constructor Details

This class inherits a constructor from FixtureKit::Adapter

Instance Method Details

#execute(&block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fixture_kit/adapters/rspec_adapter.rb', line 7

def execute(&block)
  previous_example = ::RSpec.current_example
  previous_scope = ::RSpec.current_scope
  example_group = build_example_group
  example = example_group.example { block.call(self) }
  succeeded =
    begin
      example.run(example_group.new, ::RSpec::Core::NullReporter)
    ensure
      ::RSpec.current_example = previous_example
      ::RSpec.current_scope = previous_scope
    end

  raise example.exception unless succeeded
end

#identifier_for(identifier) ⇒ Object



23
24
25
26
# File 'lib/fixture_kit/adapters/rspec_adapter.rb', line 23

def identifier_for(identifier)
  normalized_scope = identifier.to_s.sub(/\ARSpec::ExampleGroups::/, "")
  ActiveSupport::Inflector.underscore(normalized_scope)
end