Skip to content

Instantly share code, notes, and snippets.

@benkoshy
Last active April 20, 2017 11:05
Show Gist options
  • Select an option

  • Save benkoshy/76d310e94ec6f1cc77f938f2d1498aac to your computer and use it in GitHub Desktop.

Select an option

Save benkoshy/76d310e94ec6f1cc77f938f2d1498aac to your computer and use it in GitHub Desktop.
Change Kata tests
# probably not the most DRY.
# you'd want to DRY it up just in case you screwed up 
# some of the test itself.
# i spent a good 40 minutes trying to work out where I went wrong.
# it turns out that the problem was not in the code, but in the tests!
# I had to skip all the tests to finally work out what was going on.

require "minitest/autorun"
require_relative "../lib/change"

class ChangeTest < Minitest::Test

	def setup
	end

	def test_pass_in_1_to_exchange
		c = Currency.new(1)
		actual = c.change 
		assert_equal [1], actual
	end

	def test_pass_in_2_to_exchange
		skip
		c = Currency.new(2)
		actual = c.change 
		assert_equal [1,1], actual
	end

	def test_pass_in_3_to_exchange
		skip
		c = Currency.new(3)
		actual = c.change 
		assert_equal [1,1,1], actual
	end

	def test_pass_in_4_to_exchange
		skip
		c = Currency.new(4)
		actual = c.change 
		assert_equal [1,1,1, 1], actual
	end

	def test_pass_in_5_to_exchange
		skip
		c = Currency.new(5)
		actual = c.change 
		assert_equal [5], actual
	end

	def test_pass_in_6_to_exchange
		skip
		c = Currency.new(6)
		actual = c.change 
		assert_equal [5,1], actual
	end

	def test_pass_in_7_to_exchange
		skip
		c = Currency.new(7)
		actual = c.change 
		assert_equal [5,1, 1], actual
	end

	def test_pass_in_8_to_exchange
		skip
		c = Currency.new(8)
		actual = c.change 
		assert_equal [5,1, 1, 1], actual
	end

	def test_pass_in_9_to_exchange
		skip
		c = Currency.new(9)
		c.change 
		assert_equal [5,1, 1, 1, 1], actual
	end

	def test_pass_in_10_to_exchange
		skip
		c = Currency.new(10)
		actual = c.change 
		assert_equal [10], actual
	end

	def test_pass_in_26_to_exchange
		skip
		c = Currency.new(26)
		actual = c.change 
		assert_equal [25,1], actual
	end

	def test_pass_in_81_to_exchange
		skip
		c = Currency.new(81)
		actual = c.change 
		assert_equal [50,25,5,1], actual
	end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment