geopolitical 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,8 @@
1
+ Fabricator :address do
2
+ nation
3
+ city
4
+ title { Faker::Address.street_name }
5
+ number { rand(5000) }
6
+ zip { Faker::Address.zip_code }
7
+ # geom { [rand(30) - 50, rand(40) - 30] }
8
+ end
@@ -1,6 +1,6 @@
1
1
  Fabricator :city do
2
2
  nation
3
- name { sequence(:name) { |i| "#{Faker::Address.city}#{i}" }}
3
+ name { sequence(:name) { |i| "#{Faker::Address.city}#{i}" } }
4
4
  geom { [rand(30) - 50, rand(40) - 30] }
5
- #code { object.name[0..2].upcase }
5
+ # code { object.name[0..2].upcase }
6
6
  end
@@ -1,6 +1,5 @@
1
1
  Fabricator :hood do
2
2
  city
3
- name { sequence(:name) { |i| "#{Faker::Address.city}#{i}" }}
3
+ name { sequence(:name) { |i| "#{Faker::Address.city}#{i}" } }
4
4
  geom { [rand(30) - 50, rand(40) - 30] }
5
- #code { object.name[0..2].upcase }
6
5
  end
@@ -1,4 +1,4 @@
1
1
  Fabricator :nation do
2
- name { sequence { |i| Faker::Address.country }}
2
+ name { sequence { |i| Faker::Address.country } }
3
3
  abbr { |c| c[:name].first.upcase + ('A'..'Z').to_a[rand(23)] }
4
4
  end
@@ -3,23 +3,23 @@ require 'spec_helper'
3
3
 
4
4
  describe City do
5
5
 
6
- it "should create a city" do
7
- lambda { City.make! }.should_not raise_error
6
+ it 'should create a city' do
7
+ -> { City.make! }.should_not raise_error
8
8
  end
9
9
 
10
- describe "instance" do
11
- let(:city) { City.make! }
10
+ describe 'instance' do
12
11
 
12
+ let(:city) { City.make! }
13
13
 
14
- describe "Relatives" do
14
+ describe 'Relatives' do
15
15
  let(:nation) { Nation.make! }
16
16
 
17
- it "should belongs to nation" do
17
+ it 'should belongs to nation' do
18
18
  city.nation = nation
19
19
  city.save.should be_true
20
20
  end
21
21
 
22
- it "should belongs to region" do
22
+ it 'should belongs to region' do
23
23
  city.nation = nation
24
24
  city.save.should be_true
25
25
  end
@@ -28,24 +28,22 @@ describe City do
28
28
 
29
29
  end
30
30
 
31
- describe "geoenabled" do
31
+ describe 'geoenabled' do
32
32
  before do
33
33
  City.create_indexes
34
34
  end
35
35
 
36
- it "should find closest one" do
37
- pending
36
+ it 'should find closest one' do
38
37
  city = City.make!
39
- City.closest_to(city.geom).should eql(city)
38
+ City.nearby(city.geom).first.should eql(city)
40
39
  end
41
40
 
42
41
  end
43
42
 
44
- describe "validations" do
45
-
46
- it "should have a slug" do
47
- city = City.new(name: "")
43
+ describe 'validations' do
48
44
 
45
+ it 'should have a slug' do
46
+ city = City.new(name: '')
49
47
 
50
48
  city.save
51
49
  city.should_not be_valid
@@ -53,22 +51,25 @@ describe City do
53
51
  end
54
52
 
55
53
  end
56
- # it { should have_indices :name, :geom, :area, [:region_id, :nation_id] }
57
54
 
55
+ end
56
+
57
+ # it { should have_indices :name, :geom, :area, [:region_id, :nation_id] }
58
58
 
59
- # it "should accept an area" do
60
- # @city = City.make(:area => Polygon.from_coordinates([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]]))
59
+ # it 'should accept an area' do
60
+ # @city = City.make(:area => Polygon.from_coordinates([
61
+ # [[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]]))
61
62
  # @city.area.should be_instance_of(Polygon)
62
63
  # end
63
64
 
64
- # describe "some helpers" do
65
- # it "should have some nice x y z" do
65
+ # describe 'some helpers' do
66
+ # it 'should have some nice x y z' do
66
67
  # @city = City.make
67
68
  # @city.should respond_to(:x,:y,:z)
68
69
  # end
69
70
  # end
70
71
 
71
- # describe "Find by proximity" do
72
+ # describe 'Find by proximity' do
72
73
 
73
74
  # def pt(x,y); Point.from_x_y(x,y); end
74
75
 
@@ -79,20 +80,19 @@ describe City do
79
80
  # @ponto = pt(12,12)
80
81
  # end
81
82
 
82
- # it "should find the closest city" do
83
+ # it 'should find the closest city' do
83
84
  # @city = City.close_to(@ponto).first
84
85
  # @city.should eql(@perto)
85
86
  # end
86
87
 
87
- # it "should find the closest city to make sure" do
88
+ # it 'should find the closest city to make sure' do
88
89
  # ponto = pt(22,22)
89
90
  # @city = City.close_to(ponto).first
90
91
  # @city.should eql(@medio)
91
92
  # end
92
93
 
93
- # it "should find the closest" do
94
+ # it 'should find the closest' do
94
95
  # @poi = City.close_to(@ponto).first(2)
95
96
  # @poi.should eql([@perto,@medio])
96
97
  # end
97
98
  # end
98
- end
@@ -2,15 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  describe Hood do
4
4
 
5
-
6
- it "should create a nation" do
7
- lambda { Hood.make! }.should_not raise_error
5
+ it 'should create a nation' do
6
+ -> { Hood.make! }.should_not raise_error
8
7
  end
9
8
 
10
-
11
- it "should belong to city" do
12
- Fabricate.build(:hood, :city => nil).should have(1).error_on(:city)
9
+ it 'should belong to city' do
10
+ Fabricate.build(:hood, city: nil).should have(1).error_on(:city)
13
11
  end
14
12
 
15
-
16
13
  end
@@ -2,11 +2,31 @@ require 'spec_helper'
2
2
 
3
3
  describe Nation do
4
4
 
5
+ it 'should create a nation' do
6
+ -> { Nation.make! }.should_not raise_error
7
+ end
5
8
 
6
- it "should create a nation" do
7
- lambda { Nation.make! }.should_not raise_error
9
+ it 'should require an abbr' do
10
+ Nation.make(abbr: nil).should have(1).error_on(:abbr)
8
11
  end
9
12
 
13
+ it 'should validates uniqueness of abbr' do
14
+ Nation.make!(abbr: 'BR')
15
+ Nation.make(abbr: 'BR').should have(1).error_on(:abbr)
16
+ end
10
17
 
18
+ it 'should have abbr as _id' do
19
+ Nation.make!(abbr: 'BR')
20
+ Nation.first[:_id].should eq('BR')
21
+ end
22
+
23
+ it 'may have a localized name' do
24
+ I18n.locale = :pt
25
+ n = Nation.new(name: 'Brasil')
26
+ n.name.should eq('Brasil')
27
+ I18n.locale = :en
28
+ n.name = 'Brazil'
29
+ n.name_translations.should eq('pt' => 'Brasil', 'en' => 'Brazil')
30
+ end
11
31
 
12
32
  end
@@ -2,11 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe Region do
4
4
 
5
-
6
- it "should create a region" do
7
- lambda { Region.make! }.should_not raise_error
5
+ it 'should create a region' do
6
+ -> { Region.make! }.should_not raise_error
8
7
  end
9
8
 
10
-
11
-
12
9
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # This file is copied to spec/ when you run 'rails generate rspec:install'
2
- ENV["RAILS_ENV"] ||= 'test'
3
- require File.expand_path("../dummy/config/environment", __FILE__)
2
+ ENV['RAILS_ENV'] ||= 'test'
3
+ require File.expand_path('../dummy/config/environment', __FILE__)
4
4
  require 'rspec/rails'
5
5
  require 'rspec/autorun'
6
6
  require 'faker'
@@ -9,15 +9,15 @@ require 'fabrication/syntax/make'
9
9
 
10
10
  # Requires supporting ruby files with custom matchers and macros, etc,
11
11
  # in spec/support/ and its subdirectories.
12
- Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
12
+ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
13
13
 
14
14
  # Checks for pending migrations before tests are run.
15
15
  # If you are not using ActiveRecord, you can remove this line.
16
16
  ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
17
17
 
18
18
  Fabrication.configure do |config|
19
- #config.fabricator_path = 'data/fabricators'
20
- config.path_prefix = Rails.root.join("../../")
19
+ # config.fabricator_path = 'data/fabricators'
20
+ config.path_prefix = Rails.root.join('../../')
21
21
  end
22
22
 
23
23
  RSpec.configure do |config|
@@ -50,5 +50,5 @@ RSpec.configure do |config|
50
50
  # order dependency and want to debug it, you can fix the order by providing
51
51
  # the seed, which is printed after each run.
52
52
  # --seed 1234
53
- config.order = "random"
53
+ config.order = 'random'
54
54
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geopolitical
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos Piccinini
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-05 00:00:00.000000000 Z
11
+ date: 2013-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -94,6 +94,34 @@ dependencies:
94
94
  - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: rspec-rails
99
127
  requirement: !ruby/object:Gem::Requirement
@@ -133,6 +161,8 @@ files:
133
161
  - app/views/geopolitical/regions/index.html.haml
134
162
  - app/views/geopolitical/regions/_form.html.haml
135
163
  - app/views/geopolitical/regions/_region.html.haml
164
+ - app/views/geopolitical/addresses/_address.html.haml
165
+ - app/views/geopolitical/addresses/_form.html.haml
136
166
  - app/views/geopolitical/geopolitical/new.html.haml
137
167
  - app/views/geopolitical/geopolitical/index.html.haml
138
168
  - app/views/geopolitical/geopolitical/edit.html.haml
@@ -187,6 +217,7 @@ files:
187
217
  - spec/fabricators/hood_fabricator.rb
188
218
  - spec/fabricators/nation_fabricator.rb
189
219
  - spec/fabricators/region_fabricator.rb
220
+ - spec/fabricators/address_fabricator.rb
190
221
  - spec/dummy/public/500.html
191
222
  - spec/dummy/public/404.html
192
223
  - spec/dummy/public/favicon.ico
@@ -252,6 +283,7 @@ test_files:
252
283
  - spec/fabricators/hood_fabricator.rb
253
284
  - spec/fabricators/nation_fabricator.rb
254
285
  - spec/fabricators/region_fabricator.rb
286
+ - spec/fabricators/address_fabricator.rb
255
287
  - spec/dummy/public/500.html
256
288
  - spec/dummy/public/404.html
257
289
  - spec/dummy/public/favicon.ico