Permalink
Browse files

Testing scenario examples

  • Loading branch information...
1 parent 7cb9491 commit 412dcbc99779a264766361a69be146bbb9546109 @dkowis committed Jan 24, 2012
@@ -7,5 +7,5 @@
@RunWith(Cucumber.class)
@Feature(value = "RackStack.feature")
-public class stack {
+public class stackTest {
}
@@ -4,19 +4,32 @@ Feature: I need a stack!
So that I can demonstrate awesome things in a stack
So that I can make more money!
-Scenario: Push an item into a stack
- Given an empty stack
- When I push an item into the stack
- Then the stack contains one item
+ Scenario: Push an item into a stack
+ Given an empty stack
+ When I push an item into the stack
+ Then the stack contains one item
-Scenario: Push two items into a stack
- Given an empty stack
- When I push an item into the stack
- And I push another item into the stack
- Then the stack contains two items
+ Scenario: Push two items into a stack
+ Given an empty stack
+ When I push an item into the stack
+ And I push another item into the stack
+ Then the stack contains two items
-Scenario: Pop a given item from the stack
- Given an empty stack
- When I push an item into the stack
- And I pop from the stack
- Then I get the same item back
+ Scenario: Pop a given item from the stack
+ Given an empty stack
+ When I push an item into the stack
+ And I pop from the stack
+ Then I get the same item back
+
+ Scenario Outline: do stuff with a stack
+ Given an empty stack
+ When I push "<value>" into the stack
+ And I push "<value2>" into the stack
+ When I pop two values from the stack
+ Then I should get "<value3>"
+ Examples:
+ | value | value2 | value3 |
+ | 1 | 1 | 1,1 |
+ | omg | wtf | wtf,omg |
+ | 2 | 1 | 1,2 |
+ | lol | bbq | bbq,lol |
@@ -1,5 +1,6 @@
require 'java'
require 'test/unit'
+include Test::Unit::Assertions
require 'rubygems'
require 'rspec'
@@ -39,3 +40,17 @@
Then /^I get the same item back$/ do
@popped_item.should == @item
end
+
+When /^I push "([^"]*)" into the stack$/ do |value|
+ @stack.push(value)
+end
+
+When /^I pop two values from the stack$/ do
+ @value = Array.new
+ @value << @stack.pop()
+ @value << @stack.pop()
+end
+
+Then /^I should get "([^"]*)"$/ do |arg1|
+ assert_equal arg1, @value.join(",")
+end

0 comments on commit 412dcbc

Please sign in to comment.