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.
## Example1
where(:a, :b, :answer) do
[
[1 , 2 , 3],
[5 , 8 , 13],
[0 , 0 , 0]
]
end
## Example2
using RSpec::Parameterized::TableSyntax
where(:a, :b, :answer) do
1 | 2 | 3 >
5 | 8 | 13 >
0 | 0 | 0
end
40 41 42 |
# File 'lib/rspec/parameterized.rb', line 40 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
55 56 57 |
# File 'lib/rspec/parameterized.rb', line 55 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
69 70 71 72 73 74 75 76 |
# File 'lib/rspec/parameterized.rb', line 69 def with_them(*args, &b) if @parameter.nil? @parameterized_pending_cases ||= [] @parameterized_pending_cases << [args, b] else define_cases(@parameter, *args, &b) end end |