atdis 0.3.13 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +46 -0
  3. data/.ruby-version +1 -1
  4. data/Gemfile +9 -7
  5. data/Guardfile +4 -3
  6. data/Rakefile +4 -2
  7. data/atdis.gemspec +10 -5
  8. data/lib/atdis.rb +2 -0
  9. data/lib/atdis/feed.rb +31 -24
  10. data/lib/atdis/model.rb +101 -99
  11. data/lib/atdis/models/address.rb +10 -4
  12. data/lib/atdis/models/application.rb +12 -9
  13. data/lib/atdis/models/authority.rb +11 -6
  14. data/lib/atdis/models/document.rb +8 -6
  15. data/lib/atdis/models/event.rb +10 -8
  16. data/lib/atdis/models/info.rb +73 -49
  17. data/lib/atdis/models/land_title_ref.rb +15 -7
  18. data/lib/atdis/models/location.rb +9 -7
  19. data/lib/atdis/models/page.rb +34 -19
  20. data/lib/atdis/models/pagination.rb +91 -32
  21. data/lib/atdis/models/person.rb +7 -5
  22. data/lib/atdis/models/reference.rb +7 -5
  23. data/lib/atdis/models/response.rb +5 -3
  24. data/lib/atdis/models/torrens_title.rb +9 -7
  25. data/lib/atdis/separated_url.rb +17 -15
  26. data/lib/atdis/validators.rb +46 -39
  27. data/lib/atdis/version.rb +3 -1
  28. data/spec/atdis/feed_spec.rb +126 -34
  29. data/spec/atdis/model_spec.rb +124 -51
  30. data/spec/atdis/models/address_spec.rb +18 -9
  31. data/spec/atdis/models/application_spec.rb +222 -155
  32. data/spec/atdis/models/authority_spec.rb +45 -15
  33. data/spec/atdis/models/document_spec.rb +10 -4
  34. data/spec/atdis/models/event_spec.rb +23 -11
  35. data/spec/atdis/models/info_spec.rb +191 -116
  36. data/spec/atdis/models/land_title_ref_spec.rb +32 -16
  37. data/spec/atdis/models/location_spec.rb +75 -60
  38. data/spec/atdis/models/page_spec.rb +241 -135
  39. data/spec/atdis/models/pagination_spec.rb +177 -77
  40. data/spec/atdis/models/person_spec.rb +8 -4
  41. data/spec/atdis/models/reference_spec.rb +29 -16
  42. data/spec/atdis/models/response_spec.rb +2 -1
  43. data/spec/atdis/models/torrens_title_spec.rb +24 -18
  44. data/spec/atdis/separated_url_spec.rb +14 -15
  45. data/spec/spec_helper.rb +14 -10
  46. metadata +56 -27
@@ -1,33 +1,63 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe ATDIS::Models::Authority do
4
6
  describe "validations" do
5
7
  context "a valid ref" do
6
- let(:a) { ATDIS::Models::Authority.new(ref: "http://www.council.nsw.gov.au/atdis/1.0", name: "Council")}
7
- it {a.should be_valid}
8
+ let(:a) do
9
+ ATDIS::Models::Authority.new(
10
+ {
11
+ ref: "http://www.council.nsw.gov.au/atdis/1.0",
12
+ name: "Council"
13
+ },
14
+ "UTC"
15
+ )
16
+ end
17
+ it { expect(a).to be_valid }
8
18
  end
9
19
 
10
20
  context "a valid ref with https" do
11
- let(:a) { ATDIS::Models::Authority.new(ref: "https://www.council.nsw.gov.au/atdis/1.0", name: "Council")}
12
- it {a.should be_valid}
21
+ let(:a) do
22
+ ATDIS::Models::Authority.new(
23
+ {
24
+ ref: "https://www.council.nsw.gov.au/atdis/1.0",
25
+ name: "Council"
26
+ },
27
+ "UTC"
28
+ )
29
+ end
30
+ it { expect(a).to be_valid }
13
31
  end
14
32
 
15
33
  context "an invalid ref that isn't a url" do
16
- let(:a) { ATDIS::Models::Authority.new(ref: "foobar", name: "Council")}
17
- it {
18
- a.should_not be_valid
19
- a.errors.messages.should == {ref: [
20
- ATDIS::ErrorMessage.new("is not a valid URL", "4.3.1"),
21
- ATDIS::ErrorMessage.new("is not a valid Unique Authority Identifier", "4.3.1")
22
- ]}
23
- }
34
+ let(:a) { ATDIS::Models::Authority.new({ ref: "foobar", name: "Council" }, "UTC") }
35
+ it do
36
+ expect(a).to_not be_valid
37
+ expect(a.errors.messages).to eq(
38
+ ref: [
39
+ ATDIS::ErrorMessage.new("is not a valid URL", "4.3.1"),
40
+ ATDIS::ErrorMessage.new("is not a valid Unique Authority Identifier", "4.3.1")
41
+ ]
42
+ )
43
+ end
24
44
  end
25
45
 
26
46
  context "an invalid ref because it doesn't end in atdis/1.0" do
27
- let(:a) { ATDIS::Models::Authority.new(ref: "http://www.council.nsw.gov.au/foobar", name: "Council")}
47
+ let(:a) do
48
+ ATDIS::Models::Authority.new(
49
+ {
50
+ ref: "http://www.council.nsw.gov.au/foobar",
51
+ name: "Council"
52
+ },
53
+ "UTC"
54
+ )
55
+ end
28
56
  it {
29
- a.should_not be_valid
30
- a.errors.messages.should == {ref: [ATDIS::ErrorMessage.new("is not a valid Unique Authority Identifier", "4.3.1")]}
57
+ expect(a).to_not be_valid
58
+ expect(a.errors.messages).to eq(
59
+ ref: [ATDIS::ErrorMessage.new("is not a valid Unique Authority Identifier", "4.3.1")]
60
+ )
31
61
  }
32
62
  end
33
63
  end
@@ -1,19 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe ATDIS::Models::Document do
4
6
  it ".attribute_names" do
5
- ATDIS::Models::Document.attribute_names.should == ["ref", "title", "document_url"]
7
+ expect(ATDIS::Models::Document.attribute_names).to eq %w[ref title document_url]
6
8
  end
7
9
 
8
10
  it ".ref" do
9
- ATDIS::Models::Document.interpret(ref: "27B/6").ref.should == "27B/6"
11
+ expect(ATDIS::Models::Document.interpret({ ref: "27B/6" }, "UTC").ref).to eq "27B/6"
10
12
  end
11
13
 
12
14
  it ".title" do
13
- ATDIS::Models::Document.interpret(title: "Authorisation for Repairs").title.should == "Authorisation for Repairs"
15
+ expect(
16
+ ATDIS::Models::Document.interpret({ title: "Authorisation for Repairs" }, "UTC").title
17
+ ).to eq "Authorisation for Repairs"
14
18
  end
15
19
 
16
20
  it ".document_url" do
17
- ATDIS::Models::Document.interpret(document_url: "http://foo.com/bar").document_url.should == URI.parse("http://foo.com/bar")
21
+ expect(
22
+ ATDIS::Models::Document.interpret({ document_url: "http://foo.com/bar" }, "UTC").document_url
23
+ ).to eq URI.parse("http://foo.com/bar")
18
24
  end
19
25
  end
@@ -1,38 +1,50 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe ATDIS::Models::Event do
4
6
  it ".attribute_names" do
5
- ATDIS::Models::Event.attribute_names.should == ["id", "timestamp", "description", "event_type", "status"]
7
+ expect(ATDIS::Models::Event.attribute_names).to eq(
8
+ %w[id timestamp description event_type status]
9
+ )
6
10
  end
7
11
 
8
12
  it ".id" do
9
- ATDIS::Models::Event.interpret(id: "27B/6").id.should == "27B/6"
13
+ expect(ATDIS::Models::Event.interpret({ id: "27B/6" }, "UTC").id).to eq "27B/6"
10
14
  end
11
15
 
12
16
  describe ".date" do
13
17
  it do
14
- ATDIS::Models::Event.interpret(timestamp: "2013-06-18").timestamp.should == DateTime.new(2013,6,18)
18
+ expect(ATDIS::Models::Event.interpret({ timestamp: "2013-06-18" }, "UTC").timestamp).to eq(
19
+ DateTime.new(2013, 6, 18)
20
+ )
15
21
  end
16
22
 
17
23
  it do
18
- e = ATDIS::Models::Event.new(description: "Something", id: "27B/6")
24
+ e = ATDIS::Models::Event.new({ description: "Something", id: "27B/6" }, "UTC")
19
25
  e.timestamp = "18 January 2013"
20
- e.should_not be_valid
21
- e.errors.messages.should == {timestamp: [ATDIS::ErrorMessage["is not a valid date", "4.3.8"]]}
26
+ expect(e).to_not be_valid
27
+ expect(e.errors.messages).to eq(
28
+ timestamp: [ATDIS::ErrorMessage["is not a valid date", "4.3.8"]]
29
+ )
22
30
  end
23
31
  end
24
32
 
25
33
  it ".description" do
26
- ATDIS::Models::Event.interpret(description: "A very fine event").description.should == "A very fine event"
34
+ expect(
35
+ ATDIS::Models::Event.interpret({ description: "A very fine event" }, "UTC").description
36
+ ).to eq "A very fine event"
27
37
  end
28
38
 
29
39
  it ".event_type" do
30
- # TODO Is event_type always a string? ATDIS-1.0.3 doesn't say
31
- ATDIS::Models::Event.interpret(event_type: "approval").event_type.should == "approval"
40
+ # TODO: Is event_type always a string? ATDIS-1.0.3 doesn't say
41
+ expect(
42
+ ATDIS::Models::Event.interpret({ event_type: "approval" }, "UTC").event_type
43
+ ).to eq "approval"
32
44
  end
33
45
 
34
46
  it ".status" do
35
- # TODO Is status always a string? ATDIS-1.0.3 doesn't say
36
- ATDIS::Models::Event.interpret(status: "approved").status.should == "approved"
47
+ # TODO: Is status always a string? ATDIS-1.0.3 doesn't say
48
+ expect(ATDIS::Models::Event.interpret({ status: "approved" }, "UTC").status).to eq "approved"
37
49
  end
38
50
  end
@@ -1,232 +1,291 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe ATDIS::Models::Info do
4
- let(:a) { ATDIS::Models::Info.new(
5
- dat_id: "DA2013-0381",
6
- development_type: "residential",
7
- application_type: "DA",
8
- last_modified_date: DateTime.new(2013,4,20,2,1,7),
9
- description: "New pool plus deck",
10
- authority: {
11
- ref: "http://www.council.nsw.gov.au/atdis/1.0",
12
- name: "Example Council Shire Council"
13
- },
14
- lodgement_date: DateTime.new(2013,4,20,2,1,7),
15
- determination_date: DateTime.new(2013,6,20),
16
- determination_type: "Pending",
17
- status: "OPEN",
18
- )}
6
+ let(:a) do
7
+ ATDIS::Models::Info.new(
8
+ {
9
+ dat_id: "DA2013-0381",
10
+ development_type: "residential",
11
+ application_type: "DA",
12
+ last_modified_date: DateTime.new(2013, 4, 20, 2, 1, 7),
13
+ description: "New pool plus deck",
14
+ authority: {
15
+ ref: "http://www.council.nsw.gov.au/atdis/1.0",
16
+ name: "Example Council Shire Council"
17
+ },
18
+ lodgement_date: DateTime.new(2013, 4, 20, 2, 1, 7),
19
+ determination_date: DateTime.new(2013, 6, 20),
20
+ determination_type: "Pending",
21
+ status: "OPEN"
22
+ },
23
+ "UTC"
24
+ )
25
+ end
19
26
 
20
27
  describe "determination_type" do
21
28
  context "is missing" do
22
- before(:each) { a.determination_type = nil}
29
+ before(:each) { a.determination_type = nil }
23
30
  it {
24
- a.should_not be_valid
25
- a.errors.messages.should == {determination_type: [ATDIS::ErrorMessage.new("does not have one of the allowed types", "4.3.1")]}
31
+ expect(a).to_not be_valid
32
+ expect(a.errors.messages).to eq(
33
+ determination_type: [
34
+ ATDIS::ErrorMessage.new("does not have one of the allowed types", "4.3.1")
35
+ ]
36
+ )
26
37
  }
27
38
  end
28
39
 
29
40
  context "is valid and Pending" do
30
41
  before(:each) { a.determination_type = "Pending" }
31
- it { a.should be_valid }
42
+ it { expect(a).to be_valid }
32
43
  end
33
44
 
34
45
  context "is not valid because it's not one of the set of allowed ones" do
35
46
  before(:each) { a.determination_type = "Something random" }
36
47
  it {
37
- a.should_not be_valid
38
- a.errors.messages.should == {determination_type: [ATDIS::ErrorMessage.new("does not have one of the allowed types", "4.3.1")]}
48
+ expect(a).to_not be_valid
49
+ expect(a.errors.messages).to eq(
50
+ determination_type: [
51
+ ATDIS::ErrorMessage.new("does not have one of the allowed types", "4.3.1")
52
+ ]
53
+ )
39
54
  }
40
55
  end
41
56
  end
42
57
 
43
58
  describe "notification_date" do
44
59
  it "both valid start and end dates" do
45
- a.notification_start_date = DateTime.new(2013,4,20,2,1,7)
46
- a.notification_end_date = DateTime.new(2013,5,20,0,0,0)
47
- a.should be_valid
60
+ a.notification_start_date = DateTime.new(2013, 4, 20, 2, 1, 7)
61
+ a.notification_end_date = DateTime.new(2013, 5, 20, 0, 0, 0)
62
+ expect(a).to be_valid
48
63
  end
49
64
 
50
65
  it "invalid start date" do
51
66
  a.notification_start_date = "18 January 2013"
52
- a.notification_end_date = DateTime.new(2013,2,1,0,0,0)
53
- a.should_not be_valid
54
- a.errors.messages.should == {notification_start_date: [ATDIS::ErrorMessage["is not a valid date", "4.3.1"]]}
67
+ a.notification_end_date = DateTime.new(2013, 2, 1, 0, 0, 0)
68
+ expect(a).to_not be_valid
69
+ expect(a.errors.messages).to eq(
70
+ notification_start_date: [
71
+ ATDIS::ErrorMessage["is not a valid date", "4.3.1"]
72
+ ]
73
+ )
55
74
  end
56
75
 
57
76
  it "invalid end date" do
58
- a.notification_start_date = DateTime.new(2013,1,10,0,0,0)
77
+ a.notification_start_date = DateTime.new(2013, 1, 10, 0, 0, 0)
59
78
  a.notification_end_date = "18 January 2013"
60
- a.should_not be_valid
61
- a.errors.messages.should == {notification_end_date: [ATDIS::ErrorMessage["is not a valid date", "4.3.1"]]}
79
+ expect(a).to_not be_valid
80
+ expect(a.errors.messages).to eq(
81
+ notification_end_date: [
82
+ ATDIS::ErrorMessage["is not a valid date", "4.3.1"]
83
+ ]
84
+ )
62
85
  end
63
86
 
64
87
  it "only start date set" do
65
- a.notification_start_date = DateTime.new(2013,4,20,2,1,7)
66
- a.should_not be_valid
67
- a.errors.messages.should == {notification_end_date: [ATDIS::ErrorMessage["can not be blank if notification_start_date is set", "4.3.1"]]}
88
+ a.notification_start_date = DateTime.new(2013, 4, 20, 2, 1, 7)
89
+ expect(a).to_not be_valid
90
+ expect(a.errors.messages).to eq(
91
+ notification_end_date: [
92
+ ATDIS::ErrorMessage["can not be blank if notification_start_date is set", "4.3.1"]
93
+ ]
94
+ )
68
95
  end
69
96
 
70
97
  it "only end date set" do
71
- a.notification_end_date = DateTime.new(2013,4,20,2,1,7)
72
- a.should_not be_valid
73
- a.errors.messages.should == {notification_start_date: [ATDIS::ErrorMessage["can not be blank if notification_end_date is set", "4.3.1"]]}
98
+ a.notification_end_date = DateTime.new(2013, 4, 20, 2, 1, 7)
99
+ expect(a).to_not be_valid
100
+ expect(a.errors.messages).to eq(
101
+ notification_start_date: [
102
+ ATDIS::ErrorMessage["can not be blank if notification_end_date is set", "4.3.1"]
103
+ ]
104
+ )
74
105
  end
75
106
 
76
107
  it "end date is before start date" do
77
- a.notification_start_date = DateTime.new(2013,5,20,0,0,0)
78
- a.notification_end_date = DateTime.new(2013,4,20,2,1,7)
79
- a.should_not be_valid
80
- a.errors.messages.should == {notification_end_date: [ATDIS::ErrorMessage["can not be earlier than notification_start_date", "4.3.1"]]}
108
+ a.notification_start_date = DateTime.new(2013, 5, 20, 0, 0, 0)
109
+ a.notification_end_date = DateTime.new(2013, 4, 20, 2, 1, 7)
110
+ expect(a).to_not be_valid
111
+ expect(a.errors.messages).to eq(
112
+ notification_end_date: [
113
+ ATDIS::ErrorMessage["can not be earlier than notification_start_date", "4.3.1"]
114
+ ]
115
+ )
81
116
  end
82
117
 
83
118
  it "both dates set to null" do
84
119
  a.notification_start_date = nil
85
120
  a.notification_end_date = nil
86
- a.notification_start_date.should be_nil
87
- a.notification_end_date.should be_nil
88
- a.should be_valid
121
+ expect(a.notification_start_date).to be_nil
122
+ expect(a.notification_end_date).to be_nil
123
+ expect(a).to be_valid
89
124
  end
90
125
 
91
126
  it "only start date set to null" do
92
127
  a.notification_start_date = nil
93
- a.notification_end_date = DateTime.new(2013,2,1,0,0,0)
94
- a.should_not be_valid
95
- a.errors.messages.should == {notification_start_date: [ATDIS::ErrorMessage["can not be blank if notification_end_date is set", "4.3.1"]]}
128
+ a.notification_end_date = DateTime.new(2013, 2, 1, 0, 0, 0)
129
+ expect(a).to_not be_valid
130
+ expect(a.errors.messages).to eq(
131
+ notification_start_date: [
132
+ ATDIS::ErrorMessage["can not be blank if notification_end_date is set", "4.3.1"]
133
+ ]
134
+ )
96
135
  end
97
136
 
98
137
  it "only end date set to null" do
99
- a.notification_start_date = DateTime.new(2013,2,1,0,0,0)
138
+ a.notification_start_date = DateTime.new(2013, 2, 1, 0, 0, 0)
100
139
  a.notification_end_date = nil
101
- a.should_not be_valid
102
- a.errors.messages.should == {notification_end_date: [ATDIS::ErrorMessage["can not be blank if notification_start_date is set", "4.3.1"]]}
140
+ expect(a).to_not be_valid
141
+ expect(a.errors.messages).to eq(
142
+ notification_end_date: [
143
+ ATDIS::ErrorMessage["can not be blank if notification_start_date is set", "4.3.1"]
144
+ ]
145
+ )
103
146
  end
104
147
  end
105
148
 
106
149
  describe ".status" do
107
150
  it do
108
151
  a.status = nil
109
- a.should_not be_valid
110
- a.errors.messages.should == {status: [ATDIS::ErrorMessage["can't be blank", "4.3.1"]]}
152
+ expect(a).to_not be_valid
153
+ expect(a.errors.messages).to eq(status: [ATDIS::ErrorMessage["can't be blank", "4.3.1"]])
111
154
  end
112
155
  end
113
156
 
114
157
  describe ".determination_date" do
115
158
  it do
116
159
  a.determination_date = nil
117
- a.should be_valid
160
+ expect(a).to be_valid
118
161
  end
119
162
  it do
120
163
  a.determination_date = "2013-01-18"
121
- a.should be_valid
164
+ expect(a).to be_valid
122
165
  end
123
166
  it do
124
167
  a.determination_date = "2013-18-01"
125
- a.should_not be_valid
126
- a.errors.messages.should == {determination_date: [ATDIS::ErrorMessage["is not a valid date", "4.3.1"]]}
168
+ expect(a).to_not be_valid
169
+ expect(a.errors.messages).to eq(
170
+ determination_date: [ATDIS::ErrorMessage["is not a valid date", "4.3.1"]]
171
+ )
127
172
  end
128
173
  it do
129
174
  a.determination_date = "18 January 2013"
130
- a.should_not be_valid
131
- a.errors.messages.should == {determination_date: [ATDIS::ErrorMessage["is not a valid date", "4.3.1"]]}
175
+ expect(a).to_not be_valid
176
+ expect(a.errors.messages).to eq(
177
+ determination_date: [ATDIS::ErrorMessage["is not a valid date", "4.3.1"]]
178
+ )
132
179
  end
133
180
  it "nil should be allowed if the application is not yet determined" do
134
181
  a.determination_date = nil
135
- a.determination_date.should be_nil
136
- a.should be_valid
182
+ expect(a.determination_date).to be_nil
183
+ expect(a).to be_valid
137
184
  end
138
185
  end
139
186
 
140
187
  describe ".lodgement_date" do
141
188
  it do
142
189
  a.lodgement_date = nil
143
- a.should_not be_valid
144
- a.errors.messages.should == {lodgement_date: [ATDIS::ErrorMessage["can't be blank", "4.3.1"]]}
190
+ expect(a).to_not be_valid
191
+ expect(a.errors.messages).to eq(
192
+ lodgement_date: [ATDIS::ErrorMessage["can't be blank", "4.3.1"]]
193
+ )
145
194
  end
146
195
  it do
147
196
  a.lodgement_date = "18 January 2013"
148
- a.should_not be_valid
149
- a.errors.messages.should == {lodgement_date: [ATDIS::ErrorMessage["is not a valid date", "4.3.1"]]}
197
+ expect(a).to_not be_valid
198
+ expect(a.errors.messages).to eq(
199
+ lodgement_date: [ATDIS::ErrorMessage["is not a valid date", "4.3.1"]]
200
+ )
150
201
  end
151
202
  end
152
203
 
153
204
  describe ".authority" do
154
205
  it do
155
206
  a.authority = nil
156
- a.should_not be_valid
157
- a.errors.messages.should == {authority: [ATDIS::ErrorMessage["can't be blank", "4.3.1"]]}
207
+ expect(a).to_not be_valid
208
+ expect(a.errors.messages).to eq(authority: [ATDIS::ErrorMessage["can't be blank", "4.3.1"]])
158
209
  end
159
210
  end
160
211
 
161
212
  describe ".description" do
162
213
  it do
163
214
  a.description = ""
164
- a.should_not be_valid
165
- a.errors.messages.should == {description: [ATDIS::ErrorMessage["can't be blank", "4.3.1"]]}
215
+ expect(a).to_not be_valid
216
+ expect(a.errors.messages).to eq(description: [ATDIS::ErrorMessage["can't be blank", "4.3.1"]])
166
217
  end
167
218
  end
168
219
 
169
220
  describe ".last_modified_date" do
170
221
  it do
171
222
  a.last_modified_date = nil
172
- a.should_not be_valid
173
- a.errors.messages.should == {last_modified_date: [ATDIS::ErrorMessage["can't be blank", "4.3.1"]]}
223
+ expect(a).to_not be_valid
224
+ expect(a.errors.messages).to eq(
225
+ last_modified_date: [ATDIS::ErrorMessage["can't be blank", "4.3.1"]]
226
+ )
174
227
  end
175
228
  it do
176
229
  a.last_modified_date = "18 January 2013"
177
- a.should_not be_valid
178
- a.errors.messages.should == {last_modified_date: [ATDIS::ErrorMessage["is not a valid date", "4.3.1"]]}
230
+ expect(a).to_not be_valid
231
+ expect(a.errors.messages).to eq(
232
+ last_modified_date: [ATDIS::ErrorMessage["is not a valid date", "4.3.1"]]
233
+ )
179
234
  end
180
235
  end
181
236
 
182
237
  describe ".dat_id" do
183
238
  it ".dat_id" do
184
239
  a.dat_id = nil
185
- a.should_not be_valid
186
- a.errors.messages.should == {dat_id: [ATDIS::ErrorMessage["can't be blank", "4.3.1"]]}
240
+ expect(a).to_not be_valid
241
+ expect(a.errors.messages).to eq(
242
+ dat_id: [ATDIS::ErrorMessage["can't be blank", "4.3.1"]]
243
+ )
187
244
  end
188
245
 
189
246
  it "should be url encoded" do
190
247
  a.dat_id = "foo bar"
191
- a.should_not be_valid
192
- a.errors.messages.should == {dat_id: [ATDIS::ErrorMessage["should be url encoded", "4.3.1"]]}
248
+ expect(a).to_not be_valid
249
+ expect(a.errors.messages).to eq(
250
+ dat_id: [ATDIS::ErrorMessage["should be url encoded", "4.3.1"]]
251
+ )
193
252
  end
194
253
 
195
254
  it "should be valid if url encoded" do
196
255
  a.dat_id = "010%2F2014%2F00000031%2F001"
197
- a.should be_valid
256
+ expect(a).to be_valid
198
257
  end
199
258
  end
200
259
 
201
260
  describe "#description=" do
202
- let(:a) { ATDIS::Models::Info.new }
261
+ let(:a) { ATDIS::Models::Info.new({}, "UTC") }
203
262
  it "should do not type casting when it's already a String" do
204
263
  a.description = "foo"
205
- a.description.should == "foo"
264
+ expect(a.description).to eq "foo"
206
265
  end
207
266
  context "not a string" do
208
267
  before :each do
209
268
  a.description = 123
210
269
  end
211
270
  it "should cast to a string when it's not a string" do
212
- a.description.should == "123"
271
+ expect(a.description).to eq "123"
213
272
  end
214
273
  it "should keep the original value" do
215
- a.description_before_type_cast.should == 123
274
+ expect(a.description_before_type_cast).to eq 123
216
275
  end
217
276
  end
218
277
  end
219
278
 
220
279
  describe "#lodgement_date=" do
221
- let(:a) { ATDIS::Models::Info.new }
280
+ let(:a) { ATDIS::Models::Info.new({}, "UTC") }
222
281
  it "should do no type casting when it's already a date" do
223
- a.lodgement_date = DateTime.new(2013,1,1)
224
- a.lodgement_date.should == DateTime.new(2013,1,1)
282
+ a.lodgement_date = DateTime.new(2013, 1, 1)
283
+ expect(a.lodgement_date).to eq DateTime.new(2013, 1, 1)
225
284
  end
226
285
 
227
286
  it "should cast a string to a date when it's a valid date" do
228
287
  a.lodgement_date = "2013-01-01"
229
- a.lodgement_date.should == DateTime.new(2013,1,1)
288
+ expect(a.lodgement_date).to eq DateTime.new(2013, 1, 1)
230
289
  end
231
290
 
232
291
  context "not a valid date" do
@@ -234,24 +293,24 @@ describe ATDIS::Models::Info do
234
293
  a.lodgement_date = "2013/01/01"
235
294
  end
236
295
  it "should be nil" do
237
- a.lodgement_date.should be_nil
296
+ expect(a.lodgement_date).to be_nil
238
297
  end
239
298
  it "should keep the original string" do
240
- a.lodgement_date_before_type_cast.should == "2013/01/01"
299
+ expect(a.lodgement_date_before_type_cast).to eq "2013/01/01"
241
300
  end
242
301
  end
243
302
  end
244
303
 
245
304
  describe "#last_modified_date=" do
246
- let(:a) { ATDIS::Models::Info.new }
305
+ let(:a) { ATDIS::Models::Info.new({}, "UTC") }
247
306
  it "should do no type casting when it's already a date" do
248
- a.last_modified_date = DateTime.new(2013,1,1)
249
- a.last_modified_date.should == DateTime.new(2013,1,1)
307
+ a.last_modified_date = DateTime.new(2013, 1, 1)
308
+ expect(a.last_modified_date).to eq DateTime.new(2013, 1, 1)
250
309
  end
251
310
 
252
311
  it "should cast a string to a date when it's a valid date" do
253
312
  a.last_modified_date = "2013-01-01"
254
- a.last_modified_date.should == DateTime.new(2013,1,1)
313
+ expect(a.last_modified_date).to eq DateTime.new(2013, 1, 1)
255
314
  end
256
315
 
257
316
  context "not a valid date" do
@@ -259,10 +318,10 @@ describe ATDIS::Models::Info do
259
318
  a.last_modified_date = "2013/01/01"
260
319
  end
261
320
  it "should be nil" do
262
- a.last_modified_date.should be_nil
321
+ expect(a.last_modified_date).to be_nil
263
322
  end
264
323
  it "should keep the original string" do
265
- a.last_modified_date_before_type_cast.should == "2013/01/01"
324
+ expect(a.last_modified_date_before_type_cast).to eq "2013/01/01"
266
325
  end
267
326
  end
268
327
  end
@@ -270,47 +329,63 @@ describe ATDIS::Models::Info do
270
329
  describe "related_apps" do
271
330
  context "is missing" do
272
331
  before(:each) { a.related_apps = nil }
273
- it { a.should be_valid }
332
+ it { expect(a).to be_valid }
274
333
  end
275
334
 
276
335
  context "is not an array" do
277
- before(:each) { a.related_apps = "http://www.council.nsw.gov.au/atdis/1.0/2014_20-022DA.json"}
336
+ before(:each) do
337
+ a.related_apps = "http://www.council.nsw.gov.au/atdis/1.0/2014_20-022DA.json"
338
+ end
278
339
  it {
279
- a.should_not be_valid
280
- a.errors.messages.should == {related_apps: [ATDIS::ErrorMessage.new("should be an array", "4.3.1")]}
340
+ expect(a).to_not be_valid
341
+ expect(a.errors.messages).to eq(
342
+ related_apps: [ATDIS::ErrorMessage.new("should be an array", "4.3.1")]
343
+ )
281
344
  }
282
345
  end
283
346
 
284
347
  context "are all valid URLs that uniquely identifies a DA" do
285
- before(:each) { a.related_apps = [
286
- "http://www.council.nsw.gov.au/atdis/1.0/2014_20-022DA.json",
287
- "http://www.council.nsw.gov.au/foo/bar/atdis/1.0/sdjfsd.json"
288
- ]}
289
- it { a.should be_valid }
348
+ before(:each) do
349
+ a.related_apps = [
350
+ "http://www.council.nsw.gov.au/atdis/1.0/2014_20-022DA.json",
351
+ "http://www.council.nsw.gov.au/foo/bar/atdis/1.0/sdjfsd.json"
352
+ ]
353
+ end
354
+ it { expect(a).to be_valid }
290
355
  end
291
356
 
292
357
  context "are all valid URLs but one does not end in json" do
293
- before(:each) { a.related_apps = [
294
- "http://www.council.nsw.gov.au/atdis/1.0/2014_20-022DA.json",
295
- "http://www.council.nsw.gov.au/foo/bar/atdis/1.0/sdjfsd"
296
- ]}
358
+ before(:each) do
359
+ a.related_apps = [
360
+ "http://www.council.nsw.gov.au/atdis/1.0/2014_20-022DA.json",
361
+ "http://www.council.nsw.gov.au/foo/bar/atdis/1.0/sdjfsd"
362
+ ]
363
+ end
297
364
  it {
298
- a.should_not be_valid
299
- a.errors.messages.should == {related_apps: [ATDIS::ErrorMessage.new("contains url(s) not in the expected format", "4.3.1")]}
365
+ expect(a).to_not be_valid
366
+ expect(a.errors.messages).to eq(
367
+ related_apps: [
368
+ ATDIS::ErrorMessage.new("contains url(s) not in the expected format", "4.3.1")
369
+ ]
370
+ )
300
371
  }
301
372
  end
302
373
 
303
374
  context "contains an invalid URL" do
304
- before(:each) { a.related_apps = [
305
- "http://www.council.nsw.gov.au/atdis/1.0/2014_20-022DA.json",
306
- "foobar"
307
- ]}
375
+ before(:each) do
376
+ a.related_apps = [
377
+ "http://www.council.nsw.gov.au/atdis/1.0/2014_20-022DA.json",
378
+ "foobar"
379
+ ]
380
+ end
308
381
  it {
309
- a.should_not be_valid
310
- a.errors.messages.should == {related_apps: [
311
- ATDIS::ErrorMessage.new("contains an invalid URL", "4.3.1"),
312
- ATDIS::ErrorMessage.new("contains url(s) not in the expected format", "4.3.1")
313
- ]}
382
+ expect(a).to_not be_valid
383
+ expect(a.errors.messages).to eq(
384
+ related_apps: [
385
+ ATDIS::ErrorMessage.new("contains an invalid URL", "4.3.1"),
386
+ ATDIS::ErrorMessage.new("contains url(s) not in the expected format", "4.3.1")
387
+ ]
388
+ )
314
389
  }
315
390
  end
316
391
  end