atdis 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 661d7d16f8ddc03b59e867f8a1bf3a691d66f02a
4
- data.tar.gz: 0630e75e2045725a519b3fe7b1e6995b0184f2e6
3
+ metadata.gz: 582504f7e4d3344558df19bd967db447c881931a
4
+ data.tar.gz: b48255b2d8920eaf72ac22eff1981a14c0283727
5
5
  SHA512:
6
- metadata.gz: ac95146aa0dd9a03477ec1f7aad2380d0291a1f6585c951f4f6bcef334bc286b25354763f3a4cb2aff618e95b098ff50245d05934e87ed1ca943e9770f648085
7
- data.tar.gz: 1d1faec28b50806f0b1f804b21d62e3d013cd855cdabed897bcf90ebca6123cfcf4847ade63f6c1f765379828baf10b3482709357b9f15c7fda1f7f207dd6a7f
6
+ metadata.gz: a8432f063d638330887b15a2f9dbb4e15e867b529a9dc2bf13d2ed612485982e55f5d6b920c59a924fcf5bb31c4d6984a7acd0b32455306979beea0c9593ed57
7
+ data.tar.gz: 0bfb0c80d9f5d2c5b57afe5b9e6c47132b38226b84fbf466a03a1a3d69f20ddfd1480d45c26e7577796787076c492c15127ebf48cec73afd8340f1201cf2720e
@@ -28,7 +28,7 @@ module ATDIS
28
28
  end
29
29
 
30
30
  def count_is_consistent
31
- if count
31
+ if count && response.respond_to?(:count)
32
32
  errors.add(:count, ErrorMessage["is not the same as the number of applications returned", "6.4"]) if count != response.count
33
33
  errors.add(:count, ErrorMessage["should not be larger than the number of results per page", "6.4"]) if count > pagination.per_page
34
34
  end
@@ -59,7 +59,7 @@ module ATDIS
59
59
  if pages && per_page && count && count > pages * per_page
60
60
  errors.add(:count, ErrorMessage["is larger than can be retrieved through paging", "6.4"])
61
61
  end
62
- if pages && per_page && count && count <= (pages - 1) * per_page
62
+ if pages && per_page && count && count > 0 && count <= (pages - 1) * per_page
63
63
  errors.add(:count, ErrorMessage["could fit into a smaller number of pages", "6.4"])
64
64
  end
65
65
  end
data/lib/atdis/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Atdis
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
@@ -5,7 +5,7 @@ describe ATDIS::Feed do
5
5
  let(:page) { double }
6
6
 
7
7
  it "should return all the applications" do
8
- ATDIS::Models::Page.should_receive(:read_url).with("http://www.council.nsw.gov.au/atdis/1.0/applications.json").and_return(page)
8
+ expect(ATDIS::Models::Page).to receive(:read_url).with("http://www.council.nsw.gov.au/atdis/1.0/applications.json").and_return(page)
9
9
  feed.applications.should == page
10
10
  end
11
11
 
@@ -89,7 +89,7 @@ describe ATDIS::Feed do
89
89
  describe "#application" do
90
90
  it {
91
91
  application = double
92
- ATDIS::Models::Application.should_receive(:read_url).with("http://www.council.nsw.gov.au/atdis/1.0/27B%2F6.json").and_return(application)
92
+ expect(ATDIS::Models::Application).to receive(:read_url).with("http://www.council.nsw.gov.au/atdis/1.0/27B%2F6.json").and_return(application)
93
93
  feed.application("27B/6").should == application
94
94
  }
95
95
  end
@@ -3,9 +3,9 @@ require "spec_helper"
3
3
  describe ATDIS::Models::Application do
4
4
  context "extra parameter in json" do
5
5
  it "should not be valid" do
6
- ATDIS::Models::Location.should_receive(:interpret).with("location").and_return(double(valid?: true))
7
- ATDIS::Models::Document.should_receive(:interpret).with("document").and_return(double(valid?: true))
8
- ATDIS::Models::Event.should_receive(:interpret).with("event").and_return(double(valid?: true))
6
+ expect(ATDIS::Models::Location).to receive(:interpret).with("location").and_return(double(valid?: true))
7
+ expect(ATDIS::Models::Document).to receive(:interpret).with("document").and_return(double(valid?: true))
8
+ expect(ATDIS::Models::Event).to receive(:interpret).with("event").and_return(double(valid?: true))
9
9
 
10
10
  a = ATDIS::Models::Application.interpret(
11
11
  info: {
@@ -41,7 +41,7 @@ describe ATDIS::Models::Application do
41
41
  it "should parse the json and create an application object" do
42
42
  application = double
43
43
 
44
- ATDIS::Models::Application.should_receive(:new).with(
44
+ expect(ATDIS::Models::Application).to receive(:new).with(
45
45
  info: {
46
46
  dat_id: "DA2013-0381",
47
47
  development_type: "residential",
@@ -100,7 +100,7 @@ describe ATDIS::Models::Application do
100
100
 
101
101
  it "should create a nil valued application when there is no information in the json" do
102
102
  application = double
103
- ATDIS::Models::Application.should_receive(:new).with({json_left_overs:{}, info: {},
103
+ expect(ATDIS::Models::Application).to receive(:new).with({json_left_overs:{}, info: {},
104
104
  reference: {}}).and_return(application)
105
105
 
106
106
  ATDIS::Models::Application.interpret(info: {}, reference: {}).should == application
@@ -118,7 +118,7 @@ describe ATDIS::Models::Application do
118
118
  let(:a) { ATDIS::Models::Application.new }
119
119
  it "should type cast to a location" do
120
120
  location = double
121
- ATDIS::Models::Location.should_receive(:interpret).with(address: "123 Fourfivesix Street").and_return(location)
121
+ expect(ATDIS::Models::Location).to receive(:interpret).with(address: "123 Fourfivesix Street").and_return(location)
122
122
  a.locations = [{ address: "123 Fourfivesix Street" }]
123
123
  a.locations.should == [location]
124
124
  end
@@ -134,8 +134,8 @@ describe ATDIS::Models::Application do
134
134
  let(:a) { ATDIS::Models::Application.new }
135
135
  it "should type cast to several events" do
136
136
  event1, event2 = double, double
137
- ATDIS::Models::Event.should_receive(:interpret).with(id: "event1").and_return(event1)
138
- ATDIS::Models::Event.should_receive(:interpret).with(id: "event2").and_return(event2)
137
+ expect(ATDIS::Models::Event).to receive(:interpret).with(id: "event1").and_return(event1)
138
+ expect(ATDIS::Models::Event).to receive(:interpret).with(id: "event2").and_return(event2)
139
139
  a.events = [ { id: "event1" }, { id: "event2" } ]
140
140
  a.events.should == [event1, event2]
141
141
  end
@@ -145,8 +145,8 @@ describe ATDIS::Models::Application do
145
145
  let(:a) { ATDIS::Models::Application.new }
146
146
  it "should type cast to several documents" do
147
147
  document1, document2 = double, double
148
- ATDIS::Models::Document.should_receive(:interpret).with(ref: "27B/6/a").and_return(document1)
149
- ATDIS::Models::Document.should_receive(:interpret).with(ref: "27B/6/b").and_return(document2)
148
+ expect(ATDIS::Models::Document).to receive(:interpret).with(ref: "27B/6/a").and_return(document1)
149
+ expect(ATDIS::Models::Document).to receive(:interpret).with(ref: "27B/6/b").and_return(document2)
150
150
  a.documents = [ { ref: "27B/6/a" }, { ref: "27B/6/b" } ]
151
151
  a.documents.should == [document1, document2]
152
152
  end
@@ -156,8 +156,8 @@ describe ATDIS::Models::Application do
156
156
  let(:a) { ATDIS::Models::Application.new }
157
157
  it "should type cast to several people" do
158
158
  tuttle, buttle = double, double
159
- ATDIS::Models::Person.should_receive(:interpret).with(name: "Tuttle").and_return(tuttle)
160
- ATDIS::Models::Person.should_receive(:interpret).with(name: "Buttle").and_return(buttle)
159
+ expect(ATDIS::Models::Person).to receive(:interpret).with(name: "Tuttle").and_return(tuttle)
160
+ expect(ATDIS::Models::Person).to receive(:interpret).with(name: "Buttle").and_return(buttle)
161
161
  a.people = [ { name: "Tuttle" }, { name: "Buttle" } ]
162
162
  a.people.should == [tuttle, buttle]
163
163
  end
@@ -181,9 +181,9 @@ describe ATDIS::Models::Application do
181
181
 
182
182
  describe "validations" do
183
183
  before :each do
184
- ATDIS::Models::Location.should_receive(:interpret).with("address").and_return(double(valid?: true))
185
- ATDIS::Models::Document.should_receive(:interpret).with("document").and_return(double(valid?: true))
186
- ATDIS::Models::Event.should_receive(:interpret).with("event").and_return(double(valid?: true))
184
+ expect(ATDIS::Models::Location).to receive(:interpret).with("address").and_return(double(valid?: true))
185
+ expect(ATDIS::Models::Document).to receive(:interpret).with("document").and_return(double(valid?: true))
186
+ expect(ATDIS::Models::Event).to receive(:interpret).with("event").and_return(double(valid?: true))
187
187
  end
188
188
 
189
189
  let(:a) { ATDIS::Models::Application.new(
@@ -215,7 +215,7 @@ describe ATDIS::Models::Application do
215
215
  describe ".location" do
216
216
  it "should not be valid if the location is not valid" do
217
217
  l = double(valid?: false)
218
- ATDIS::Models::Location.should_receive(:interpret).with(foo: "some location data").and_return(l)
218
+ expect(ATDIS::Models::Location).to receive(:interpret).with(foo: "some location data").and_return(l)
219
219
  a.locations = [{foo: "some location data"}]
220
220
  a.should_not be_valid
221
221
  end
@@ -223,7 +223,7 @@ describe ATDIS::Models::Application do
223
223
 
224
224
  describe "events" do
225
225
  it "has to be an array" do
226
- ATDIS::Models::Event.should_receive(:interpret).with(foo: "bar").and_return(double(valid?: true))
226
+ expect(ATDIS::Models::Event).to receive(:interpret).with(foo: "bar").and_return(double(valid?: true))
227
227
  a.events = {foo: "bar"}
228
228
  #a.events.should be_nil
229
229
  a.should_not be_valid
@@ -4,8 +4,8 @@ describe ATDIS::Models::LandTitleRef do
4
4
  context "torrens" do
5
5
  before(:each) {
6
6
  m = double
7
- ATDIS::Models::TorrensTitle.should_receive(:interpret).with({lot: "10"}).and_return(m)
8
- m.should_receive(:valid?).and_return(true)
7
+ expect(ATDIS::Models::TorrensTitle).to receive(:interpret).with({lot: "10"}).and_return(m)
8
+ expect(m).to receive(:valid?).and_return(true)
9
9
  }
10
10
  let(:l) { ATDIS::Models::LandTitleRef.new(torrens: {lot: "10"}) }
11
11
  it { l.should be_valid }
@@ -27,8 +27,8 @@ describe ATDIS::Models::LandTitleRef do
27
27
  context "both torrens and other" do
28
28
  before(:each) {
29
29
  m = double
30
- ATDIS::Models::TorrensTitle.should_receive(:interpret).with({lot: "10"}).and_return(m)
31
- m.should_receive(:valid?).and_return(true)
30
+ expect(ATDIS::Models::TorrensTitle).to receive(:interpret).with({lot: "10"}).and_return(m)
31
+ expect(m).to receive(:valid?).and_return(true)
32
32
  }
33
33
  let(:l) { ATDIS::Models::LandTitleRef.new(torrens: {lot: "10"}, other: {some: "foo", random: "stuff"})}
34
34
  it {
@@ -5,6 +5,12 @@ describe ATDIS::Models::Page do
5
5
  ATDIS::Models::Page.attribute_names.should == ["response", "count", "pagination"]
6
6
  end
7
7
 
8
+ it "should error if response is null" do
9
+ page = ATDIS::Models::Page.new(response: nil, count: 0, pagination: {pages: 1, per_page: 20, count: 0, current: 1})
10
+ page.should_not be_valid
11
+ page.errors.messages.should == {:response => [ATDIS::ErrorMessage["can't be blank", "4.3"]]}
12
+ end
13
+
8
14
  describe "validations" do
9
15
  context "results block that is a hash" do
10
16
  before :each do
@@ -131,14 +137,14 @@ describe ATDIS::Models::Page do
131
137
 
132
138
  it do
133
139
  page.should_not be_valid
134
- page.errors.messages.has_key?(:json).should be_true
140
+ page.errors.messages.has_key?(:json).should be_truthy
135
141
  page.errors.messages.count.should == 1
136
142
  # The error messages returned by the library are different for different Ruby versions
137
143
  ruby19_message = ATDIS::ErrorMessage["Invalid JSON: 784: unexpected token at '{\n \"response\": [\n {\n \"application\": {\n \"description\": \"application2\"\n }\n }\n ],\n}\n'", nil]
138
144
  ruby20_message = ATDIS::ErrorMessage["Invalid JSON: 795: unexpected token at '{\n \"response\": [\n {\n \"application\": {\n \"description\": \"application2\"\n }\n }\n ],\n}\n'", nil]
139
145
  page.errors.messages[:json].count.should == 1
140
146
  message = page.errors.messages[:json].first
141
- (message == ruby19_message || message == ruby20_message).should be_true
147
+ (message == ruby19_message || message == ruby20_message).should be_truthy
142
148
  end
143
149
  end
144
150
 
@@ -60,6 +60,13 @@ describe ATDIS::Models::Pagination do
60
60
  end
61
61
  end
62
62
 
63
+ 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) }
65
+ it do
66
+ pagination.should be_valid
67
+ end
68
+ end
69
+
63
70
  context "count is larger than would be expected" do
64
71
  let(:pagination) { ATDIS::Models::Pagination.new(
65
72
  previous: nil, current: 1, next: 2, per_page: 25, pages: 4, count: 101
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atdis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Landauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-02 00:00:00.000000000 Z
11
+ date: 2014-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler