File: xmlschema.rb

package info (click to toggle)
jruby 9.4.12.0%2Bds-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 89,468 kB
  • sloc: ruby: 550,612; java: 276,882; yacc: 25,873; ansic: 6,285; xml: 6,172; sh: 1,775; sed: 94; makefile: 76; jsp: 48; tcl: 40; exp: 12
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