spec/parametarized_spec.rb in rspec-parameterized-0.0.2 vs spec/parametarized_spec.rb in rspec-parameterized-0.0.3
- old
+ new
@@ -31,10 +31,28 @@
(a + b).should == answer
end
end
end
+ describe "lambda parameter" do
+ where(:a, :b, :answer) do
+ [
+ [1 , 2 , -> {should == 3}],
+ [5 , 8 , -> {should == 13}],
+ [0 , 0 , -> {should == 0}]
+ ]
+ end
+
+ with_them do
+ subject {a + b}
+ it "should do additions" do
+ self.instance_exec(&answer)
+ end
+ end
+ end
+
+
describe "table separated with pipe" do
where_table(:a, :b, :answer) do
1 | 2 | 3
"hello " | "world" | "hello world"
[1, 2, 3] | [4, 5, 6] | [1, 2, 3, 4, 5, 6]
@@ -84,8 +102,32 @@
end
with_them do
subject { a }
it { should be_is_a Numeric }
+ end
+ end
+
+ context "when the where has only one parameter to be set" do
+ where(:x) do
+ [1, 2, 3]
+ end
+
+ with_them do
+ it 'can take an array of elements' do
+ x.should == x
+ end
+ end
+ end
+
+ context "when the table has only a row" do
+ where_table(:a, :b, :answer) do
+ 1 | 2 | 3
+ end
+
+ with_them do
+ it "a plus b is answer" do
+ (a + b).should == answer
+ end
end
end
end