Sha256: c8f2e0b4bd3abe0e5361e63f0725de23a21a0933a9f673c8561370fde9936eea

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

require 'spec_helper'

describe 'routine' do
  context 'no method arguments' do
    it 'returns benchmark result' do
      expect((routine 'test_string', 'benches 20 reps of split').first).to be_a Benchmark::Tms
    end
  end

  context 'method has integer argument' do
    it 'returns benchmark result' do
      expect((routine 'test_string', "benches 20 reps of insert with (0,a)").first).to be_a Benchmark::Tms
    end
  end

  context 'method has float argument' do
    it 'returns benchmark result' do
      expect((routine 32.444, 'benches 20 reps of + with (4.43)').first).to be_a Benchmark::Tms
    end
  end
end

describe 'float?' do
  context 'input string contains only a float' do
    it 'returns true' do
      expect(float?('32.555')).to eql true
    end
  end

  context 'input string contains letters and numbers' do
    it 'returns false' do
      expect(float?('ab321')).to eql false
    end
  end

  context 'input string contains an integer' do
    it 'returns false' do
      expect(float?('32')).to eql false
    end
  end

  context 'input string does not contain any numbers' do
    it 'returns false' do
      expect(float?('stuff')).to eql false
    end
  end
end

describe 'integer?' do
  context 'input string contains only an integer' do
    it 'returns true' do
      expect(integer?('32')).to eql true
    end
  end

  context 'input string contains a float' do
    it 'returns false' do
      expect(integer?('32.423')).to eql false
    end
  end

  context 'input string contains letters and numbers' do
    it 'returns false' do
      expect(integer?('abc123')).to eql false
    end
  end

  context 'input string does not contain any numbers' do
    it 'returns false' do
      expect(integer?('abc')).to eql false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
benches-0.1.0 spec/dsl_spec.rb