Skip to content

Instantly share code, notes, and snippets.

@deathbob
Created April 8, 2011 17:53
Show Gist options
  • Select an option

  • Save deathbob/910375 to your computer and use it in GitHub Desktop.

Select an option

Save deathbob/910375 to your computer and use it in GitHub Desktop.
class TenCommandments
# Had to change this method name, it didn't read well in my test suite.
# t.should be_thou_shalt_not_kill??? Give me a break. Not idiomatic Ruby!
# *I* would't be caught dead with those specs on.
# def thou_shalt_not_kill
# true
# end
# Much more idiomatic. Now my specs read like butter too.
# t.should be_a_person_who_does_not_commit_murder.
def a_person_who_does_not_commit_murder
true
end
end
@jeremy6d

jeremy6d commented Apr 8, 2011

Copy link
Copy Markdown

def murderer? <= the question mark is idiomatic ruby
true
end

person.should_not be_murderer

Your "thou shalt not kill" method doesn't make sense; I can't think of an equivalent method I'd write an use that way. But it actually does kind of sound like a test:

thou.should_not kill(thee)

The issue here is that the idiomatic method makes it clear that this is a state check. This is distinct from a identity check, such as:
thou = ChildOfGod.new
thou.should be_a_child_of_god

With all that said, yes: Yahweh probably would not have used RSpec as his Ten Commandments design tool. Granted. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment