Skip to content

Instantly share code, notes, and snippets.

@natritmeyer
Created August 27, 2011 12:37
Show Gist options
  • Save natritmeyer/1175337 to your computer and use it in GitHub Desktop.
Save natritmeyer/1175337 to your computer and use it in GitHub Desktop.
BDD example with WPF, cucumber, ironruby and bewildr; Part 3
C:\wpfbdd>irake spec
C:/ironruby/bin/ir.exe -S rspec spec/counter_spec.rb
..
Finished in 0.2103 seconds
2 examples, 0 failures
C:\wpfbdd>irake cucumber
C:/ironruby/bin/ir.exe -I "C:/Ruby19/lib/ruby/gems/1.9.1/gems/cucumber-0.6.4/lib;lib" "C:/Ruby19/lib/ruby/gems/1.9.1/gems/cucumber-0.6.4/bin/cucumber" --format
pretty
Feature: Sheep Counter
As a farmer
In order to prevent any straggling sheep from getting eaten by the big bad wolf
I want to be able to keep track of my sheep as they move from field to field
Scenario: Before I start moving my sheep # features\sheep_counter.feature:6
When I start up my sheep counter # features/step_definitions/sheep_counter_steps.rb:1
Then it tells me that no sheep have moved field yet # features/step_definitions/sheep_counter_steps.rb:7
Scenario: Move one sheep # features\sheep_counter.feature:10
Given I have started my sheep counter # features/step_definitions/sheep_counter_steps.rb:11
When I move one sheep # features/step_definitions/sheep_counter_steps.rb:15
Then it tells me that 1 sheep has moved # features/step_definitions/sheep_counter_steps.rb:19
expected: "1",
got: "0" (using ==)
Diff:
@@ -1,2 +1,2 @@
-1
+0
(Spec::Expectations::ExpectationNotMetError)
./features/step_definitions/sheep_counter_steps.rb:20
features\sheep_counter.feature:13:in `Then it tells me that 1 sheep has moved'
Scenario: Move two sheep # features\sheep_counter.feature:15
Given I have started my sheep counter # features/step_definitions/sheep_counter_steps.rb:11
And I have moved 1 sheep already # features/step_definitions/sheep_counter_steps.rb:23
Bewildr::ElementDoesntExist (Bewildr::ElementDoesntExist)
:0:in `lambda_method'
./features/step_definitions/sheep_counter_steps.rb:16707566
features\sheep_counter.feature:17:in `And I have moved 1 sheep already'
When I move another sheep # features/step_definitions/sheep_counter_steps.rb:29
Then it tells me that 2 sheep have moved # features/step_definitions/sheep_counter_steps.rb:19
Failing Scenarios:
cucumber features\sheep_counter.feature:10 # Scenario: Move one sheep
cucumber features\sheep_counter.feature:15 # Scenario: Move two sheep
3 scenarios (2 failed, 1 passed)
9 steps (2 failed, 2 skipped, 5 passed)
0m8.012s
rake aborted!
Command failed with status (1): [C:/ironruby/bin/ir.exe -I "C:/Ruby19/lib/r...]
C:\wpfbdd>irake cucumber
C:/ironruby/bin/ir.exe -I "C:/Ruby19/lib/ruby/gems/1.9.1/gems/cucumber-0.6.4/lib;lib" "C:/Ruby19/lib/ruby/gems/1.9.1/gems/cucumber-0.6.4/bin/cucumber" --format
pretty
Feature: Sheep Counter
As a farmer
In order to prevent any straggling sheep from getting eaten by the big bad wolf
I want to be able to keep track of my sheep as they move from field to field
Scenario: Before I start moving my sheep # features\sheep_counter.feature:6
When I start up my sheep counter # features/step_definitions/sheep_counter_steps.rb:1
Then it tells me that no sheep have moved field yet # features/step_definitions/sheep_counter_steps.rb:7
Scenario: Move one sheep # features\sheep_counter.feature:10
Given I have started my sheep counter # features/step_definitions/sheep_counter_steps.rb:11
When I move one sheep # features/step_definitions/sheep_counter_steps.rb:15
Then it tells me that 1 sheep has moved # features/step_definitions/sheep_counter_steps.rb:19
Scenario: Move two sheep # features\sheep_counter.feature:15
Given I have started my sheep counter # features/step_definitions/sheep_counter_steps.rb:11
And I have moved 1 sheep already # features/step_definitions/sheep_counter_steps.rb:23
When I move another sheep # features/step_definitions/sheep_counter_steps.rb:29
Then it tells me that 2 sheep have moved # features/step_definitions/sheep_counter_steps.rb:19
3 scenarios (3 passed)
9 steps (9 passed)
0m3.705s
[snip]
Scenario: Reset the counter # features\sheep_counter.feature:21
Given I have started my sheep counter # features/step_definitions/sheep_counter_steps.rb:11
And I have moved 10 sheep already # features/step_definitions/sheep_counter_steps.rb:23
When I reset the counter # features/step_definitions/sheep_counter_steps.rb:33
Bewildr::ElementDoesntExist (Bewildr::ElementDoesntExist)
./features/step_definitions/sheep_counter_steps.rb:34
features\sheep_counter.feature:24:in `When I reset the counter'
Then it tells me that no sheep have moved field yet # features/step_definitions/sheep_counter_steps.rb:7
[snip]
[snip]
Scenario: Reset the counter # features\sheep_counter.feature:21
Given I have started my sheep counter # features/step_definitions/sheep_counter_steps.rb:11
And I have moved 10 sheep already # features/step_definitions/sheep_counter_steps.rb:23
When I reset the counter # features/step_definitions/sheep_counter_steps.rb:33
Then it tells me that no sheep have moved field yet # features/step_definitions/sheep_counter_steps.rb:7
expected: "0",
got: "10" (using ==)
Diff:
@@ -1,2 +1,2 @@
-0
+10
(Spec::Expectations::ExpectationNotMetError)
./features/step_definitions/sheep_counter_steps.rb:8
features\sheep_counter.feature:25:in `Then it tells me that no sheep have moved field yet'
[snip]
namespace Counter
{
public class Counter
{
private int currentCount;
public Counter()
{
currentCount = 0;
}
public int count()
{
return currentCount;
}
public void increment()
{
currentCount++;
}
}
}
using System.Windows;
namespace SheepCounter
{
public partial class MainWindow : Window
{
Counter.Counter counter = new Counter.Counter();
public MainWindow()
{
InitializeComponent();
update();
}
private void update()
{
sheep_count.Content = counter.count();
}
}
}
using System.Windows;
namespace SheepCounter
{
public partial class MainWindow : Window
{
Counter.Counter counter = new Counter.Counter();
public MainWindow()
{
InitializeComponent();
update();
}
private void update()
{
sheep_count.Content = counter.count();
}
private void increment_sheep_Click(object sender, RoutedEventArgs e)
{
counter.increment();
update();
}
}
}
Scenario: Reset the counter
Given I have started my sheep counter
And I have moved 10 sheep already
When I reset the counter
Then it tells me that no sheep have moved field yet
When /^I reset the counter$/ do
@counter_window.get(:id => "reset").click
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment