forked from immateriel/im_onix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_date.rb
68 lines (53 loc) · 1.64 KB
/
test_date.rb
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
require 'helper'
require 'onix/serializer'
class TestDate < Minitest::Test
context "other publication date format" do
setup do
message = ONIX::ONIXMessage.new
message.parse('test/fixtures/other-publication-date-format.xml')
@product = message.products.last
end
should "be published" do
assert_equal Date.new(2011, 8, 31), @product.publication_date
end
should "be no embargo date" do
assert_equal nil, @product.embargo_date
end
end
context "with embargo date" do
setup do
message = ONIX::ONIXMessage.new
message.parse('test/fixtures/embargo-date.xml')
@product = message.products.last
end
should "be published" do
assert_equal Date.new(2011, 8, 31), @product.publication_date
end
should "be no embargo date" do
assert_equal Date.new(2012, 9, 21), @product.embargo_date
end
end
context "with preorder embargo date" do
setup do
message = ONIX::ONIXMessage.new
message.parse('test/fixtures/preorder-embargo-date.xml')
@product = message.products.last
end
should "be published" do
assert_equal Date.new(2011, 8, 31), @product.publication_date
end
should "have a preorder embargo date" do
assert_equal Date.new(2011, 8, 21), @product.preorder_embargo_date
end
end
context "with YYYY date format" do
setup do
message = ONIX::ONIXMessage.new
message.parse('test/fixtures/test_YYYY_date_format.xml')
@product = message.products.last
end
should "have a correct date format" do
assert_equal Date.new(1989, 01, 01), @product.publication_date
end
end
end