File: xmlschema.rb

package info (click to toggle)
ruby3.4 3.4.5-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 154,784 kB
  • sloc: ruby: 1,259,653; ansic: 829,955; yacc: 28,233; pascal: 7,359; sh: 3,864; python: 1,799; cpp: 1,158; asm: 808; makefile: 801; javascript: 414; lisp: 109; perl: 62; awk: 36; sed: 4; xml: 4
file content (31 lines) | stat: -rw-r--r-- 1,061 bytes parent folder | download | duplicates (2)
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
describe :time_xmlschema, shared: true do
  ruby_version_is "3.4" do
    it "generates ISO-8601 strings in Z for UTC times" do
      t = Time.utc(1985, 4, 12, 23, 20, 50, 521245)
      t.send(@method).should == "1985-04-12T23:20:50Z"
      t.send(@method, 2).should == "1985-04-12T23:20:50.52Z"
      t.send(@method, 9).should == "1985-04-12T23:20:50.521245000Z"
    end

    it "generates ISO-8601 string with timeone offset for non-UTC times" do
      t = Time.new(1985, 4, 12, 23, 20, 50, "+02:00")
      t.send(@method).should == "1985-04-12T23:20:50+02:00"
      t.send(@method, 2).should == "1985-04-12T23:20:50.00+02:00"
    end

    it "year is always at least 4 digits" do
      t = Time.utc(12, 4, 12)
      t.send(@method).should ==  "0012-04-12T00:00:00Z"
    end

    it "year can be more than 4 digits" do
      t = Time.utc(40_000, 4, 12)
      t.send(@method).should ==  "40000-04-12T00:00:00Z"
    end

    it "year can be negative" do
      t = Time.utc(-2000, 4, 12)
      t.send(@method).should ==  "-2000-04-12T00:00:00Z"
    end
  end
end