|
8 | 8 | site.process |
9 | 9 | end |
10 | 10 |
|
11 | | - context "looking for locations" do |
12 | | - let(:options) { Jekyll::Maps::OptionsParser.parse("") } |
| 11 | + context "looking for locations in posts" do |
| 12 | + let(:options) { Jekyll::Maps::OptionsParser.parse("src='_posts'") } |
13 | 13 | let(:finder) { Jekyll::Maps::LocationFinder.new(options) } |
14 | 14 | let(:actual) { finder.find(site, page) } |
15 | 15 |
|
|
18 | 18 | expect(actual).to all(include(:latitude, :longitude, :title, :url)) |
19 | 19 | end |
20 | 20 |
|
| 21 | + it "finds location in post" do |
| 22 | + expect(actual.find { |l| l[:title] == "London" }).to be_a(Hash) |
| 23 | + end |
| 24 | + |
21 | 25 | it "skips posts without location" do |
22 | 26 | actual.each do |location| |
23 | 27 | expect(location).not_to include(:title => "post without location") |
24 | 28 | end |
25 | 29 | end |
| 30 | + end |
| 31 | + |
| 32 | + context "looking for locations in custom collections" do |
| 33 | + let(:options) { Jekyll::Maps::OptionsParser.parse("src='_my_collection'") } |
| 34 | + let(:finder) { Jekyll::Maps::LocationFinder.new(options) } |
| 35 | + let(:actual) { finder.find(site, page) } |
26 | 36 |
|
27 | 37 | it "finds location in custom collections" do |
28 | 38 | expect(actual.find { |l| l[:title] == "Tokyo" }).to be_a(Hash) |
29 | 39 | end |
| 40 | + end |
| 41 | + |
| 42 | + context "looking for locations in data files with deep source" do |
| 43 | + let(:options) { Jekyll::Maps::OptionsParser.parse("src='_data/france'") } |
| 44 | + let(:finder) { Jekyll::Maps::LocationFinder.new(options) } |
| 45 | + let(:actual) { finder.find(site, page) } |
| 46 | + |
| 47 | + it "finds location from France" do |
| 48 | + expect(actual.find { |l| l[:title] == "Paris" }).to be_a(Hash) |
| 49 | + end |
| 50 | + |
| 51 | + it "doesn't find location from Spain" do |
| 52 | + actual.each do |location| |
| 53 | + expect(location).not_to include(:title => "Madird") |
| 54 | + end |
| 55 | + end |
| 56 | + end |
| 57 | + |
| 58 | + context "looking for locations in data files with shallow source" do |
| 59 | + let(:options) { Jekyll::Maps::OptionsParser.parse("src='_data'") } |
| 60 | + let(:finder) { Jekyll::Maps::LocationFinder.new(options) } |
| 61 | + let(:actual) { finder.find(site, page) } |
30 | 62 |
|
31 | | - it "finds location in data files" do |
| 63 | + it "finds locations in all data files" do |
32 | 64 | expect(actual.find { |l| l[:title] == "Paris" }).to be_a(Hash) |
| 65 | + expect(actual.find { |l| l[:title] == "Madrid" }).to be_a(Hash) |
33 | 66 | end |
34 | 67 | end |
35 | 68 |
|
36 | 69 | context "filtering locations" do |
37 | | - let(:options) { Jekyll::Maps::OptionsParser.parse("country:de") } |
| 70 | + let(:options) { Jekyll::Maps::OptionsParser.parse("src='_posts' country='de'") } |
38 | 71 | let(:finder) { Jekyll::Maps::LocationFinder.new(options) } |
39 | 72 | let(:actual) { finder.find(site, page) } |
40 | 73 |
|
|
46 | 79 | end |
47 | 80 | end |
48 | 81 |
|
49 | | - context "looking for on_page locations" do |
| 82 | + context "by default look for locations on current page" do |
50 | 83 | let(:location) { { "location" => { "latitude" => 1, "longitude" => -1 } } } |
51 | 84 | let(:page) { make_page(location) } |
52 | | - let(:options) { Jekyll::Maps::OptionsParser.parse("on_page") } |
| 85 | + let(:options) { Jekyll::Maps::OptionsParser.parse("") } |
53 | 86 | let(:finder) { Jekyll::Maps::LocationFinder.new(options) } |
54 | 87 | let(:actual) { finder.find(site, page) } |
55 | 88 |
|
|
0 commit comments