sitemap_generator_ftbpro 5.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +13 -0
  3. data/Gemfile.lock +35 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +1139 -0
  6. data/Rakefile +43 -0
  7. data/VERSION +1 -0
  8. data/lib/capistrano/sitemap_generator.rb +1 -0
  9. data/lib/capistrano/tasks/sitemap_generator.cap +36 -0
  10. data/lib/sitemap_generator/adapters/file_adapter.rb +43 -0
  11. data/lib/sitemap_generator/adapters/fog_adapter.rb +28 -0
  12. data/lib/sitemap_generator/adapters/s3_adapter.rb +41 -0
  13. data/lib/sitemap_generator/adapters/wave_adapter.rb +21 -0
  14. data/lib/sitemap_generator/adapters.rb +0 -0
  15. data/lib/sitemap_generator/application.rb +49 -0
  16. data/lib/sitemap_generator/builder/sitemap_file.rb +171 -0
  17. data/lib/sitemap_generator/builder/sitemap_index_file.rb +149 -0
  18. data/lib/sitemap_generator/builder/sitemap_index_url.rb +28 -0
  19. data/lib/sitemap_generator/builder/sitemap_url.rb +250 -0
  20. data/lib/sitemap_generator/builder.rb +8 -0
  21. data/lib/sitemap_generator/core_ext/big_decimal.rb +45 -0
  22. data/lib/sitemap_generator/core_ext/numeric.rb +48 -0
  23. data/lib/sitemap_generator/core_ext.rb +3 -0
  24. data/lib/sitemap_generator/helpers/number_helper.rb +237 -0
  25. data/lib/sitemap_generator/interpreter.rb +80 -0
  26. data/lib/sitemap_generator/link_set.rb +665 -0
  27. data/lib/sitemap_generator/railtie.rb +7 -0
  28. data/lib/sitemap_generator/sitemap_location.rb +192 -0
  29. data/lib/sitemap_generator/sitemap_namer.rb +75 -0
  30. data/lib/sitemap_generator/tasks.rb +53 -0
  31. data/lib/sitemap_generator/templates.rb +41 -0
  32. data/lib/sitemap_generator/utilities.rb +181 -0
  33. data/lib/sitemap_generator.rb +82 -0
  34. data/lib/tasks/sitemap_generator_tasks.rake +1 -0
  35. data/rails/install.rb +2 -0
  36. data/rails/uninstall.rb +2 -0
  37. data/spec/blueprint.rb +15 -0
  38. data/spec/files/sitemap.create.rb +12 -0
  39. data/spec/files/sitemap.groups.rb +49 -0
  40. data/spec/sitemap_generator/adapters/s3_adapter_spec.rb +23 -0
  41. data/spec/sitemap_generator/alternate_sitemap_spec.rb +79 -0
  42. data/spec/sitemap_generator/application_spec.rb +69 -0
  43. data/spec/sitemap_generator/builder/sitemap_file_spec.rb +110 -0
  44. data/spec/sitemap_generator/builder/sitemap_index_file_spec.rb +124 -0
  45. data/spec/sitemap_generator/builder/sitemap_index_url_spec.rb +28 -0
  46. data/spec/sitemap_generator/builder/sitemap_url_spec.rb +186 -0
  47. data/spec/sitemap_generator/core_ext/bigdecimal_spec.rb +20 -0
  48. data/spec/sitemap_generator/core_ext/numeric_spec.rb +43 -0
  49. data/spec/sitemap_generator/file_adaptor_spec.rb +20 -0
  50. data/spec/sitemap_generator/geo_sitemap_spec.rb +30 -0
  51. data/spec/sitemap_generator/helpers/number_helper_spec.rb +196 -0
  52. data/spec/sitemap_generator/interpreter_spec.rb +90 -0
  53. data/spec/sitemap_generator/link_set_spec.rb +864 -0
  54. data/spec/sitemap_generator/mobile_sitemap_spec.rb +27 -0
  55. data/spec/sitemap_generator/news_sitemap_spec.rb +42 -0
  56. data/spec/sitemap_generator/pagemap_sitemap_spec.rb +57 -0
  57. data/spec/sitemap_generator/sitemap_generator_spec.rb +582 -0
  58. data/spec/sitemap_generator/sitemap_groups_spec.rb +144 -0
  59. data/spec/sitemap_generator/sitemap_location_spec.rb +210 -0
  60. data/spec/sitemap_generator/sitemap_namer_spec.rb +96 -0
  61. data/spec/sitemap_generator/templates_spec.rb +24 -0
  62. data/spec/sitemap_generator/utilities/existence_spec.rb +26 -0
  63. data/spec/sitemap_generator/utilities/hash_spec.rb +57 -0
  64. data/spec/sitemap_generator/utilities/rounding_spec.rb +31 -0
  65. data/spec/sitemap_generator/utilities_spec.rb +101 -0
  66. data/spec/sitemap_generator/video_sitemap_spec.rb +117 -0
  67. data/spec/spec_helper.rb +24 -0
  68. data/spec/support/file_macros.rb +39 -0
  69. data/spec/support/schemas/siteindex.xsd +73 -0
  70. data/spec/support/schemas/sitemap-geo.xsd +41 -0
  71. data/spec/support/schemas/sitemap-mobile.xsd +32 -0
  72. data/spec/support/schemas/sitemap-news.xsd +159 -0
  73. data/spec/support/schemas/sitemap-pagemap.xsd +97 -0
  74. data/spec/support/schemas/sitemap-video.xsd +643 -0
  75. data/spec/support/schemas/sitemap.xsd +115 -0
  76. data/spec/support/xml_macros.rb +67 -0
  77. data/templates/sitemap.rb +27 -0
  78. metadata +226 -0
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+ require 'bigdecimal'
3
+
4
+ describe SitemapGenerator::BigDecimal do
5
+ describe "to_yaml" do
6
+ it "should serialize correctly" do
7
+ SitemapGenerator::BigDecimal.new('100000.30020320320000000000000000000000000000001').to_yaml.should =~ /^--- 100000\.30020320320000000000000000000000000000001\n/
8
+ SitemapGenerator::BigDecimal.new('Infinity').to_yaml.should =~ /^--- \.Inf\n/
9
+ SitemapGenerator::BigDecimal.new('NaN').to_yaml.should =~ /^--- \.NaN\n/
10
+ SitemapGenerator::BigDecimal.new('-Infinity').to_yaml.should =~ /^--- -\.Inf\n/
11
+ end
12
+ end
13
+
14
+ describe "to_d" do
15
+ it "should convert correctly" do
16
+ bd = SitemapGenerator::BigDecimal.new '10'
17
+ bd.to_d.should == bd
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe SitemapGenerator::Numeric do
4
+ def numeric(size)
5
+ SitemapGenerator::Numeric.new(size)
6
+ end
7
+
8
+ describe "bytes" do
9
+ it "should define equality of different units" do
10
+ relationships = {
11
+ numeric( 1024).bytes => numeric( 1).kilobyte,
12
+ numeric( 1024).kilobytes => numeric( 1).megabyte,
13
+ numeric(3584.0).kilobytes => numeric(3.5).megabytes,
14
+ numeric(3584.0).megabytes => numeric(3.5).gigabytes,
15
+ numeric(1).kilobyte ** 4 => numeric( 1).terabyte,
16
+ numeric(1024).kilobytes + numeric(2).megabytes => numeric(3).megabytes,
17
+ numeric( 2).gigabytes / 4 => numeric(512).megabytes,
18
+ numeric(256).megabytes * 20 +numeric( 5).gigabytes => numeric(10).gigabytes,
19
+ numeric(1).kilobyte ** 5 => numeric(1).petabyte,
20
+ numeric(1).kilobyte ** 6 => numeric(1).exabyte
21
+ }
22
+
23
+ relationships.each do |left, right|
24
+ left.should == right
25
+ end
26
+ end
27
+
28
+ it "should represent units as bytes" do
29
+ numeric(3).megabytes.should == 3145728
30
+ numeric(3).megabyte .should == 3145728
31
+ numeric(3).kilobytes.should == 3072
32
+ numeric(3).kilobyte .should == 3072
33
+ numeric(3).gigabytes.should == 3221225472
34
+ numeric(3).gigabyte .should == 3221225472
35
+ numeric(3).terabytes.should == 3298534883328
36
+ numeric(3).terabyte .should == 3298534883328
37
+ numeric(3).petabytes.should == 3377699720527872
38
+ numeric(3).petabyte .should == 3377699720527872
39
+ numeric(3).exabytes .should == 3458764513820540928
40
+ numeric(3).exabyte .should == 3458764513820540928
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe "SitemapGenerator::FileAdapter" do
4
+ let(:location) { SitemapGenerator::SitemapLocation.new }
5
+ let(:adapter) { SitemapGenerator::FileAdapter.new }
6
+
7
+ describe "write" do
8
+ it "should gzip contents if filename ends in .gz" do
9
+ adapter.expects(:gzip).once
10
+ location.stubs(:filename).returns('sitemap.xml.gz')
11
+ adapter.write(location, 'data')
12
+ end
13
+
14
+ it "should not gzip contents if filename does not end in .gz" do
15
+ adapter.expects(:plain).once
16
+ location.stubs(:filename).returns('sitemap.xml')
17
+ adapter.write(location, 'data')
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe "SitemapGenerator" do
4
+
5
+ it "should add the geo sitemap element" do
6
+ loc = 'http://www.example.com/geo_page.kml'
7
+ format = 'kml'
8
+
9
+ geo_xml_fragment = SitemapGenerator::Builder::SitemapUrl.new('geo_page.kml',
10
+ :host => 'http://www.example.com',
11
+ :geo => {
12
+ :format => format
13
+ }
14
+ ).to_xml
15
+
16
+ # Check that the options were parsed correctly
17
+ doc = Nokogiri::XML.parse("<root xmlns:geo='#{SitemapGenerator::SCHEMAS['geo']}'>#{geo_xml_fragment}</root>")
18
+ url = doc.at_xpath("//url")
19
+ url.should_not be_nil
20
+ url.at_xpath("loc").text.should == loc
21
+
22
+ geo = url.at_xpath("geo:geo")
23
+ geo.should_not be_nil
24
+ geo.at_xpath("geo:format").text.should == format
25
+
26
+ # Google's documentation and published schema don't match some valid elements may
27
+ # not validate.
28
+ xml_fragment_should_validate_against_schema(geo, 'sitemap-geo', 'xmlns:geo' => SitemapGenerator::SCHEMAS['geo'])
29
+ end
30
+ end
@@ -0,0 +1,196 @@
1
+ require 'spec_helper'
2
+ require 'sitemap_generator/helpers/number_helper'
3
+
4
+ def kilobytes(number)
5
+ number * 1024
6
+ end
7
+
8
+ def megabytes(number)
9
+ kilobytes(number) * 1024
10
+ end
11
+
12
+ def gigabytes(number)
13
+ megabytes(number) * 1024
14
+ end
15
+
16
+ def terabytes(number)
17
+ gigabytes(number) * 1024
18
+ end
19
+
20
+ describe SitemapGenerator::Helpers::NumberHelper do
21
+ include SitemapGenerator::Helpers::NumberHelper
22
+
23
+ it "should number_with_delimiter" do
24
+ number_with_delimiter(12345678).should == "12,345,678"
25
+ number_with_delimiter(0).should == "0"
26
+ number_with_delimiter(123).should == "123"
27
+ number_with_delimiter(123456).should == "123,456"
28
+ number_with_delimiter(123456.78).should == "123,456.78"
29
+ number_with_delimiter(123456.789).should == "123,456.789"
30
+ number_with_delimiter(123456.78901).should == "123,456.78901"
31
+ number_with_delimiter(123456789.78901).should == "123,456,789.78901"
32
+ number_with_delimiter(0.78901).should == "0.78901"
33
+ number_with_delimiter("123456.78").should == "123,456.78"
34
+ end
35
+
36
+ it "should number_with_delimiter_with_options_hash" do
37
+ number_with_delimiter(12345678, :delimiter => ' ').should == '12 345 678'
38
+ number_with_delimiter(12345678.05, :separator => '-').should == '12,345,678-05'
39
+ number_with_delimiter(12345678.05, :separator => ',', :delimiter => '.').should == '12.345.678,05'
40
+ number_with_delimiter(12345678.05, :delimiter => '.', :separator => ',').should == '12.345.678,05'
41
+ end
42
+
43
+ it "should number_with_precision" do
44
+ number_with_precision(-111.2346).should == "-111.235"
45
+ number_with_precision(111.2346).should == "111.235"
46
+ number_with_precision(31.825, :precision => 2).should == "31.83"
47
+ number_with_precision(111.2346, :precision => 2).should == "111.23"
48
+ number_with_precision(111, :precision => 2).should == "111.00"
49
+ number_with_precision("111.2346").should == "111.235"
50
+ number_with_precision("31.825", :precision => 2).should == "31.83"
51
+ number_with_precision((32.6751 * 100.00), :precision => 0).should == "3268"
52
+ number_with_precision(111.50, :precision => 0).should == "112"
53
+ number_with_precision(1234567891.50, :precision => 0).should == "1234567892"
54
+ number_with_precision(0, :precision => 0).should == "0"
55
+ number_with_precision(0.001, :precision => 5).should == "0.00100"
56
+ number_with_precision(0.00111, :precision => 3).should == "0.001"
57
+ # Odd difference between Ruby versions
58
+ if RUBY_VERSION < '1.9.3'
59
+ number_with_precision(9.995, :precision => 2).should == "9.99"
60
+ else
61
+ number_with_precision(9.995, :precision => 2).should == "10.00"
62
+ end
63
+ number_with_precision(10.995, :precision => 2).should == "11.00"
64
+ end
65
+
66
+ it "should number_with_precision_with_custom_delimiter_and_separator" do
67
+ number_with_precision(31.825, :precision => 2, :separator => ',').should == '31,83'
68
+ number_with_precision(1231.825, :precision => 2, :separator => ',', :delimiter => '.').should == '1.231,83'
69
+ end
70
+
71
+ it "should number_with_precision_with_significant_digits" do
72
+ number_with_precision(123987, :precision => 3, :significant => true).should == "124000"
73
+ number_with_precision(123987876, :precision => 2, :significant => true ).should == "120000000"
74
+ number_with_precision("43523", :precision => 1, :significant => true ).should == "40000"
75
+ number_with_precision(9775, :precision => 4, :significant => true ).should == "9775"
76
+ number_with_precision(5.3923, :precision => 2, :significant => true ).should == "5.4"
77
+ number_with_precision(5.3923, :precision => 1, :significant => true ).should == "5"
78
+ number_with_precision(1.232, :precision => 1, :significant => true ).should == "1"
79
+ number_with_precision(7, :precision => 1, :significant => true ).should == "7"
80
+ number_with_precision(1, :precision => 1, :significant => true ).should == "1"
81
+ number_with_precision(52.7923, :precision => 2, :significant => true ).should == "53"
82
+ number_with_precision(9775, :precision => 6, :significant => true ).should == "9775.00"
83
+ number_with_precision(5.3929, :precision => 7, :significant => true ).should == "5.392900"
84
+ number_with_precision(0, :precision => 2, :significant => true ).should == "0.0"
85
+ number_with_precision(0, :precision => 1, :significant => true ).should == "0"
86
+ number_with_precision(0.0001, :precision => 1, :significant => true ).should == "0.0001"
87
+ number_with_precision(0.0001, :precision => 3, :significant => true ).should == "0.000100"
88
+ number_with_precision(0.0001111, :precision => 1, :significant => true ).should == "0.0001"
89
+ number_with_precision(9.995, :precision => 3, :significant => true).should == "10.0"
90
+ number_with_precision(9.994, :precision => 3, :significant => true).should == "9.99"
91
+ number_with_precision(10.995, :precision => 3, :significant => true).should == "11.0"
92
+ end
93
+
94
+ it "should number_with_precision_with_strip_insignificant_zeros" do
95
+ number_with_precision(9775.43, :precision => 4, :strip_insignificant_zeros => true ).should == "9775.43"
96
+ number_with_precision(9775.2, :precision => 6, :significant => true, :strip_insignificant_zeros => true ).should == "9775.2"
97
+ number_with_precision(0, :precision => 6, :significant => true, :strip_insignificant_zeros => true ).should == "0"
98
+ end
99
+
100
+ it "should number_with_precision_with_significant_true_and_zero_precision" do
101
+ # Zero precision with significant is a mistake (would always return zero),
102
+ # so we treat it as if significant was false (increases backwards compatibily for number_to_human_size)
103
+ number_with_precision(123.987, :precision => 0, :significant => true).should == "124"
104
+ number_with_precision(12, :precision => 0, :significant => true ).should == "12"
105
+ number_with_precision("12.3", :precision => 0, :significant => true ).should == "12"
106
+ end
107
+
108
+ it "should number_to_human_size" do
109
+ number_to_human_size(0).should == '0 Bytes'
110
+ number_to_human_size(1).should == '1 Byte'
111
+ number_to_human_size(3.14159265).should == '3 Bytes'
112
+ number_to_human_size(123.0).should == '123 Bytes'
113
+ number_to_human_size(123).should == '123 Bytes'
114
+ number_to_human_size(1234).should == '1.21 KB'
115
+ number_to_human_size(12345).should == '12.1 KB'
116
+ number_to_human_size(1234567).should == '1.18 MB'
117
+ number_to_human_size(1234567890).should == '1.15 GB'
118
+ number_to_human_size(1234567890123).should == '1.12 TB'
119
+ number_to_human_size(terabytes(1026)).should == '1030 TB'
120
+ number_to_human_size(kilobytes(444)).should == '444 KB'
121
+ number_to_human_size(megabytes(1023)).should == '1020 MB'
122
+ number_to_human_size(terabytes(3)).should == '3 TB'
123
+ number_to_human_size(1234567, :precision => 2).should == '1.2 MB'
124
+ number_to_human_size(3.14159265, :precision => 4).should == '3 Bytes'
125
+ number_to_human_size('123').should == '123 Bytes'
126
+ number_to_human_size(kilobytes(1.0123), :precision => 2).should == '1 KB'
127
+ number_to_human_size(kilobytes(1.0100), :precision => 4).should == '1.01 KB'
128
+ number_to_human_size(kilobytes(10.000), :precision => 4).should == '10 KB'
129
+ number_to_human_size(1.1).should == '1 Byte'
130
+ number_to_human_size(10).should == '10 Bytes'
131
+ end
132
+
133
+ it "should number_to_human_size_with_options_hash" do
134
+ number_to_human_size(1234567, :precision => 2).should == '1.2 MB'
135
+ number_to_human_size(3.14159265, :precision => 4).should == '3 Bytes'
136
+ number_to_human_size(kilobytes(1.0123), :precision => 2).should == '1 KB'
137
+ number_to_human_size(kilobytes(1.0100), :precision => 4).should == '1.01 KB'
138
+ number_to_human_size(kilobytes(10.000), :precision => 4).should == '10 KB'
139
+ number_to_human_size(1234567890123, :precision => 1).should == '1 TB'
140
+ number_to_human_size(524288000, :precision=>3).should == '500 MB'
141
+ number_to_human_size(9961472, :precision=>0).should == '10 MB'
142
+ number_to_human_size(41010, :precision => 1).should == '40 KB'
143
+ number_to_human_size(41100, :precision => 2).should == '40 KB'
144
+ number_to_human_size(kilobytes(1.0123), :precision => 2, :strip_insignificant_zeros => false).should == '1.0 KB'
145
+ number_to_human_size(kilobytes(1.0123), :precision => 3, :significant => false).should == '1.012 KB'
146
+ number_to_human_size(kilobytes(1.0123), :precision => 0, :significant => true) #ignores significant it precision is 0.should == '1 KB'
147
+ end
148
+
149
+ it "should number_to_human_size_with_custom_delimiter_and_separator" do
150
+ number_to_human_size(kilobytes(1.0123), :precision => 3, :separator => ',') .should == '1,01 KB'
151
+ number_to_human_size(kilobytes(1.0100), :precision => 4, :separator => ',') .should == '1,01 KB'
152
+ number_to_human_size(terabytes(1000.1), :precision => 5, :delimiter => '.', :separator => ',') .should == '1.000,1 TB'
153
+ end
154
+
155
+ it "should number_helpers_should_return_nil_when_given_nil" do
156
+ number_with_delimiter(nil).should be_nil
157
+ number_with_precision(nil).should be_nil
158
+ number_to_human_size(nil).should be_nil
159
+ end
160
+
161
+ it "should number_helpers_should_return_non_numeric_param_unchanged" do
162
+ number_with_delimiter("x").should == "x"
163
+ number_with_precision("x.").should == "x."
164
+ number_with_precision("x").should == "x"
165
+ number_to_human_size('x').should == "x"
166
+ end
167
+
168
+ it "should number_helpers_should_raise_error_if_invalid_when_specified" do
169
+ lambda do
170
+ number_to_human_size("x", :raise => true)
171
+ end.should raise_error(SitemapGenerator::Helpers::NumberHelper::InvalidNumberError)
172
+ begin
173
+ number_to_human_size("x", :raise => true)
174
+ rescue SitemapGenerator::Helpers::NumberHelper::InvalidNumberError => e
175
+ e.number.should == "x"
176
+ end
177
+
178
+ lambda do
179
+ number_with_precision("x", :raise => true)
180
+ end.should raise_error(SitemapGenerator::Helpers::NumberHelper::InvalidNumberError)
181
+ begin
182
+ number_with_precision("x", :raise => true)
183
+ rescue SitemapGenerator::Helpers::NumberHelper::InvalidNumberError => e
184
+ e.number.should == "x"
185
+ end
186
+
187
+ lambda do
188
+ number_with_delimiter("x", :raise => true)
189
+ end.should raise_error(SitemapGenerator::Helpers::NumberHelper::InvalidNumberError)
190
+ begin
191
+ number_with_delimiter("x", :raise => true)
192
+ rescue SitemapGenerator::Helpers::NumberHelper::InvalidNumberError => e
193
+ e.number.should == "x"
194
+ end
195
+ end
196
+ end
@@ -0,0 +1,90 @@
1
+ require 'spec_helper'
2
+ require 'sitemap_generator/interpreter'
3
+
4
+ describe SitemapGenerator::Interpreter do
5
+ let(:link_set) { SitemapGenerator::LinkSet.new }
6
+ let(:interpreter) { SitemapGenerator::Interpreter.new(:link_set => link_set) }
7
+
8
+ # The interpreter doesn't have the URL helpers included for some reason, so it
9
+ # fails when adding links. That messes up later specs unless we reset the sitemap object.
10
+ after :all do
11
+ SitemapGenerator::Sitemap.reset!
12
+ end
13
+
14
+ it "should find the config file if Rails.root doesn't end in a slash" do
15
+ SitemapGenerator::Utilities.with_warnings(nil) do
16
+ Rails = stub(:root => SitemapGenerator.app.root.to_s.sub(/\/$/, ''))
17
+ end
18
+ # Rails.expects(:root).returns(rails_root).at_least_once
19
+ lambda { SitemapGenerator::Interpreter.run }.should_not raise_exception(Errno::ENOENT)
20
+ end
21
+
22
+ it "should set the verbose option" do
23
+ SitemapGenerator::Interpreter.any_instance.expects(:instance_eval)
24
+ interpreter = SitemapGenerator::Interpreter.run(:verbose => true)
25
+ interpreter.instance_variable_get(:@linkset).verbose.should be_true
26
+ end
27
+
28
+ describe "link_set" do
29
+ it "should default to the default LinkSet" do
30
+ SitemapGenerator::Interpreter.new.sitemap.should be(SitemapGenerator::Sitemap)
31
+ end
32
+
33
+ it "should allow setting the LinkSet as an option" do
34
+ interpreter.sitemap.should be(link_set)
35
+ end
36
+ end
37
+
38
+ describe "public interface" do
39
+ describe "add" do
40
+ it "should add a link to the sitemap" do
41
+ link_set.expects(:add).with('test', :option => 'value')
42
+ interpreter.add('test', :option => 'value')
43
+ end
44
+ end
45
+
46
+ describe "group" do
47
+ it "should start a new group" do
48
+ link_set.expects(:group).with('test', :option => 'value')
49
+ interpreter.group('test', :option => 'value')
50
+ end
51
+ end
52
+
53
+ describe "sitemap" do
54
+ it "should return the LinkSet" do
55
+ interpreter.sitemap.should be(link_set)
56
+ end
57
+ end
58
+
59
+ describe "add_to_index" do
60
+ it "should add a link to the sitemap index" do
61
+ link_set.expects(:add_to_index).with('test', :option => 'value')
62
+ interpreter.add_to_index('test', :option => 'value')
63
+ end
64
+ end
65
+ end
66
+
67
+ describe "eval" do
68
+ it "should yield the LinkSet to the block" do
69
+ interpreter.eval(:yield_sitemap => true) do |sitemap|
70
+ sitemap.should be(link_set)
71
+ end
72
+ end
73
+
74
+ it "should not yield the LinkSet to the block" do
75
+ local = interpreter # prevent undefined method
76
+ local_be = self.method(:be) # prevent undefined method
77
+ local.eval(:yield_sitemap => false) do
78
+ self.should local_be.call(local)
79
+ end
80
+ end
81
+
82
+ it "should not yield the LinkSet to the block by default" do
83
+ local = interpreter # prevent undefined method
84
+ local_be = self.method(:be) # prevent undefined method
85
+ local.eval do
86
+ self.should local_be.call(local)
87
+ end
88
+ end
89
+ end
90
+ end