atdis 0.3.11 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +46 -0
  3. data/.ruby-version +1 -1
  4. data/.travis.yml +0 -4
  5. data/Gemfile +9 -7
  6. data/Guardfile +4 -3
  7. data/Rakefile +4 -2
  8. data/atdis.gemspec +10 -5
  9. data/lib/atdis.rb +2 -0
  10. data/lib/atdis/feed.rb +32 -24
  11. data/lib/atdis/model.rb +108 -95
  12. data/lib/atdis/models/address.rb +10 -4
  13. data/lib/atdis/models/application.rb +12 -9
  14. data/lib/atdis/models/authority.rb +11 -6
  15. data/lib/atdis/models/document.rb +8 -6
  16. data/lib/atdis/models/event.rb +10 -8
  17. data/lib/atdis/models/info.rb +73 -49
  18. data/lib/atdis/models/land_title_ref.rb +15 -7
  19. data/lib/atdis/models/location.rb +9 -7
  20. data/lib/atdis/models/page.rb +36 -21
  21. data/lib/atdis/models/pagination.rb +91 -32
  22. data/lib/atdis/models/person.rb +7 -5
  23. data/lib/atdis/models/reference.rb +7 -5
  24. data/lib/atdis/models/response.rb +5 -3
  25. data/lib/atdis/models/torrens_title.rb +9 -7
  26. data/lib/atdis/separated_url.rb +17 -15
  27. data/lib/atdis/validators.rb +46 -39
  28. data/lib/atdis/version.rb +3 -1
  29. data/spec/atdis/feed_spec.rb +128 -34
  30. data/spec/atdis/model_spec.rb +124 -51
  31. data/spec/atdis/models/address_spec.rb +18 -9
  32. data/spec/atdis/models/application_spec.rb +222 -155
  33. data/spec/atdis/models/authority_spec.rb +45 -15
  34. data/spec/atdis/models/document_spec.rb +10 -4
  35. data/spec/atdis/models/event_spec.rb +23 -11
  36. data/spec/atdis/models/info_spec.rb +197 -113
  37. data/spec/atdis/models/land_title_ref_spec.rb +32 -16
  38. data/spec/atdis/models/location_spec.rb +75 -60
  39. data/spec/atdis/models/page_spec.rb +244 -135
  40. data/spec/atdis/models/pagination_spec.rb +177 -77
  41. data/spec/atdis/models/person_spec.rb +8 -4
  42. data/spec/atdis/models/reference_spec.rb +29 -16
  43. data/spec/atdis/models/response_spec.rb +2 -1
  44. data/spec/atdis/models/torrens_title_spec.rb +24 -18
  45. data/spec/atdis/separated_url_spec.rb +14 -15
  46. data/spec/spec_helper.rb +14 -10
  47. metadata +62 -33
@@ -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,223 +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
161
+ end
162
+ it do
163
+ a.determination_date = "2013-01-18"
164
+ expect(a).to be_valid
165
+ end
166
+ it do
167
+ a.determination_date = "2013-18-01"
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
+ )
118
172
  end
119
173
  it do
120
174
  a.determination_date = "18 January 2013"
121
- a.should_not be_valid
122
- 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
+ )
123
179
  end
124
180
  it "nil should be allowed if the application is not yet determined" do
125
181
  a.determination_date = nil
126
- a.determination_date.should be_nil
127
- a.should be_valid
182
+ expect(a.determination_date).to be_nil
183
+ expect(a).to be_valid
128
184
  end
129
185
  end
130
186
 
131
187
  describe ".lodgement_date" do
132
188
  it do
133
189
  a.lodgement_date = nil
134
- a.should_not be_valid
135
- 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
+ )
136
194
  end
137
195
  it do
138
196
  a.lodgement_date = "18 January 2013"
139
- a.should_not be_valid
140
- 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
+ )
141
201
  end
142
202
  end
143
203
 
144
204
  describe ".authority" do
145
205
  it do
146
206
  a.authority = nil
147
- a.should_not be_valid
148
- 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"]])
149
209
  end
150
210
  end
151
211
 
152
212
  describe ".description" do
153
213
  it do
154
214
  a.description = ""
155
- a.should_not be_valid
156
- 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"]])
157
217
  end
158
218
  end
159
219
 
160
220
  describe ".last_modified_date" do
161
221
  it do
162
222
  a.last_modified_date = nil
163
- a.should_not be_valid
164
- 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
+ )
165
227
  end
166
228
  it do
167
229
  a.last_modified_date = "18 January 2013"
168
- a.should_not be_valid
169
- 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
+ )
170
234
  end
171
235
  end
172
236
 
173
237
  describe ".dat_id" do
174
238
  it ".dat_id" do
175
239
  a.dat_id = nil
176
- a.should_not be_valid
177
- 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
+ )
178
244
  end
179
245
 
180
246
  it "should be url encoded" do
181
247
  a.dat_id = "foo bar"
182
- a.should_not be_valid
183
- 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
+ )
184
252
  end
185
253
 
186
254
  it "should be valid if url encoded" do
187
255
  a.dat_id = "010%2F2014%2F00000031%2F001"
188
- a.should be_valid
256
+ expect(a).to be_valid
189
257
  end
190
258
  end
191
259
 
192
260
  describe "#description=" do
193
- let(:a) { ATDIS::Models::Info.new }
261
+ let(:a) { ATDIS::Models::Info.new({}, "UTC") }
194
262
  it "should do not type casting when it's already a String" do
195
263
  a.description = "foo"
196
- a.description.should == "foo"
264
+ expect(a.description).to eq "foo"
197
265
  end
198
266
  context "not a string" do
199
267
  before :each do
200
268
  a.description = 123
201
269
  end
202
270
  it "should cast to a string when it's not a string" do
203
- a.description.should == "123"
271
+ expect(a.description).to eq "123"
204
272
  end
205
273
  it "should keep the original value" do
206
- a.description_before_type_cast.should == 123
274
+ expect(a.description_before_type_cast).to eq 123
207
275
  end
208
276
  end
209
277
  end
210
278
 
211
279
  describe "#lodgement_date=" do
212
- let(:a) { ATDIS::Models::Info.new }
280
+ let(:a) { ATDIS::Models::Info.new({}, "UTC") }
213
281
  it "should do no type casting when it's already a date" do
214
- a.lodgement_date = DateTime.new(2013,1,1)
215
- 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)
216
284
  end
217
285
 
218
286
  it "should cast a string to a date when it's a valid date" do
219
287
  a.lodgement_date = "2013-01-01"
220
- a.lodgement_date.should == DateTime.new(2013,1,1)
288
+ expect(a.lodgement_date).to eq DateTime.new(2013, 1, 1)
221
289
  end
222
290
 
223
291
  context "not a valid date" do
@@ -225,24 +293,24 @@ describe ATDIS::Models::Info do
225
293
  a.lodgement_date = "2013/01/01"
226
294
  end
227
295
  it "should be nil" do
228
- a.lodgement_date.should be_nil
296
+ expect(a.lodgement_date).to be_nil
229
297
  end
230
298
  it "should keep the original string" do
231
- a.lodgement_date_before_type_cast.should == "2013/01/01"
299
+ expect(a.lodgement_date_before_type_cast).to eq "2013/01/01"
232
300
  end
233
301
  end
234
302
  end
235
303
 
236
304
  describe "#last_modified_date=" do
237
- let(:a) { ATDIS::Models::Info.new }
305
+ let(:a) { ATDIS::Models::Info.new({}, "UTC") }
238
306
  it "should do no type casting when it's already a date" do
239
- a.last_modified_date = DateTime.new(2013,1,1)
240
- 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)
241
309
  end
242
310
 
243
311
  it "should cast a string to a date when it's a valid date" do
244
312
  a.last_modified_date = "2013-01-01"
245
- a.last_modified_date.should == DateTime.new(2013,1,1)
313
+ expect(a.last_modified_date).to eq DateTime.new(2013, 1, 1)
246
314
  end
247
315
 
248
316
  context "not a valid date" do
@@ -250,10 +318,10 @@ describe ATDIS::Models::Info do
250
318
  a.last_modified_date = "2013/01/01"
251
319
  end
252
320
  it "should be nil" do
253
- a.last_modified_date.should be_nil
321
+ expect(a.last_modified_date).to be_nil
254
322
  end
255
323
  it "should keep the original string" do
256
- 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"
257
325
  end
258
326
  end
259
327
  end
@@ -261,47 +329,63 @@ describe ATDIS::Models::Info do
261
329
  describe "related_apps" do
262
330
  context "is missing" do
263
331
  before(:each) { a.related_apps = nil }
264
- it { a.should be_valid }
332
+ it { expect(a).to be_valid }
265
333
  end
266
334
 
267
335
  context "is not an array" do
268
- 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
269
339
  it {
270
- a.should_not be_valid
271
- 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
+ )
272
344
  }
273
345
  end
274
346
 
275
347
  context "are all valid URLs that uniquely identifies a DA" do
276
- before(:each) { a.related_apps = [
277
- "http://www.council.nsw.gov.au/atdis/1.0/2014_20-022DA.json",
278
- "http://www.council.nsw.gov.au/foo/bar/atdis/1.0/sdjfsd.json"
279
- ]}
280
- 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 }
281
355
  end
282
356
 
283
357
  context "are all valid URLs but one does not end in json" do
284
- before(:each) { a.related_apps = [
285
- "http://www.council.nsw.gov.au/atdis/1.0/2014_20-022DA.json",
286
- "http://www.council.nsw.gov.au/foo/bar/atdis/1.0/sdjfsd"
287
- ]}
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
288
364
  it {
289
- a.should_not be_valid
290
- 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
+ )
291
371
  }
292
372
  end
293
373
 
294
374
  context "contains an invalid URL" do
295
- before(:each) { a.related_apps = [
296
- "http://www.council.nsw.gov.au/atdis/1.0/2014_20-022DA.json",
297
- "foobar"
298
- ]}
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
299
381
  it {
300
- a.should_not be_valid
301
- a.errors.messages.should == {related_apps: [
302
- ATDIS::ErrorMessage.new("contains an invalid URL", "4.3.1"),
303
- ATDIS::ErrorMessage.new("contains url(s) not in the expected format", "4.3.1")
304
- ]}
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
+ )
305
389
  }
306
390
  end
307
391
  end