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
-
#description ⇒ String?
readonly
Description of the input.
-
#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:, description:) ⇒ Input
constructor
A new instance of Input.
-
#label ⇒ String
Returns a human-readable label string.
Constructor Details
#initialize(index:, location:, initializer:, description:) ⇒ Input
Returns a new instance of Input.
15 16 17 18 19 20 |
# File 'lib/parameterized_testing/input.rb', line 15 def initialize(index:, location:, initializer:, description:) @index = index @location = location @initializer = initializer @description = description end |
Instance Attribute Details
#description ⇒ String? (readonly)
Returns description of the input.
13 14 15 |
# File 'lib/parameterized_testing/input.rb', line 13 def description @description end |
#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.
33 34 35 36 37 |
# File 'lib/parameterized_testing/input.rb', line 33 def self.collect(&) inputs = [] Collector.new(inputs).instance_exec(&) inputs end |
Instance Method Details
#label ⇒ String
Returns a human-readable label string.
24 25 26 |
# File 'lib/parameterized_testing/input.rb', line 24 def label "#{@description || "input[#{index}]"} (at line #{location.lineno})" end |