File: weeks_spec.rb

package info (click to toggle)
ruby-iso8601 0.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 316 kB
  • sloc: ruby: 2,156; makefile: 3
file content (48 lines) | stat: -rw-r--r-- 1,090 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe ISO8601::Weeks do
  describe 'Atomic' do
    let(:subject) { ISO8601::Weeks.new(1) }

    it "should respond to the Atomic interface" do
      %i[factor
         to_seconds
         symbol
         to_i
         to_f
         to_s
         value
         <=>
         eql?
         hash
         valid_atom?].each { |m| expect(subject).to respond_to(m) }
    end
  end

  describe '#factor' do
    it "should return the Week factor" do
      expect(ISO8601::Weeks.new(2).factor).to eq(604800)
    end
  end

  describe '#to_seconds' do
    it "should return the amount of seconds" do
      expect(ISO8601::Weeks.new(2).to_seconds).to eq(1209600)
      expect(ISO8601::Weeks.new(-2).to_seconds).to eq(-1209600)
    end
  end

  describe '#symbol' do
    it "should return the ISO symbol" do
      expect(ISO8601::Weeks.new(1).symbol).to eq(:W)
    end
  end

  describe '#hash' do
    it "should build hash identity by value" do
      expect(ISO8601::Weeks.new(3).hash).to eq(ISO8601::Weeks.new(3).hash)
    end
  end
end