forked from thetron/ausburbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathausburbs_spec.rb
86 lines (72 loc) · 2.19 KB
/
ausburbs_spec.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
require 'spec_helper'
describe Ausburbs do
before :each do
end
it "should return a list of states, in alphabetical order" do
Ausburbs.states.should be_a(Array)
last_state = nil
Ausburbs.states.each do |state|
state.should be_a(Ausburbs::State)
(state.name > last_state.name).should be_true if last_state
last_state = state
end
end
it "should return an list of suburbs for a given state, in postcode order" do
Ausburbs.states.each do |state|
state.suburbs.should be_a(Array)
last_suburb = nil
state.suburbs.each do |suburb|
suburb.should be_a(Ausburbs::Suburb)
(suburb.postcode >= last_suburb.postcode).should be_true if last_suburb
last_suburb = suburb
end
end
end
it "should return the list of state names, in alphabetical order" do
Ausburbs.state_names.should be_a(Array)
last_state_name = nil
Ausburbs.state_names.each do |state_name|
(state_name.should >= last_state_name).should be_true if last_state_name
last_state_name = state_name
end
end
it "should return a state for a given state name" do
Ausburbs.state_names.each do |state_name|
Ausburbs.state(state_name).should be_a(Ausburbs::State)
Ausburbs.state(state_name).name.should == state_name
end
end
end
describe Ausburbs::State do
before :each do
@state = Ausburbs.states.first
end
it "should have a name" do
@state.respond_to?(:name).should be_true
@state.name.should be_a(String)
end
it "should return a list of suburbs" do
@state.suburbs.should be_an(Array)
end
end
describe Ausburbs::Suburb do
before :each do
@suburb = Ausburbs.states.first.suburbs.first
end
it "should have a name" do
@suburb.respond_to?(:name).should be_true
@suburb.name.should be_a(String)
end
it "should have a postcode" do
@suburb.respond_to?(:postcode).should be_true
@suburb.postcode.should be_a(String)
end
it "should have a latitude"do
@suburb.respond_to?(:latitude).should be_true
@suburb.latitude.should be_a(Float)
end
it "should have a longitude" do
@suburb.respond_to?(:longitude).should be_true
@suburb.longitude.should be_a(Float)
end
end