Skip to content

Instantly share code, notes, and snippets.

@borgand
Created November 29, 2010 10:56
Show Gist options
  • Save borgand/719825 to your computer and use it in GitHub Desktop.
Save borgand/719825 to your computer and use it in GitHub Desktop.
class RobinHood
# Ask for skills: RobinHood.can_shoot_bow?
SKILLS=[:fight_with_sword, :shoot_bow, :ride_on_horseback,
:sneak, :survive_in_forest, :get_the_word_out,
:speak_english]
# Ask for personality: RobinHood.seeks_problems?
PERSONALITY = [:seeks_problems, :gets_things_done, :has_fun,
:loves_adrenaline, :has_style, :outlaw]
# Ask for activities: RobinHood.does_recruit_followers?
ACTIVITIES = [:give_to_poor, :help_others, :fight_for_freedom,
:leak_essential_state_secrets, :recruit_followers,
:teach_newcomers]
class << self
def method_missing(name)
if name.to_s =~ /^can_/
bname = name.to_s.sub(/^can_/,"")
bname = bname.sub(/\?$/, "")
return SKILLS.include?(bname.to_sym)
elsif name.to_s =~ /^does_/
bname = name.to_s.sub(/^does_/,"")
bname = bname.sub(/\?$/, "")
return ACTIVITIES.include?(bname.to_sym)
elsif name.to_s =~ /\?$/
bname = name.to_s.sub(/\?$/, "")
return PERSONALITY.include?(bname.to_sym)
end
return false
end
def has_skills?
!SKILLS.empty?
end
def skills
SKILLS
end
end
end
require 'test/unit'
class HackerTest < Test::Unit::TestCase
def test_hacker_attitude
assert(RobinHood.seeks_problems?, "Hacker must love problems")
assert(RobinHood.gets_things_done?, "No problem shoudl ever ahve to be solved twice")
assert(RobinHood.has_fun?, "Hacker needs to have fun")
assert(RobinHood.loves_adrenaline?, "Hacker fun must not be trivial")
assert(RobinHood.does_fight_for_freedom?, "Hacker should be ati-authoritarian")
assert(RobinHood.has_skills?, "Attitude is no substitude for competence")
end
def test_hacking_skills
assert(RobinHood.has_skills?, "Hacker should have skills in his field")
assert(RobinHood.skills.size > 1, "Hacker should have more than one skill")
assert(RobinHood.can_survive_in_forest?, "Hacker should know how to use and survive w/o commercial support")
assert(RobinHood.can_get_the_word_out?, "Hacker should influence non-hackers lives")
assert(RobinHood.can_speak_english?, "Hacker must have functional English")
end
def test_status_in_hacker_culture
assert(RobinHood.does_give_to_poor?, "Hacker should open source his work")
assert(RobinHood.does_help_others?, "Hacker should help others in their problems")
assert(RobinHood.does_leak_essential_state_secrets?, "Hacker should publish useful information")
assert(RobinHood.does_recruit_followers?, "Hacker should keep the infrastructure working")
assert(RobinHood.does_teach_newcomers?, "Hacker should serve the culture itself")
end
def test_hacker_nerd_connection
assert(RobinHood.outlaw?, "Being nerd/outcast helps in being a hacker")
end
def test_hacker_style
assert(RobinHood.can_fight_with_sword? || RobinHood.does_read? ||
RobinHood.does_listen_to_music?, "Hacker should have activities for non-hacking time")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment