Class: RSpec::Authorization::Adapters::Example
- Inherits:
-
Object
- Object
- RSpec::Authorization::Adapters::Example
- Defined in:
- lib/rspec/authorization/adapters/example.rb
Overview
Wrapper to generate and immediately run example from RSpec::Core::Example
. The purpose of this class is to abstract the running of an example without unnecessary artifacts from an RSpec example, such as: reporter, generated description, context and expectation.
The sole purpose of this class is to generate the minimum required component needed to create and run an example, for our matcher to run against. The trick to run the example without producing unnecessary artifacts is to trigger the example’s before and after hook manually without running any expectations.
Instance Attribute Summary collapse
-
#group_target ⇒ Class
readonly
RSpec example group.
-
#target ⇒ RSpec::Core::Example
readonly
Instance of RSpec example.
Instance Method Summary collapse
-
#initialize(group_target) ⇒ Example
constructor
Initialize example using RSpec example group.
Constructor Details
#initialize(group_target) ⇒ Example
Initialize example using RSpec example group. The RSpec example group can be retrieved using example group’s target, consider the following example:
group = ExampleGroup.new(ArticlesController)
example = Example.new(group.target)
26 27 28 29 30 31 32 33 |
# File 'lib/rspec/authorization/adapters/example.rb', line 26 def initialize(group_target) @group_target = group_target @target = RSpec::Core::Example.new(group_target, "", {}) set_example_group_instance run_before_example run_after_example end |
Instance Attribute Details
#group_target ⇒ Class (readonly)
Returns RSpec example group.
14 15 16 |
# File 'lib/rspec/authorization/adapters/example.rb', line 14 def group_target @group_target end |
#target ⇒ RSpec::Core::Example (readonly)
Returns instance of RSpec example.
16 17 18 |
# File 'lib/rspec/authorization/adapters/example.rb', line 16 def target @target end |