mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 01:31:39 -05:00
Add spec for CountriesAndCities service
This commit is contained in:
parent
111667ce5a
commit
0afea82aae
1 changed files with 30 additions and 0 deletions
30
spec/services/countries_and_cities_spec.rb
Normal file
30
spec/services/countries_and_cities_spec.rb
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CountriesAndCities do
|
||||
describe '#call' do
|
||||
subject(:countries_and_cities) { described_class.new(points).call }
|
||||
|
||||
let(:points) do
|
||||
[
|
||||
create(:point, latitude: 0, longitude: 0, city: 'City', country: 'Country'),
|
||||
create(:point, latitude: 1, longitude: 1, city: 'City', country: 'Country'),
|
||||
create(:point, latitude: 2, longitude: 2, city: 'City', country: 'Country'),
|
||||
create(:point, latitude: 2, longitude: 2, city: 'Another city', country: 'Some Country'),
|
||||
create(:point, latitude: 2, longitude: 6, city: 'Another city', country: 'Some Country')
|
||||
]
|
||||
end
|
||||
|
||||
before do
|
||||
stub_const('CountriesAndCities::MINIMUM_POINTS_IN_CITY', 1)
|
||||
end
|
||||
|
||||
it 'returns countries and cities' do
|
||||
expect(countries_and_cities).to eq(
|
||||
[
|
||||
{ cities: [{city: "City", points: 3, timestamp: 1}], country: "Country" },
|
||||
{ cities: [{city: "Another city", points: 2, timestamp: 1}], country: "Some Country" }
|
||||
]
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue