atdis 0.3.13 → 0.4.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 (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,160 +1,260 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe ATDIS::Models::Pagination do
4
6
  context "valid pagination" do
5
- let (:pagination) { ATDIS::Models::Pagination.new(
6
- previous: nil, current: 1, next: 2, per_page: 25, pages: 4, count: 90
7
- )}
7
+ let(:pagination) do
8
+ ATDIS::Models::Pagination.new(
9
+ { previous: nil, current: 1, next: 2, per_page: 25, pages: 4, count: 90 },
10
+ "UTC"
11
+ )
12
+ end
8
13
  it do
9
- pagination.should be_valid
14
+ expect(pagination).to be_valid
10
15
  end
11
16
  end
12
17
 
13
18
  context "current is not set" do
14
- let (:pagination) { ATDIS::Models::Pagination.new(
15
- previous: nil, current: nil, next: 2, per_page: 25, pages: 4, count: 90
16
- )}
19
+ let(:pagination) do
20
+ ATDIS::Models::Pagination.new(
21
+ { previous: nil, current: nil, next: 2, per_page: 25, pages: 4, count: 90 },
22
+ "UTC"
23
+ )
24
+ end
17
25
  it do
18
- pagination.should_not be_valid
19
- pagination.errors.messages.should == {current: [ATDIS::ErrorMessage["should be present if pagination is being used", "6.4"]]}
26
+ expect(pagination).to_not be_valid
27
+ expect(pagination.errors.messages).to eq(
28
+ current: [ATDIS::ErrorMessage["should be present if pagination is being used", "6.4"]]
29
+ )
20
30
  end
21
31
  end
22
32
 
23
33
  context "per_page is not set" do
24
- let (:pagination) { ATDIS::Models::Pagination.new(
25
- previous: nil, current: 1, next: 2, per_page: nil, pages: 4, count: 90
26
- )}
34
+ let(:pagination) do
35
+ ATDIS::Models::Pagination.new(
36
+ { previous: nil, current: 1, next: 2, per_page: nil, pages: 4, count: 90 },
37
+ "UTC"
38
+ )
39
+ end
27
40
  it do
28
- pagination.should_not be_valid
29
- pagination.errors.messages.should == {per_page: [ATDIS::ErrorMessage["should be present if pagination is being used", "6.4"]]}
41
+ expect(pagination).to_not be_valid
42
+ expect(pagination.errors.messages).to eq(
43
+ per_page: [ATDIS::ErrorMessage["should be present if pagination is being used", "6.4"]]
44
+ )
30
45
  end
31
46
  end
32
47
 
33
48
  context "total_not_results is not set" do
34
- let (:pagination) { ATDIS::Models::Pagination.new(
35
- previous: nil, current: 1, next: 2, per_page: 25, pages: 4, count: nil
36
- )}
49
+ let(:pagination) do
50
+ ATDIS::Models::Pagination.new(
51
+ { previous: nil, current: 1, next: 2, per_page: 25, pages: 4, count: nil },
52
+ "UTC"
53
+ )
54
+ end
37
55
  it do
38
- pagination.should_not be_valid
39
- pagination.errors.messages.should == {count: [ATDIS::ErrorMessage["should be present if pagination is being used", "6.4"]]}
56
+ expect(pagination).to_not be_valid
57
+ expect(pagination.errors.messages).to eq(
58
+ count: [ATDIS::ErrorMessage["should be present if pagination is being used", "6.4"]]
59
+ )
40
60
  end
41
61
  end
42
62
 
43
63
  context "pages is not set" do
44
- let (:pagination) { ATDIS::Models::Pagination.new(
45
- previous: nil, current: 1, next: 2, per_page: 25, pages: nil, count: 90
46
- )}
64
+ let(:pagination) do
65
+ ATDIS::Models::Pagination.new(
66
+ { previous: nil, current: 1, next: 2, per_page: 25, pages: nil, count: 90 },
67
+ "UTC"
68
+ )
69
+ end
47
70
  it do
48
- pagination.should_not be_valid
49
- pagination.errors.messages.should == {pages: [ATDIS::ErrorMessage["should be present if pagination is being used", "6.4"]]}
71
+ expect(pagination).to_not be_valid
72
+ expect(pagination.errors.messages).to eq(
73
+ pages: [ATDIS::ErrorMessage["should be present if pagination is being used", "6.4"]]
74
+ )
50
75
  end
51
76
  end
52
77
 
53
78
  context "total no_results is less than would be expected" do
54
- let (:pagination) { ATDIS::Models::Pagination.new(
55
- previous: nil, current: 1, next: 2, per_page: 25, pages: 4, count: 75
56
- )}
79
+ let(:pagination) do
80
+ ATDIS::Models::Pagination.new(
81
+ { previous: nil, current: 1, next: 2, per_page: 25, pages: 4, count: 75 },
82
+ "UTC"
83
+ )
84
+ end
57
85
  it do
58
- pagination.should_not be_valid
59
- pagination.errors.messages.should == {count: [ATDIS::ErrorMessage["could fit into a smaller number of pages", "6.4"]]}
86
+ expect(pagination).to_not be_valid
87
+ expect(pagination.errors.messages).to eq(
88
+ count: [ATDIS::ErrorMessage["could fit into a smaller number of pages", "6.4"]]
89
+ )
60
90
  end
61
91
  end
62
92
 
63
93
  context "zero results returned" do
64
- let (:pagination) { ATDIS::Models::Pagination.new(previous: nil, current: 1, next: nil, per_page: 25, pages: 1, count: 0) }
94
+ let(:pagination) do
95
+ ATDIS::Models::Pagination.new(
96
+ { previous: nil, current: 1, next: nil, per_page: 25, pages: 1, count: 0 },
97
+ "UTC"
98
+ )
99
+ end
65
100
  it do
66
- pagination.should be_valid
101
+ expect(pagination).to be_valid
67
102
  end
68
103
  end
69
104
 
70
105
  context "count is larger than would be expected" do
71
- let(:pagination) { ATDIS::Models::Pagination.new(
72
- previous: nil, current: 1, next: 2, per_page: 25, pages: 4, count: 101
73
- )}
106
+ let(:pagination) do
107
+ ATDIS::Models::Pagination.new(
108
+ { previous: nil, current: 1, next: 2, per_page: 25, pages: 4, count: 101 },
109
+ "UTC"
110
+ )
111
+ end
74
112
  it do
75
- pagination.should_not be_valid
76
- pagination.errors.messages.should == {count: [ATDIS::ErrorMessage["is larger than can be retrieved through paging", "6.4"]]}
113
+ expect(pagination).to_not be_valid
114
+ expect(pagination.errors.messages).to eq(
115
+ count: [ATDIS::ErrorMessage["is larger than can be retrieved through paging", "6.4"]]
116
+ )
77
117
  end
78
118
  end
79
119
 
80
120
  context "current page is zero" do
81
- let(:pagination) { ATDIS::Models::Pagination.new(
82
- previous: nil, current: 0, next: 1, pages: 1, per_page: 25, count: 2
83
- ) }
121
+ let(:pagination) do
122
+ ATDIS::Models::Pagination.new(
123
+ { previous: nil, current: 0, next: 1, pages: 1, per_page: 25, count: 2 },
124
+ "UTC"
125
+ )
126
+ end
84
127
  it do
85
- pagination.should_not be_valid
86
- pagination.errors.messages.should == {current: [ATDIS::ErrorMessage["can not be less than 1", "6.4"]]}
128
+ expect(pagination).to_not be_valid
129
+ expect(pagination.errors.messages).to eq(
130
+ current: [ATDIS::ErrorMessage["can not be less than 1", "6.4"]]
131
+ )
87
132
  end
88
133
  end
89
134
 
90
135
  context "current page is larger than the number of pages" do
91
- let(:pagination) { ATDIS::Models::Pagination.new(
92
- previous: nil, previous: 1, current: 2, next: 3, pages: 1, per_page: 25, count: 2
93
- ) }
136
+ let(:pagination) do
137
+ ATDIS::Models::Pagination.new(
138
+ { previous: 1, current: 2, next: 3, pages: 1, per_page: 25, count: 2 },
139
+ "UTC"
140
+ )
141
+ end
94
142
  it do
95
- pagination.should_not be_valid
96
- pagination.errors.messages.should == {current: [ATDIS::ErrorMessage["is larger than the number of pages", "6.4"]]}
143
+ expect(pagination).to_not be_valid
144
+ expect(pagination.errors.messages).to eq(
145
+ current: [ATDIS::ErrorMessage["is larger than the number of pages", "6.4"]]
146
+ )
97
147
  end
98
148
  end
99
149
 
100
150
  context "next page number is not nil but on last page" do
101
- let(:pagination) { ATDIS::Models::Pagination.new(
102
- previous: 3, current: 4, next: 5, pages: 4, per_page: 25, count: 100
103
- ) }
151
+ let(:pagination) do
152
+ ATDIS::Models::Pagination.new(
153
+ { previous: 3, current: 4, next: 5, pages: 4, per_page: 25, count: 100 },
154
+ "UTC"
155
+ )
156
+ end
104
157
  it do
105
- pagination.should_not be_valid
106
- pagination.errors.messages.should == {next: [ATDIS::ErrorMessage["should be null if on the last page", "6.4"]]}
158
+ expect(pagination).to_not be_valid
159
+ expect(pagination.errors.messages).to eq(
160
+ next: [ATDIS::ErrorMessage["should be null if on the last page", "6.4"]]
161
+ )
107
162
  end
108
163
  end
109
164
 
110
165
  context "next page number is nil but not on last page" do
111
- let(:pagination) { ATDIS::Models::Pagination.new(
112
- previous: 3, current: 4, next: nil, pages: 6, per_page: 25, count: 140
113
- ) }
166
+ let(:pagination) do
167
+ ATDIS::Models::Pagination.new(
168
+ { previous: 3, current: 4, next: nil, pages: 6, per_page: 25, count: 140 },
169
+ "UTC"
170
+ )
171
+ end
114
172
  it do
115
- pagination.should_not be_valid
116
- pagination.errors.messages.should == {next: [ATDIS::ErrorMessage["can't be null if not on the last page", "6.4"]]}
173
+ expect(pagination).to_not be_valid
174
+ expect(pagination.errors.messages).to eq(
175
+ next: [ATDIS::ErrorMessage["can't be null if not on the last page", "6.4"]]
176
+ )
117
177
  end
118
178
  end
119
179
 
120
180
  context "next page number is pointing to a weird page number" do
121
- let(:pagination) { ATDIS::Models::Pagination.new(
122
- previous: nil, current: 1, next: 5, pages: 2, per_page: 25, count: 50
123
- ) }
181
+ let(:pagination) do
182
+ ATDIS::Models::Pagination.new(
183
+ { previous: nil, current: 1, next: 5, pages: 2, per_page: 25, count: 50 },
184
+ "UTC"
185
+ )
186
+ end
124
187
  it do
125
- pagination.should_not be_valid
126
- pagination.errors.messages.should == {next: [ATDIS::ErrorMessage["should be one greater than current page number or null if last page", "6.4"]]}
188
+ expect(pagination).to_not be_valid
189
+ expect(pagination.errors.messages).to eq(
190
+ next: [
191
+ ATDIS::ErrorMessage[
192
+ "should be one greater than current page number or null if last page",
193
+ "6.4"
194
+ ]
195
+ ]
196
+ )
127
197
  end
128
198
  end
129
199
 
130
200
  context "previous page number not nil but on first page" do
131
- let(:pagination) { ATDIS::Models::Pagination.new(
132
- previous: 0, current: 1, next: 2, pages: 10, per_page: 25, count: 240
133
- ) }
201
+ let(:pagination) do
202
+ ATDIS::Models::Pagination.new(
203
+ { previous: 0, current: 1, next: 2, pages: 10, per_page: 25, count: 240 },
204
+ "UTC"
205
+ )
206
+ end
134
207
  it do
135
- pagination.should_not be_valid
136
- pagination.errors.messages.should == {previous: [ATDIS::ErrorMessage["should be null if on the first page", "6.4"]]}
208
+ expect(pagination).to_not be_valid
209
+ expect(pagination.errors.messages).to eq(
210
+ previous: [ATDIS::ErrorMessage["should be null if on the first page", "6.4"]]
211
+ )
137
212
  end
138
213
  end
139
214
 
140
215
  context "previous page number if nil but not on first page" do
141
- let(:pagination) { ATDIS::Models::Pagination.new(
142
- previous: nil, current: 4, next: 5, pages: 10, per_page: 25, count: 240
143
- ) }
216
+ let(:pagination) do
217
+ ATDIS::Models::Pagination.new(
218
+ { previous: nil, current: 4, next: 5, pages: 10, per_page: 25, count: 240 },
219
+ "UTC"
220
+ )
221
+ end
144
222
  it do
145
- pagination.should_not be_valid
146
- pagination.errors.messages.should == {previous: [ATDIS::ErrorMessage["can't be null if not on the first page", "6.4"]]}
223
+ expect(pagination).to_not be_valid
224
+ expect(pagination.errors.messages).to eq(
225
+ previous: [ATDIS::ErrorMessage["can't be null if not on the first page", "6.4"]]
226
+ )
147
227
  end
148
228
  end
149
229
 
150
230
  context "previous page number is pointing to a weird page number" do
151
- let(:pagination) { ATDIS::Models::Pagination.new(
152
- previous: 5, current: 2, next: nil, pages: 2, per_page: 25, count: 50
153
- ) }
231
+ let(:pagination) do
232
+ ATDIS::Models::Pagination.new(
233
+ { previous: 5, current: 2, next: nil, pages: 2, per_page: 25, count: 50 },
234
+ "UTC"
235
+ )
236
+ end
154
237
  it do
155
- pagination.should_not be_valid
156
- pagination.errors.messages.should == {previous: [ATDIS::ErrorMessage["should be one less than current page number or null if first page", "6.4"]]}
157
- pagination.json_errors.should == [[{previous: 5}, [ATDIS::ErrorMessage["previous should be one less than current page number or null if first page", "6.4"]]]]
238
+ expect(pagination).to_not be_valid
239
+ expect(pagination.errors.messages).to eq(
240
+ previous: [
241
+ ATDIS::ErrorMessage[
242
+ "should be one less than current page number or null if first page",
243
+ "6.4"
244
+ ]
245
+ ]
246
+ )
247
+ expect(pagination.json_errors).to eq(
248
+ [[
249
+ { previous: 5 },
250
+ [
251
+ ATDIS::ErrorMessage[
252
+ "previous should be one less than current page number or null if first page",
253
+ "6.4"
254
+ ]
255
+ ]
256
+ ]]
257
+ )
158
258
  end
159
259
  end
160
260
  end
@@ -1,19 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe ATDIS::Models::Person do
4
6
  it ".attribute_names" do
5
- ATDIS::Models::Person.attribute_names.should == ["name", "role", "contact"]
7
+ expect(ATDIS::Models::Person.attribute_names).to eq %w[name role contact]
6
8
  end
7
9
 
8
10
  it ".name" do
9
- ATDIS::Models::Person.interpret(name: "Tuttle").name.should == "Tuttle"
11
+ expect(ATDIS::Models::Person.interpret({ name: "Tuttle" }, "UTC").name).to eq "Tuttle"
10
12
  end
11
13
 
12
14
  it ".role" do
13
- ATDIS::Models::Person.interpret(role: "Heating Engineer").role.should == "Heating Engineer"
15
+ expect(
16
+ ATDIS::Models::Person.interpret({ role: "Heating Engineer" }, "UTC").role
17
+ ).to eq "Heating Engineer"
14
18
  end
15
19
 
16
20
  it ".contact" do
17
- ATDIS::Models::Person.interpret(contact: "94-FLUSH").contact.should == "94-FLUSH"
21
+ expect(ATDIS::Models::Person.interpret({ contact: "94-FLUSH" }, "UTC").contact).to eq "94-FLUSH"
18
22
  end
19
23
  end
@@ -1,43 +1,56 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe ATDIS::Models::Reference do
4
- let(:a) { ATDIS::Models::Reference.new(
5
- more_info_url: URI.parse("http://foo.com/bar"),
6
- )}
6
+ let(:a) do
7
+ ATDIS::Models::Reference.new(
8
+ { more_info_url: URI.parse("http://foo.com/bar") },
9
+ "UTC"
10
+ )
11
+ end
7
12
 
8
13
  describe ".more_info_url" do
9
14
  it do
10
15
  a.more_info_url = nil
11
- a.should_not be_valid
12
- a.errors.messages.should == {more_info_url: [ATDIS::ErrorMessage["can't be blank", "4.3.2"]]}
16
+ expect(a).to_not be_valid
17
+ expect(a.errors.messages).to eq(
18
+ more_info_url: [ATDIS::ErrorMessage["can't be blank", "4.3.2"]]
19
+ )
13
20
  end
14
21
  it do
15
22
  a.more_info_url = "This is not a valid url"
16
- a.should_not be_valid
17
- a.errors.messages.should == {more_info_url: [ATDIS::ErrorMessage["is not a valid URL", "4.3.2"]]}
23
+ expect(a).to_not be_valid
24
+ expect(a.errors.messages).to eq(
25
+ more_info_url: [ATDIS::ErrorMessage["is not a valid URL", "4.3.2"]]
26
+ )
18
27
  end
19
28
  it do
20
29
  a.more_info_url = "foo.com"
21
- a.should_not be_valid
22
- a.errors.messages.should == {more_info_url: [ATDIS::ErrorMessage["is not a valid URL", "4.3.2"]]}
30
+ expect(a).to_not be_valid
31
+ expect(a.errors.messages).to eq(
32
+ more_info_url: [ATDIS::ErrorMessage["is not a valid URL", "4.3.2"]]
33
+ )
23
34
  end
24
35
  it do
25
36
  a.more_info_url = "httpss://foo.com"
26
- a.should_not be_valid
27
- a.errors.messages.should == {more_info_url: [ATDIS::ErrorMessage["is not a valid URL", "4.3.2"]]}
37
+ expect(a).to_not be_valid
38
+ expect(a.errors.messages).to eq(
39
+ more_info_url: [ATDIS::ErrorMessage["is not a valid URL", "4.3.2"]]
40
+ )
28
41
  end
29
42
  end
30
43
 
31
44
  describe "#more_info_url=" do
32
- let(:a) { ATDIS::Models::Reference.new }
45
+ let(:a) { ATDIS::Models::Reference.new({}, "UTC") }
33
46
  it "should do no type casting when it's already a URI" do
34
47
  a.more_info_url = URI.parse("http://foo.com/bar")
35
- a.more_info_url.should == URI.parse("http://foo.com/bar")
48
+ expect(a.more_info_url).to eq URI.parse("http://foo.com/bar")
36
49
  end
37
50
 
38
51
  it "should cast a string to a URI when it's a valid url" do
39
52
  a.more_info_url = "http://foo.com/bar"
40
- a.more_info_url.should == URI.parse("http://foo.com/bar")
53
+ expect(a.more_info_url).to eq URI.parse("http://foo.com/bar")
41
54
  end
42
55
 
43
56
  context "not a valid url" do
@@ -45,10 +58,10 @@ describe ATDIS::Models::Reference do
45
58
  a.more_info_url = "This is not a url"
46
59
  end
47
60
  it "should be nil" do
48
- a.more_info_url.should be_nil
61
+ expect(a.more_info_url).to be_nil
49
62
  end
50
63
  it "should keep the original string" do
51
- a.more_info_url_before_type_cast.should == "This is not a url"
64
+ expect(a.more_info_url_before_type_cast).to eq "This is not a url"
52
65
  end
53
66
  end
54
67
  end
@@ -1,5 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe ATDIS::Models::Response do
4
-
5
6
  end