Sha256: 27bf6b44b2df57f71b8e566ca53d9de08a90734513d9449ba4ba6d02db527bc7

Contents?: true

Size: 709 Bytes

Versions: 11

Compression:

Stored size: 709 Bytes

Contents

require 'spec_helper'

describe Bidu::PeriodParser do
  shared_examples 'a class who knows how to parse time' do |tests|
    tests.each do |string, expected|
      it "parses #{string} into #{expected} seconds" do
        expect(described_class.parse(string)).to eq(expected)
      end
    end
  end

  it_behaves_like 'a class who knows how to parse time', {
    '3' => 3.seconds,
    '3seconds' => 3.seconds,
    '3minutes' => 3.minutes,
    '3hours' => 3.hours,
    '3days' => 3.days,
    '3months' => 3.months,
    '3years' => 3.years
  }

  context 'when value is already a period' do
    it 'returns the value itself' do
      expect(described_class.parse(3.minutes)).to eq(3.minutes)
    end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
mercy-1.3.0 spec/lib/bidu/period_parser_spec.rb
bidu-mercy-1.3.0 spec/lib/bidu/period_parser_spec.rb
bidu-house-1.3.0 spec/lib/bidu/period_parser_spec.rb
bidu-house-1.2.0 spec/lib/bidu/period_parser_spec.rb
bidu-house-1.1.0 spec/lib/bidu/period_parser_spec.rb
bidu-house-1.0.0 spec/lib/bidu/period_parser_spec.rb
bidu-house-0.2.1 spec/lib/bidu/period_parser_spec.rb
bidu-house-0.2.0 spec/lib/bidu/period_parser_spec.rb
bidu-house-0.1.2 spec/lib/bidu/period_parser_spec.rb
bidu-house-0.1.1 spec/lib/bidu/period_parser_spec.rb
bidu-house-0.1.0 spec/lib/bidu/period_parser_spec.rb