Sha256: 0095c9125a5740a5549759eba6e2b8390646aff352731c54895fa3ce92cdc14a

Contents?: true

Size: 1.68 KB

Versions: 4

Compression:

Stored size: 1.68 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Yardstick do
  describe '.measure' do
    describe 'with no arguments' do
      before :all do
        @measurements = Yardstick.measure
      end

      it_should_behave_like 'measured itself'
    end

    describe 'with a String path' do
      before :all do
        @measurements = Yardstick.measure(Yardstick::ROOT.join('lib', 'yardstick.rb').to_s)
      end

      it_should_behave_like 'measured itself'
    end

    describe 'with a Pathname' do
      before :all do
        @measurements = Yardstick.measure(Yardstick::ROOT.join('lib', 'yardstick.rb'))
      end

      it_should_behave_like 'measured itself'
    end

    describe 'with an Array of String objects' do
      before :all do
        @measurements = Yardstick.measure([ Yardstick::ROOT.join('lib', 'yardstick.rb').to_s ])
      end

      it_should_behave_like 'measured itself'
    end

    describe 'with an Array of Pathname objects' do
      before :all do
        @measurements = Yardstick.measure([ Yardstick::ROOT.join('lib', 'yardstick.rb') ])
      end

      it_should_behave_like 'measured itself'
    end
  end

  describe '.measure_string' do
    describe 'with a String' do
      before do
        @measurements = Yardstick.measure_string('def test; end')
      end

      it 'should return a MeasurementSet' do
        @measurements.should be_kind_of(Yardstick::MeasurementSet)
      end

      it 'should be non-empty' do
        @measurements.should_not be_empty
      end
    end

    describe 'with no arguments' do
      it 'should raise an exception' do
        lambda {
          Yardstick.measure_string
        }.should raise_error(ArgumentError)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yardstick-0.9.6 spec/unit/yardstick_spec.rb
yardstick-0.9.5 spec/unit/yardstick_spec.rb
yardstick-0.9.4 spec/unit/yardstick_spec.rb
yardstick-0.9.3 spec/unit/yardstick_spec.rb