Skip to content

Instantly share code, notes, and snippets.

@natritmeyer
Created August 27, 2011 13:38
Show Gist options
  • Save natritmeyer/1175396 to your computer and use it in GitHub Desktop.
Save natritmeyer/1175396 to your computer and use it in GitHub Desktop.
BDD example with WPF, cucumber, ironruby and bewildr; Part 4
1) Counter should set the count back to 0 when reset
Failure/Error: @counter.reset
NoMethodError:
undefined method `reset' for Counter.Counter:Counter::Counter
# ./spec/counter_spec.rb:20
C:\wpfbdd>irake spec
C:/ironruby/bin/ir.exe -S rspec spec/counter_spec.rb
...
Finished in 0.2103 seconds
3 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
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
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
4 scenarios (4 passed)
13 steps (13 passed)
0m5.488s
public void reset()
{
currentCount = 0;
}
private void reset_Click(object sender, RoutedEventArgs e)
{
counter.reset();
update();
}
it "should set the count back to 0 when reset" do
10.times { @counter.increment }
@counter.count.should == 10
@counter.reset
@counter.count.should == 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment