Skip to content

Instantly share code, notes, and snippets.

@jjulian
Created March 14, 2010 06:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjulian/331808 to your computer and use it in GitHub Desktop.
Save jjulian/331808 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe Base58 do
it "should handle creating encoded strings over 2 characters long" do
(1..100000).each do |i|
i.should encode_and_decode_to(i)
end
end
end
class EncodeDecodeCorrectly
def initialize(i)
@encoded = Base58.encode(i)
end
def matches?(target)
@target = target
# puts @encoded
return Base58.decode(@encoded) == target
end
def failure_message
"expected #{@target} to encode and decode correctly: encoded is #{@encoded}"
end
def negative_failure_message
"expected #{@target} to not encode and decode correctly: encoded is #{@encoded}"
end
end
def encode_and_decode_to(i)
EncodeDecodeCorrectly.new(i)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment