Sha256: d60dd8aa97799e19dc147a3dd27dcdcf00116ab0a154dc0916fff7bff08fc1dc

Contents?: true

Size: 791 Bytes

Versions: 1

Compression:

Stored size: 791 Bytes

Contents

require "test_helper"

module Whitespace
  describe Counter do
    before do
      @counter = Counter.new
    end

    it "is initially 0" do
      expect(@counter.to_int).must_equal 0
    end

    describe "#increment" do
      it "increases its value by 1" do
        @counter.increment

        expect(@counter.to_int).must_equal 1
      end
    end

    describe "#change_to" do
      describe "when the value is non-negative" do
        it "changes the counter's value to the given value" do
          @counter.change_to 5

          expect(@counter.to_int).must_equal 5
        end
      end

      describe "when the value is negative" do
        it "raises ArgumentError" do
          expect { @counter.change_to -1 }.must_raise ArgumentError
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whitespace-ruby-1.0.0 test/whitespace/data_structures/counter_test.rb