Skip to content

Instantly share code, notes, and snippets.

@taylor
Created January 27, 2009 03:15
Show Gist options
  • Select an option

  • Save taylor/53143 to your computer and use it in GitHub Desktop.

Select an option

Save taylor/53143 to your computer and use it in GitHub Desktop.
require 'pushuproutine'
require 'spec/expectations'
@pr=nil
Given /^I have an empty routine$/ do
@pr = PushupRoutine.new
end
When /^I add a set with (\d+) (\w+) reps for the first set$/ do |reps, speed|
reps = reps.to_i
@pr.add_repset(speed,reps)
end
When /^then I add a (\d+) more sets with (\d+) (\w+) reps each$/ do |num_sets, reps, speed|
reps = reps.to_i
1.upto(num_sets.to_i) do |i|
ret = @pr.add_repset(speed, reps)
#ret.should == [{:reps=>reps, :speed=>speed}]
end
end
Then /^I should have a routine with the following reps: (.*) for a total of (\d+)$/ do |repset,total|
total = total.to_i
rs = []
repset.split(", ").inject([]) do |rs,e|
n,s = e.split
rs << {:speed=>s, :reps=>n.to_i}
end
@pr.repset.length.should == rs.length
prtotal = 0
rs.each_with_index do |repset,n|
@pr.repset(n)[:speed].should == repset[:speed]
@pr.repset(n)[:reps].should == repset[:reps]
prtotal += (@pr.repset(n)[:reps])
end
prtotal.should == total
end
When /^I add a set with (\d+) (\w+)$/ do |reps,speed|
reps = reps.to_i
ret = @pr.add_repset(speed,reps)
ret.should == nil
end
Then /^I should still have an empty routine$/ do
@pr.repset.length.should == 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment