utopia 2.11.1 → 2.12.0

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 (129) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/Rakefile +2 -0
  4. data/benchmarks/call_vs_check.rb +2 -0
  5. data/benchmarks/const_vs_hash.rb +2 -0
  6. data/benchmarks/hash_vs_openstruct.rb +2 -0
  7. data/benchmarks/string_vs_symbol.rb +2 -0
  8. data/benchmarks/struct_vs_class.rb +2 -0
  9. data/documentation/Gemfile +1 -0
  10. data/documentation/Rakefile +1 -0
  11. data/documentation/config.ru +1 -0
  12. data/documentation/config/environment.rb +1 -0
  13. data/documentation/pages/wiki/controller.rb +1 -0
  14. data/documentation/spec/website_context.rb +1 -0
  15. data/documentation/spec/website_spec.rb +1 -0
  16. data/lib/utopia.rb +2 -0
  17. data/lib/utopia/command.rb +2 -0
  18. data/lib/utopia/command/environment.rb +2 -0
  19. data/lib/utopia/command/server.rb +2 -0
  20. data/lib/utopia/command/site.rb +2 -0
  21. data/lib/utopia/content.rb +10 -1
  22. data/lib/utopia/content/document.rb +2 -0
  23. data/lib/utopia/content/link.rb +2 -0
  24. data/lib/utopia/content/links.rb +160 -124
  25. data/lib/utopia/content/markup.rb +2 -0
  26. data/lib/utopia/content/namespace.rb +2 -0
  27. data/lib/utopia/content/node.rb +6 -3
  28. data/lib/utopia/content/response.rb +2 -0
  29. data/lib/utopia/content/tags.rb +2 -0
  30. data/lib/utopia/content_length.rb +2 -0
  31. data/lib/utopia/controller.rb +2 -0
  32. data/lib/utopia/controller/actions.rb +2 -0
  33. data/lib/utopia/controller/base.rb +2 -0
  34. data/lib/utopia/controller/respond.rb +2 -0
  35. data/lib/utopia/controller/rewrite.rb +2 -0
  36. data/lib/utopia/controller/variables.rb +2 -0
  37. data/lib/utopia/exceptions.rb +2 -0
  38. data/lib/utopia/exceptions/handler.rb +2 -0
  39. data/lib/utopia/exceptions/mailer.rb +2 -0
  40. data/lib/utopia/extensions/array_split.rb +2 -0
  41. data/lib/utopia/extensions/date_comparisons.rb +2 -0
  42. data/lib/utopia/http.rb +2 -0
  43. data/lib/utopia/locale.rb +2 -0
  44. data/lib/utopia/localization.rb +2 -0
  45. data/lib/utopia/logger.rb +2 -0
  46. data/lib/utopia/middleware.rb +2 -0
  47. data/lib/utopia/path.rb +2 -0
  48. data/lib/utopia/path/matcher.rb +2 -0
  49. data/lib/utopia/redirection.rb +2 -0
  50. data/lib/utopia/session.rb +2 -0
  51. data/lib/utopia/session/lazy_hash.rb +2 -0
  52. data/lib/utopia/session/serialization.rb +2 -0
  53. data/lib/utopia/setup.rb +2 -0
  54. data/lib/utopia/static.rb +2 -0
  55. data/lib/utopia/static/local_file.rb +2 -0
  56. data/lib/utopia/static/mime_types.rb +2 -0
  57. data/lib/utopia/version.rb +3 -1
  58. data/setup/site/Gemfile +1 -0
  59. data/setup/site/Rakefile +1 -0
  60. data/setup/site/config.ru +1 -0
  61. data/setup/site/config/environment.rb +1 -0
  62. data/setup/site/falcon.rb +1 -0
  63. data/setup/site/spec/spec_helper.rb +1 -0
  64. data/setup/site/spec/website_context.rb +1 -0
  65. data/setup/site/spec/website_spec.rb +1 -0
  66. data/setup/site/tasks/deploy.rake +1 -0
  67. data/setup/site/tasks/development.rake +1 -0
  68. data/setup/site/tasks/environment.rake +1 -0
  69. data/setup/site/tasks/log.rake +1 -0
  70. data/setup/site/tasks/static.rake +1 -0
  71. data/setup/site/tasks/yarn.rake +1 -0
  72. data/spec/mock_node.rb +1 -0
  73. data/spec/spec_helper.rb +1 -0
  74. data/spec/utopia/command_spec.rb +2 -0
  75. data/spec/utopia/content/document_spec.rb +2 -0
  76. data/spec/utopia/content/link_spec.rb +1 -0
  77. data/spec/utopia/content/links_spec.rb +21 -21
  78. data/spec/utopia/content/markup_spec.rb +1 -0
  79. data/spec/utopia/content/namespace_spec.rb +2 -0
  80. data/spec/utopia/content/node_spec.rb +2 -0
  81. data/spec/utopia/content/response_spec.rb +2 -0
  82. data/spec/utopia/content/tags_spec.rb +2 -0
  83. data/spec/utopia/content_spec.rb +2 -0
  84. data/spec/utopia/content_spec.ru +1 -0
  85. data/spec/utopia/controller/actions_spec.rb +1 -0
  86. data/spec/utopia/controller/middleware_spec.rb +1 -0
  87. data/spec/utopia/controller/middleware_spec.ru +1 -0
  88. data/spec/utopia/controller/middleware_spec/controller/controller.rb +1 -0
  89. data/spec/utopia/controller/middleware_spec/controller/nested/controller.rb +1 -0
  90. data/spec/utopia/controller/middleware_spec/redirect/controller.rb +1 -0
  91. data/spec/utopia/controller/middleware_spec/redirect/test/controller.rb +1 -0
  92. data/spec/utopia/controller/respond_spec.rb +1 -0
  93. data/spec/utopia/controller/respond_spec.ru +1 -0
  94. data/spec/utopia/controller/respond_spec/api/controller.rb +1 -0
  95. data/spec/utopia/controller/respond_spec/errors/controller.rb +1 -0
  96. data/spec/utopia/controller/respond_spec/html/controller.rb +1 -0
  97. data/spec/utopia/controller/respond_spec/rewrite/controller.rb +1 -0
  98. data/spec/utopia/controller/rewrite_spec.rb +1 -0
  99. data/spec/utopia/controller/sequence_spec.rb +2 -1
  100. data/spec/utopia/controller/variables_spec.rb +1 -0
  101. data/spec/utopia/controller/websocket_spec.rb +1 -0
  102. data/spec/utopia/controller/websocket_spec.ru +1 -0
  103. data/spec/utopia/controller/websocket_spec/server/controller.rb +1 -0
  104. data/spec/utopia/exceptions/handler_spec.rb +1 -0
  105. data/spec/utopia/exceptions/handler_spec.ru +1 -0
  106. data/spec/utopia/exceptions/handler_spec/controller.rb +1 -0
  107. data/spec/utopia/exceptions/mailer_spec.rb +1 -0
  108. data/spec/utopia/exceptions/mailer_spec.ru +1 -0
  109. data/spec/utopia/extensions_spec.rb +2 -0
  110. data/spec/utopia/http/status_spec.rb +2 -0
  111. data/spec/utopia/locale_spec.rb +2 -0
  112. data/spec/utopia/localization_spec.rb +2 -0
  113. data/spec/utopia/localization_spec.ru +1 -0
  114. data/spec/utopia/localization_spec/controller.rb +1 -0
  115. data/spec/utopia/middleware_spec.rb +2 -0
  116. data/spec/utopia/path/matcher_spec.rb +1 -0
  117. data/spec/utopia/path_spec.rb +1 -0
  118. data/spec/utopia/performance_spec.rb +2 -0
  119. data/spec/utopia/performance_spec/config.ru +1 -0
  120. data/spec/utopia/performance_spec/pages/api/controller.rb +1 -0
  121. data/spec/utopia/rack_helper.rb +2 -0
  122. data/spec/utopia/redirection_spec.rb +2 -0
  123. data/spec/utopia/redirection_spec.ru +1 -0
  124. data/spec/utopia/session_spec.rb +2 -0
  125. data/spec/utopia/session_spec.ru +1 -0
  126. data/spec/utopia/setup_spec.rb +2 -0
  127. data/spec/utopia/static_spec.rb +2 -0
  128. data/spec/utopia/static_spec.ru +1 -0
  129. metadata +2 -2
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -79,7 +81,8 @@ module Utopia
79
81
 
80
82
  def links(path = '.', **options, &block)
81
83
  path = uri_path.dirname + Path[path]
82
- links = Links.index(@controller.root, path, **options)
84
+
85
+ links = @controller.links(path, **options)
83
86
 
84
87
  if block_given?
85
88
  links.each(&block)
@@ -91,7 +94,7 @@ module Utopia
91
94
  def related_links
92
95
  name = @uri_path.basename
93
96
 
94
- return Links.index(@controller.root, @uri_path.dirname, :name => @uri_path.basename, :indices => true)
97
+ return @controller.links(@uri_path.dirname, :name => @uri_path.basename, :indices => true)
95
98
  end
96
99
 
97
100
  def siblings_path
@@ -103,7 +106,7 @@ module Utopia
103
106
  end
104
107
 
105
108
  def sibling_links(**options)
106
- return Links.index(@controller.root, siblings_path, **options)
109
+ return @controller.links(siblings_path, **options)
107
110
  end
108
111
 
109
112
  # Lookup the given tag which is being rendered within the given node. Invoked by {Document}.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2014, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2014, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2014, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2014, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2014, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -19,5 +21,5 @@
19
21
  # THE SOFTWARE.
20
22
 
21
23
  module Utopia
22
- VERSION = "2.11.1"
24
+ VERSION = "2.12.0"
23
25
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  source 'https://rubygems.org'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'pathname'
3
4
  SITE_ROOT = Pathname.new(__dir__).realpath
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env rackup
2
+ # frozen_string_literal: true
2
3
 
3
4
  require_relative 'config/environment'
4
5
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'bundler/setup'
3
4
  Bundler.setup
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env -S falcon host
2
+ # frozen_string_literal: true
2
3
 
3
4
  load :rack, :lets_encrypt_tls, :supervisor
4
5
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'bundler/setup'
3
4
  require 'covered/rspec'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'rack/test'
3
4
  require 'async/rspec/reactor'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require_relative 'website_context'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  desc 'Run by git post-update hook when deployed to a web server'
3
4
  task :deploy do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require "rspec/core/rake_task"
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  desc 'Set up the environment for running your web application'
3
4
  task :environment => :log do |task|
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  task :log do
3
4
  require 'utopia/logger'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  namespace :static do
3
4
  task :static_environment do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  namespace :yarn do
3
4
  desc 'Load the .bowerrc file and setup the environment for other tasks.'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class MockNode
3
4
  def initialize(namespaces = {}, &block)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'covered/rspec'
3
4
  require 'async/rspec'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env rspec
2
+ # frozen_string_literal: true
2
3
 
3
4
  # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
5
  #
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env rspec
2
+ # frozen_string_literal: true
2
3
 
3
4
  # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
5
  #
@@ -23,6 +24,9 @@
23
24
  require 'utopia/content/links'
24
25
 
25
26
  RSpec.describe Utopia::Content::Links do
27
+ let(:root) {File.expand_path("links", __dir__)}
28
+ subject {described_class.new(root)}
29
+
26
30
  describe 'INDEX_XNODE_FILTER' do
27
31
  subject{Utopia::Content::Links::INDEX_XNODE_FILTER}
28
32
 
@@ -36,13 +40,13 @@ RSpec.describe Utopia::Content::Links do
36
40
  end
37
41
 
38
42
  it "should not match partial strings" do
39
- links = Utopia::Content::Links.index(File.expand_path("links", __dir__), Utopia::Path.create("/"), name: "come")
43
+ links = subject.index(Utopia::Path.create("/"), name: "come")
40
44
 
41
45
  expect(links).to be_empty
42
46
  end
43
47
 
44
48
  it "should give a list of links" do
45
- links = Utopia::Content::Links.index(File.expand_path("links", __dir__), Utopia::Path.create("/"))
49
+ links = subject.index(Utopia::Path.create("/"))
46
50
 
47
51
  expect(links.size).to be == 3
48
52
 
@@ -65,37 +69,33 @@ RSpec.describe Utopia::Content::Links do
65
69
  end
66
70
 
67
71
  it "should filter links by name" do
68
- links = Utopia::Content::Links.index(File.expand_path("links", __dir__), Utopia::Path.create("/"), name: /foo/)
72
+ links = subject.index(Utopia::Path.create("/"), name: /foo/)
69
73
 
70
74
  expect(links.size).to be == 1
71
75
  end
72
76
 
73
77
  it "should select localized links" do
74
- root = File.expand_path("links", __dir__)
75
-
76
78
  # Select both test links
77
- links = Utopia::Content::Links.index(root, Utopia::Path.create("/foo"))
79
+ links = subject.index(Utopia::Path.create("/foo"))
78
80
  expect(links.size).to be == 2
79
81
 
80
- links = Utopia::Content::Links.index(root, Utopia::Path.create("/foo"), locale: 'en')
82
+ links = subject.index(Utopia::Path.create("/foo"), locale: 'en')
81
83
  expect(links.size).to be == 1
82
84
  end
83
85
 
84
- it "should read correct link order for en" do
85
- root = File.expand_path("localized", __dir__)
86
-
87
- # Select both test links
88
- links = Utopia::Content::Links.index(root, Utopia::Path.create("/"), locale: 'en')
89
-
90
- expect(links.collect(&:title)).to be == ['One', 'Two', 'Three', 'Four', 'Five']
91
- end
92
-
93
- it "should read correct link order for zh" do
94
- root = File.expand_path("localized", __dir__)
86
+ context 'localized links' do
87
+ let(:root) {File.expand_path("localized", __dir__)}
95
88
 
96
- # Select both test links
97
- links = Utopia::Content::Links.index(root, Utopia::Path.create("/"), locale: 'zh')
89
+ it "should read correct link order for en" do
90
+ links = subject.index(Utopia::Path.create("/"), locale: 'en')
91
+
92
+ expect(links.collect(&:title)).to be == ['One', 'Two', 'Three', 'Four', 'Five']
93
+ end
98
94
 
99
- expect(links.collect(&:title)).to be == ['One', 'Two', 'Three', '四']
95
+ it "should read correct link order for zh" do
96
+ links = subject.index(Utopia::Path.create("/"), locale: 'zh')
97
+
98
+ expect(links.collect(&:title)).to be == ['One', 'Two', 'Three', '四']
99
+ end
100
100
  end
101
101
  end