Sha256: 70e6887c4c64f40f9f8c36b3aab47c96ebfbea8592a0b20e35766454778ae646

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require 'helper'

class TestFizzBuzz < MiniTest::Unit::TestCase

  def test_new_fizzbuzz
    assert_instance_of FizzBuzz, FizzBuzz.new
  end

  def setup
    @fizzbuzz = FizzBuzz.new
  end

  def test_crunch
    assert_respond_to @fizzbuzz, :crunch
    assert_kind_of Array, @fizzbuzz.crunch

    assert_equal 100,         @fizzbuzz.crunch.length
    assert_equal "Fizz",      @fizzbuzz.crunch[2]
    assert_equal "4",         @fizzbuzz.crunch[3].to_s
    assert_equal "Buzz",      @fizzbuzz.crunch[4]
    assert_equal "FizzBuzz",  @fizzbuzz.crunch[14]
  end


  def test_crunch_with_range
    assert_equal 14,          @fizzbuzz.crunch(4,17).length
    assert_equal "Fizz",      @fizzbuzz.crunch(4,17)[2]
    assert_equal "4",         @fizzbuzz.crunch(4,17)[0].to_s
    assert_equal "Buzz",      @fizzbuzz.crunch(4,17)[1]
    assert_equal "FizzBuzz",  @fizzbuzz.crunch(4,17)[11]

    assert_nil @fizzbuzz.crunch(44,17)
  end


  def test_will_it_fizz
    assert_respond_to 4, :fizz?
    assert            3.fizz?
    assert_nil        2.fizz?
  end


  def test_will_it_buzz
    assert_respond_to 4, :buzz?
    assert            5.buzz?
    assert_nil        2.buzz?
  end


  def test_will_it_fizzbuzz
    assert_respond_to 4, :fizzbuzz?
    assert            30.fizzbuzz?
    assert_nil        2.fizzbuzz?
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fizz-buzz-0.3.0 test/test_fizz-buzz.rb