Sha256: cdd5b69d3c498bbf5795f6f9e6a920c4d40653635ca60fb73dd51e7e542a176d

Contents?: true

Size: 1007 Bytes

Versions: 9

Compression:

Stored size: 1007 Bytes

Contents

require 'cucumber/messages'

module Cucumber
  module Messages
    describe TimeConversion do
      include TimeConversion

      it 'converts to and from milliseconds since epoch' do
        time = Time.now
        timestamp = time_to_timestamp(time)
        time_again = timestamp_to_time(timestamp)

        expect(time_again).to eq(time)
      end

      it 'converts to and from seconds duration' do
        duration_in_seconds = 1234
        duration = seconds_to_duration(duration_in_seconds)
        duration_in_seconds_again = duration_to_seconds(duration)

        expect(duration_in_seconds_again).to eq(duration_in_seconds)
      end

      it 'converts to and from seconds duration (with decimal places)' do
        duration_in_seconds = 3.000161
        duration = seconds_to_duration(duration_in_seconds)
        duration_in_seconds_again = duration_to_seconds(duration)

        expect(duration_in_seconds_again).to be_within(0.000000001).of(duration_in_seconds)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
cucumber-messages-12.2.0 spec/cucumber/messages/time_conversion_spec.rb
cucumber-messages-12.1.1 spec/cucumber/messages/time_conversion_spec.rb
cucumber-messages-12.1.0 spec/cucumber/messages/time_conversion_spec.rb
cucumber-messages-12.0.0 spec/cucumber/messages/time_conversion_spec.rb
cucumber-messages-11.1.1 spec/cucumber/messages/time_conversion_spec.rb
cucumber-messages-11.1.0 spec/cucumber/messages/time_conversion_spec.rb
cucumber-messages-11.0.1 spec/cucumber/messages/time_conversion_spec.rb
cucumber-messages-10.0.3 spec/cucumber/messages/time_conversion_spec.rb
cucumber-messages-10.0.1 spec/cucumber/messages/time_conversion_spec.rb