Class: Smartest::Fixture
- Inherits:
-
Object
show all
- Defined in:
- lib/smartest/fixture.rb
Constant Summary
collapse
- RESERVED_CONTEXT_METHODS =
%i[skip pending].freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(fixture_set:, context:) ⇒ Fixture
Returns a new instance of Fixture.
55
56
57
58
|
# File 'lib/smartest/fixture.rb', line 55
def initialize(fixture_set:, context:)
@fixture_set = fixture_set
@context = context
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
68
69
70
71
72
73
74
75
76
|
# File 'lib/smartest/fixture.rb', line 68
def method_missing(method_name, *args, &block)
return super if RESERVED_CONTEXT_METHODS.include?(method_name)
if @context.respond_to?(method_name, true)
@context.__send__(method_name, *args, &block)
else
super
end
end
|
Class Method Details
.fixture(name, scope: :test, &block) ⇒ Object
8
9
10
11
12
13
14
15
|
# File 'lib/smartest/fixture.rb', line 8
def fixture(name, scope: :test, &block)
define_fixture(
name,
scope: scope,
block: block,
location: caller_locations(1, 1).first
)
end
|
.fixture_definitions ⇒ Object
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/smartest/fixture.rb', line 26
def fixture_definitions
inherited =
if superclass.respond_to?(:fixture_definitions)
superclass.fixture_definitions
else
{}
end
inherited.merge(own_fixture_definitions)
end
|
.suite_fixture(name, &block) ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/smartest/fixture.rb', line 17
def suite_fixture(name, &block)
define_fixture(
name,
scope: :suite,
block: block,
location: caller_locations(1, 1).first
)
end
|