Class: ParameterizedTesting::Input
- Inherits:
-
Object
- Object
- ParameterizedTesting::Input
- Defined in:
- lib/parameterized_testing/input.rb
Overview
Input represents a single test case for a parameterized test.
Instance Attribute Summary collapse
-
#index ⇒ Integer
readonly
Index of the input.
-
#initializer ⇒ Proc
readonly
The block to compute the value of this input.
-
#location ⇒ Thread::Backtrace::Location
readonly
The location of the
input { ... }block.
Class Method Summary collapse
-
.collect ⇒ Array<Input>
Collects all
input { ... }in a block.
Instance Method Summary collapse
-
#initialize(index:, location:, initializer:) ⇒ Input
constructor
A new instance of Input.
-
#label ⇒ String
Gets a human-readable label string.
Constructor Details
#initialize(index:, location:, initializer:) ⇒ Input
Returns a new instance of Input.
13 14 15 16 17 |
# File 'lib/parameterized_testing/input.rb', line 13 def initialize(index:, location:, initializer:) @index = index @location = location @initializer = initializer end |
Instance Attribute Details
#index ⇒ Integer (readonly)
Returns index of the input.
7 8 9 |
# File 'lib/parameterized_testing/input.rb', line 7 def index @index end |
#initializer ⇒ Proc (readonly)
Returns the block to compute the value of this input.
11 12 13 |
# File 'lib/parameterized_testing/input.rb', line 11 def initializer @initializer end |
#location ⇒ Thread::Backtrace::Location (readonly)
Returns the location of the input { ... } block.
9 10 11 |
# File 'lib/parameterized_testing/input.rb', line 9 def location @location end |
Class Method Details
.collect ⇒ Array<Input>
Collects all input { ... } in a block. It is important to notice that this method collects inputs by actually #instance_executing the block in a dedicated context, in order to get the line number of input. In this context, all other method calls are ignored.
30 31 32 33 34 |
# File 'lib/parameterized_testing/input.rb', line 30 def self.collect(&) inputs = [] Collector.new(inputs).instance_exec(&) inputs end |
Instance Method Details
#label ⇒ String
Gets a human-readable label string.
21 22 23 |
# File 'lib/parameterized_testing/input.rb', line 21 def label "input[#{index}] at line #{location.lineno}" end |