Module: RSpec::Parameterized::ExampleGroupMethods
- Included in:
- Core::ExampleGroup
- Defined in:
- lib/rspec/parameterized.rb
Defined Under Namespace
Classes: Parameter
Instance Method Summary collapse
-
#where(*args, &b) ⇒ Object
Set parameters to be bound in specs under this example group.
-
#where_table(*args, &b) ⇒ Object
Set parameters to be bound in specs under this example group.
-
#with_them(*args, &b) ⇒ Object
Use parameters to execute the block.
Instance Method Details
#where(*args, &b) ⇒ Object
Set parameters to be bound in specs under this example group.
## Example
where(:a, :b, :answer) do
[
[1 , 2 , 3],
[5 , 8 , 13],
[0 , 0 , 0]
]
end
30 31 32 |
# File 'lib/rspec/parameterized.rb', line 30 def where(*args, &b) set_parameters(args, false, &b) end |
#where_table(*args, &b) ⇒ Object
Set parameters to be bound in specs under this example group. You can separate fields with | like a cucumber table.
## Example
where_table(:a, :b, :answer) do
1 | 2 | 3
5 | 8 | 13
0 | 0 | 0
end
45 46 47 |
# File 'lib/rspec/parameterized.rb', line 45 def where_table(*args, &b) set_parameters(args, true, &b) end |
#with_them(*args, &b) ⇒ Object
Use parameters to execute the block. The given block is converted into describes for each parameter set.
## Example
with_them do
it "should do additions" do
(a + b).should == answer
end
end
59 60 61 62 63 64 65 66 |
# File 'lib/rspec/parameterized.rb', line 59 def with_them(*args, &b) if @parameter.nil? @parameterized_pending_cases ||= [] @parameterized_pending_cases << [args, b] else define_cases(@parameter, *args, &b) end end |