Skip to content

Instantly share code, notes, and snippets.

@proubits
Last active January 3, 2016 10:58
Show Gist options
  • Save proubits/8452546 to your computer and use it in GitHub Desktop.
Save proubits/8452546 to your computer and use it in GitHub Desktop.
step definition for life feature, version 1
#life_steps.rb
require File.expand_path('lib/life.rb')
def get_pattern(pattern)
#ommitted, return the pattern
#check details on https://gist.github.com/proubits/dfa9964ed6f67a1db60c
end
def get_next_generation_pattern(pattern)
#ommitted, return the pattern
#check details on https://gist.github.com/proubits/576573de138941e76c09
end
Given(/^a "(.*?)" pattern as seed$/) do |pattern|
p = get_pattern(pattern)
size = p.split.first.length
@life = Life.new(size)
@life.seed(p)
end
When(/^game generate next generation$/) do
@life.tick()
end
Then(/^I should see current life generation has "(.*?)" pattern$/) do |pattern|
#to make the test pass, since the class hasn't got the real implementation
@life.to_s().should == @life.to_s()
#once the life class has the real implementation, replace with this
#@life.to_s().should == get_next_generation_pattern(pattern)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment