Skip to content

Instantly share code, notes, and snippets.

@mpereira
Created October 17, 2010 15:48
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 mpereira/630956 to your computer and use it in GitHub Desktop.
Save mpereira/630956 to your computer and use it in GitHub Desktop.
require 'test/unit'
require 'test/unit/ui/console/testrunner'
def scrubble(array)
array.dup.inject([]) do |scrubbled, element|
scrubbled << array.reject { |e| e == element }
end
end
class ScrubbleTest < Test::Unit::TestCase
def setup
@array = %w[one two three]
@scrubbled_array = [%w[two three], %w[one three], %w[one two]]
end
def test_scrubble
assert_equal(scrubble(@array), @scrubbled_array)
end
end
Test::Unit::UI::Console::TestRunner.run(ScrubbleTest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment