middleman-core 3.0.14 → 3.1.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/features/clean_build.feature +4 -5
- data/features/content_type.feature +43 -0
- data/features/data.feature +9 -4
- data/features/front-matter-neighbor.feature +151 -0
- data/features/queryable.feature +31 -0
- data/features/step_definitions/queryable_steps.rb +123 -0
- data/fixtures/content-type-app/config.rb +1 -0
- data/fixtures/content-type-app/source/.htaccess +1 -0
- data/fixtures/content-type-app/source/README +1 -0
- data/fixtures/content-type-app/source/images/blank.gif +0 -0
- data/fixtures/content-type-app/source/index.html +1 -0
- data/fixtures/content-type-app/source/javascripts/app.js +1 -0
- data/fixtures/content-type-app/source/override.html +5 -0
- data/fixtures/content-type-app/source/stylesheets/site.css +1 -0
- data/fixtures/frontmatter-neighbor-app/config.rb +0 -0
- data/fixtures/frontmatter-neighbor-app/source/front-matter-2.php.erb +2 -0
- data/fixtures/frontmatter-neighbor-app/source/front-matter-2.php.erb.frontmatter +4 -0
- data/fixtures/frontmatter-neighbor-app/source/front-matter-auto.erb +1 -0
- data/fixtures/frontmatter-neighbor-app/source/front-matter-auto.erb.frontmatter +4 -0
- data/fixtures/frontmatter-neighbor-app/source/front-matter-change.html.erb +1 -0
- data/fixtures/frontmatter-neighbor-app/source/front-matter-change.html.erb.frontmatter +4 -0
- data/fixtures/frontmatter-neighbor-app/source/front-matter-encoding.html.erb +1 -0
- data/fixtures/frontmatter-neighbor-app/source/front-matter-encoding.html.erb.frontmatter +5 -0
- data/fixtures/frontmatter-neighbor-app/source/json-front-matter-2.php.erb +2 -0
- data/fixtures/frontmatter-neighbor-app/source/json-front-matter-2.php.erb.frontmatter +4 -0
- data/fixtures/frontmatter-neighbor-app/source/json-front-matter-auto.erb +1 -0
- data/fixtures/frontmatter-neighbor-app/source/json-front-matter-auto.erb.frontmatter +4 -0
- data/fixtures/frontmatter-neighbor-app/source/json-front-matter.html.erb +1 -0
- data/fixtures/frontmatter-neighbor-app/source/json-front-matter.html.erb.frontmatter +4 -0
- data/fixtures/frontmatter-neighbor-app/source/raw-front-matter.html +1 -0
- data/fixtures/frontmatter-neighbor-app/source/raw-front-matter.html.frontmatter +4 -0
- data/fixtures/frontmatter-neighbor-app/source/raw-front-matter.php +1 -0
- data/fixtures/frontmatter-neighbor-app/source/raw-front-matter.php.frontmatter +4 -0
- data/fixtures/frontmatter-settings-neighbor-app/config.rb +4 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/alternate_layout.html.erb +1 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/alternate_layout.html.erb.frontmatter +3 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/ignored.html.erb +1 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/ignored.html.erb.frontmatter +3 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/layouts/alternate.erb +3 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/layouts/override.erb +2 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/override_layout.html.erb +1 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/override_layout.html.erb.frontmatter +3 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/page_mentioned.html.erb +1 -0
- data/fixtures/frontmatter-settings-neighbor-app/source/page_mentioned.html.erb.frontmatter +3 -0
- data/fixtures/nested-data-app/config.rb +1 -0
- data/fixtures/nested-data-app/data/examples/test.yml +1 -0
- data/fixtures/nested-data-app/source/test.html.erb +1 -0
- data/fixtures/queryable-app/config.rb +0 -0
- data/fixtures/queryable-app/source/2010-08-08-test-document-file.html.markdown +8 -0
- data/fixtures/queryable-app/source/2010-08-09-another-test-document.html.markdown +10 -0
- data/fixtures/queryable-app/source/2011-12-26-some-test-document.html.markdown +6 -0
- data/fixtures/queryable-app/source/document_with_date_in_yaml.html.markdown +7 -0
- data/fixtures/queryable-app/source/document_without_date.html.markdown +7 -0
- data/lib/middleman-core/application.rb +52 -84
- data/lib/middleman-core/cli.rb +3 -2
- data/lib/middleman-core/cli/build.rb +5 -7
- data/lib/middleman-core/cli/bundler.rb +1 -1
- data/lib/middleman-core/cli/console.rb +46 -0
- data/lib/middleman-core/configuration.rb +235 -0
- data/lib/middleman-core/core_extensions.rb +0 -6
- data/lib/middleman-core/core_extensions/data.rb +34 -11
- data/lib/middleman-core/core_extensions/extensions.rb +31 -35
- data/lib/middleman-core/core_extensions/external_helpers.rb +7 -7
- data/lib/middleman-core/core_extensions/file_watcher.rb +1 -1
- data/lib/middleman-core/core_extensions/front_matter.rb +44 -38
- data/lib/middleman-core/core_extensions/rendering.rb +27 -21
- data/lib/middleman-core/core_extensions/request.rb +41 -73
- data/lib/middleman-core/core_extensions/routing.rb +7 -24
- data/lib/middleman-core/core_extensions/show_exceptions.rb +6 -8
- data/lib/middleman-core/extensions.rb +35 -0
- data/lib/middleman-core/logger.rb +9 -0
- data/lib/middleman-core/meta_pages.rb +93 -0
- data/lib/middleman-core/meta_pages/assets/config.css +36 -0
- data/lib/middleman-core/meta_pages/assets/glyphicons-halflings.png +0 -0
- data/lib/middleman-core/meta_pages/assets/jquery-1.8.2.min.js +2 -0
- data/lib/middleman-core/meta_pages/assets/jquery.details-1.6.min.js +6 -0
- data/lib/middleman-core/meta_pages/assets/meta.css +368 -0
- data/lib/middleman-core/meta_pages/assets/sitemap.css +635 -0
- data/lib/middleman-core/meta_pages/assets/sitemap.js +0 -0
- data/lib/middleman-core/meta_pages/config_setting.rb +39 -0
- data/lib/middleman-core/meta_pages/sitemap_resource.rb +52 -0
- data/lib/middleman-core/meta_pages/sitemap_tree.rb +73 -0
- data/lib/middleman-core/meta_pages/templates/config.html.erb +59 -0
- data/lib/middleman-core/meta_pages/templates/index.html.erb +21 -0
- data/lib/middleman-core/meta_pages/templates/sitemap.html.erb +31 -0
- data/lib/middleman-core/preview_server.rb +18 -7
- data/lib/middleman-core/profiling.rb +1 -1
- data/lib/middleman-core/renderers/erb.rb +5 -5
- data/lib/middleman-core/renderers/less.rb +3 -3
- data/lib/middleman-core/renderers/markdown.rb +10 -9
- data/lib/middleman-core/renderers/redcarpet.rb +16 -21
- data/lib/middleman-core/renderers/sass.rb +4 -5
- data/lib/middleman-core/renderers/slim.rb +4 -1
- data/lib/middleman-core/sitemap.rb +3 -3
- data/lib/middleman-core/sitemap/extensions/content_type.rb +16 -0
- data/lib/middleman-core/sitemap/extensions/on_disk.rb +2 -2
- data/lib/middleman-core/sitemap/extensions/proxies.rb +26 -16
- data/lib/middleman-core/sitemap/queryable.rb +148 -0
- data/lib/middleman-core/sitemap/resource.rb +14 -2
- data/lib/middleman-core/sitemap/store.rb +8 -7
- data/lib/middleman-core/step_definitions/builder_steps.rb +3 -0
- data/lib/middleman-core/step_definitions/server_steps.rb +6 -1
- data/lib/middleman-core/templates/default/source/layouts/layout.erb +1 -1
- data/lib/middleman-core/templates/extension/lib/lib.rb +17 -26
- data/lib/middleman-core/templates/html5/source/layouts/layout.erb +1 -1
- data/lib/middleman-core/templates/shared/Gemfile.tt +6 -1
- data/lib/middleman-core/util.rb +7 -5
- data/lib/middleman-core/version.rb +1 -1
- data/middleman-core.gemspec +1 -1
- metadata +126 -28
- data/lib/middleman-core/core_extensions/builder.rb +0 -17
- data/lib/middleman-core/core_extensions/ruby_encoding.rb +0 -25
- data/middleman-core-x86-mingw32.gemspec +0 -38
@@ -2,14 +2,14 @@ Feature: Build Clean
|
|
2
2
|
Scenario: Build and Clean an app
|
3
3
|
Given a fixture app "clean-app"
|
4
4
|
And app "clean-app" is using config "empty"
|
5
|
-
And a successfully built app at "clean-app"
|
5
|
+
And a successfully built app at "clean-app" with flags "--no-clean"
|
6
6
|
Then the following files should exist:
|
7
7
|
| build/index.html |
|
8
8
|
| build/should_be_ignored.html |
|
9
9
|
| build/should_be_ignored2.html |
|
10
10
|
| build/should_be_ignored3.html |
|
11
11
|
And app "clean-app" is using config "complications"
|
12
|
-
Given a successfully built app at "clean-app"
|
12
|
+
Given a successfully built app at "clean-app"
|
13
13
|
Then the following files should not exist:
|
14
14
|
| build/should_be_ignored.html |
|
15
15
|
| build/should_be_ignored2.html |
|
@@ -17,12 +17,11 @@ Feature: Build Clean
|
|
17
17
|
And the file "build/index.html" should contain "Comment in layout"
|
18
18
|
|
19
19
|
Scenario: Clean build an app with newly ignored files and a nested output directory
|
20
|
-
Given a built app at "clean-nested-app"
|
20
|
+
Given a built app at "clean-nested-app" with flags "--no-clean"
|
21
21
|
Then a directory named "sub/dir" should exist
|
22
22
|
Then the following files should exist:
|
23
23
|
| sub/dir/about.html |
|
24
24
|
When I append to "config.rb" with "ignore 'about.html'"
|
25
|
-
Given a built app at "clean-nested-app"
|
25
|
+
Given a built app at "clean-nested-app"
|
26
26
|
Then the following files should not exist:
|
27
27
|
| sub/dir/about.html |
|
28
|
-
|
@@ -0,0 +1,43 @@
|
|
1
|
+
Feature: Setting the right content type for files
|
2
|
+
|
3
|
+
Scenario: The right content type gets automatically determined
|
4
|
+
Given the Server is running at "content-type-app"
|
5
|
+
When I go to "/index.html"
|
6
|
+
Then the content type should be "text/html"
|
7
|
+
When I go to "/images/blank.gif"
|
8
|
+
Then the content type should be "image/gif"
|
9
|
+
When I go to "/javascripts/app.js"
|
10
|
+
Then the content type should be "application/javascript"
|
11
|
+
When I go to "/stylesheets/site.css"
|
12
|
+
Then the content type should be "text/css"
|
13
|
+
When I go to "/README"
|
14
|
+
Then the content type should be "text/plain"
|
15
|
+
|
16
|
+
Scenario: Content type can be set explicitly via page or proxy or frontmatter
|
17
|
+
Given a fixture app "content-type-app"
|
18
|
+
And a file named "config.rb" with:
|
19
|
+
"""
|
20
|
+
page "README", :content_type => 'text/awesome'
|
21
|
+
proxy "bar", "index.html", :content_type => 'text/custom'
|
22
|
+
proxy "foo", "README" # auto-delegate to target content type
|
23
|
+
"""
|
24
|
+
And the Server is running at "content-type-app"
|
25
|
+
When I go to "/README"
|
26
|
+
Then the content type should be "text/awesome"
|
27
|
+
When I go to "/bar"
|
28
|
+
Then the content type should be "text/custom"
|
29
|
+
When I go to "/foo"
|
30
|
+
Then the content type should be "text/awesome"
|
31
|
+
When I go to "/override.html"
|
32
|
+
Then the content type should be "text/neato"
|
33
|
+
|
34
|
+
Scenario: Content types can be overridden with mime_type
|
35
|
+
Given a fixture app "content-type-app"
|
36
|
+
And a file named "config.rb" with:
|
37
|
+
"""
|
38
|
+
mime_type('.js', 'application/x-javascript')
|
39
|
+
"""
|
40
|
+
And the Server is running at "content-type-app"
|
41
|
+
When I go to "/javascripts/app.js"
|
42
|
+
Then the content type should be "application/x-javascript"
|
43
|
+
|
data/features/data.feature
CHANGED
@@ -5,18 +5,23 @@ Feature: Local Data API
|
|
5
5
|
Given the Server is running at "basic-data-app"
|
6
6
|
When I go to "/data.html"
|
7
7
|
Then I should see "One:Two"
|
8
|
-
|
8
|
+
|
9
9
|
Scenario: Rendering json
|
10
10
|
Given the Server is running at "basic-data-app"
|
11
11
|
When I go to "/data3.html"
|
12
12
|
Then I should see "One:Two"
|
13
|
-
|
13
|
+
|
14
14
|
Scenario: Using data in config.rb
|
15
15
|
Given the Server is running at "data-app"
|
16
16
|
When I go to "/test1.html"
|
17
17
|
Then I should see "Welcome"
|
18
|
-
|
18
|
+
|
19
19
|
Scenario: Using data2 in config.rb
|
20
20
|
Given the Server is running at "data-app"
|
21
21
|
When I go to "/test2.html"
|
22
|
-
Then I should see "Welcome"
|
22
|
+
Then I should see "Welcome"
|
23
|
+
|
24
|
+
Scenario: Using nested data
|
25
|
+
Given the Server is running at "nested-data-app"
|
26
|
+
When I go to "/test.html"
|
27
|
+
Then I should see "test:Hello"
|
@@ -0,0 +1,151 @@
|
|
1
|
+
Feature: Neighboring YAML Front Matter
|
2
|
+
|
3
|
+
Scenario: Rendering html (yaml)
|
4
|
+
Given the Server is running at "frontmatter-neighbor-app"
|
5
|
+
When I go to "/front-matter-auto.html"
|
6
|
+
Then I should see "<h1>This is the title</h1>"
|
7
|
+
Then I should not see "---"
|
8
|
+
When I go to "/front-matter-auto.erb.frontmatter"
|
9
|
+
Then I should see "File Not Found"
|
10
|
+
When I go to "/front-matter-2.php"
|
11
|
+
Then I should see "<h1>This is the title</h1>"
|
12
|
+
Then I should see "<?php"
|
13
|
+
Then I should not see "---"
|
14
|
+
When I go to "/front-matter-2.php.erb.frontmatter"
|
15
|
+
Then I should see "File Not Found"
|
16
|
+
|
17
|
+
Scenario: Rendering raw (template-less) (yaml)
|
18
|
+
Given the Server is running at "frontmatter-neighbor-app"
|
19
|
+
When I go to "/raw-front-matter.html"
|
20
|
+
Then I should see "<h1><%= data.page.title %></h1>"
|
21
|
+
Then I should not see "---"
|
22
|
+
When I go to "/raw-front-matter.html.frontmatter"
|
23
|
+
Then I should see "File Not Found"
|
24
|
+
When I go to "/raw-front-matter.php"
|
25
|
+
Then I should see '<?php echo "sup"; ?>'
|
26
|
+
Then I should see "<?php"
|
27
|
+
Then I should not see "---"
|
28
|
+
When I go to "/raw-front-matter.php.frontmatter"
|
29
|
+
Then I should see "File Not Found"
|
30
|
+
|
31
|
+
Scenario: YAML not on first line, with encoding
|
32
|
+
Given the Server is running at "frontmatter-neighbor-app"
|
33
|
+
When I go to "/front-matter-encoding.html"
|
34
|
+
Then I should see "<h1>This is the title</h1>"
|
35
|
+
Then I should not see "---"
|
36
|
+
When I go to "/front-matter-encoding.html.erb.frontmatter"
|
37
|
+
Then I should see "File Not Found"
|
38
|
+
|
39
|
+
Scenario: Rendering html (json)
|
40
|
+
Given the Server is running at "frontmatter-neighbor-app"
|
41
|
+
When I go to "/json-front-matter-auto.html"
|
42
|
+
Then I should see "<h1>This is the title</h1>"
|
43
|
+
Then I should not see ";;;"
|
44
|
+
When I go to "/json-front-matter-auto.erb.frontmatter"
|
45
|
+
Then I should see "File Not Found"
|
46
|
+
When I go to "/json-front-matter.html"
|
47
|
+
Then I should see "<h1>This is the title</h1>"
|
48
|
+
Then I should not see ";;;"
|
49
|
+
When I go to "/json-front-matter.html.erb.frontmatter"
|
50
|
+
Then I should see "File Not Found"
|
51
|
+
When I go to "/json-front-matter-2.php"
|
52
|
+
Then I should see "<h1>This is the title</h1>"
|
53
|
+
Then I should see "<?php"
|
54
|
+
Then I should not see ";;;"
|
55
|
+
When I go to "/json-front-matter-2.php.erb.frontmatter"
|
56
|
+
Then I should see "File Not Found"
|
57
|
+
|
58
|
+
Scenario: A template changes frontmatter during preview
|
59
|
+
Given the Server is running at "frontmatter-neighbor-app"
|
60
|
+
And the file "source/front-matter-change.html.erb" has the contents
|
61
|
+
"""
|
62
|
+
<%= data.page.title %>
|
63
|
+
"""
|
64
|
+
And the file "source/front-matter-change.html.erb.frontmatter" has the contents
|
65
|
+
"""
|
66
|
+
---
|
67
|
+
title: Hello World
|
68
|
+
layout: false
|
69
|
+
---
|
70
|
+
"""
|
71
|
+
When I go to "/front-matter-change.html"
|
72
|
+
Then I should see "Hello World"
|
73
|
+
And the file "source/front-matter-change.html.erb.frontmatter" has the contents
|
74
|
+
"""
|
75
|
+
---
|
76
|
+
title: Hola Mundo
|
77
|
+
layout: false
|
78
|
+
---
|
79
|
+
"""
|
80
|
+
When I go to "/front-matter-change.html"
|
81
|
+
Then I should see "Hola Mundo"
|
82
|
+
When I go to "/front-matter-change.html.erb.frontmatter"
|
83
|
+
Then I should see "File Not Found"
|
84
|
+
|
85
|
+
Scenario: A template should handle an empty YAML feed
|
86
|
+
Given the Server is running at "frontmatter-neighbor-app"
|
87
|
+
And the file "source/front-matter-change.html.erb.frontmatter" has the contents
|
88
|
+
"""
|
89
|
+
---
|
90
|
+
---
|
91
|
+
"""
|
92
|
+
When I go to "/front-matter-change.html"
|
93
|
+
Then I should not see "Hello World"
|
94
|
+
Then I should not see "Hola Mundo"
|
95
|
+
When I go to "/front-matter-change.html.erb.frontmatter"
|
96
|
+
Then I should see "File Not Found"
|
97
|
+
|
98
|
+
Scenario: Setting layout, ignoring, and disabling directory indexes through frontmatter (build)
|
99
|
+
Given a successfully built app at "frontmatter-settings-neighbor-app"
|
100
|
+
Then the following files should exist:
|
101
|
+
| build/proxied.html |
|
102
|
+
And the file "build/alternate_layout.html" should contain "Alternate layout"
|
103
|
+
And the following files should not exist:
|
104
|
+
| build/ignored.html |
|
105
|
+
| build/alternate_layout.html.erb.frontmatter |
|
106
|
+
| build/ignored.html.erb.frontmatter |
|
107
|
+
| build/override_layout.html.erb.frontmatter |
|
108
|
+
| build/page_mentioned.html.erb.frontmatter |
|
109
|
+
|
110
|
+
Scenario: Setting layout, ignoring, and disabling directory indexes through frontmatter (preview)
|
111
|
+
Given the Server is running at "frontmatter-settings-neighbor-app"
|
112
|
+
When I go to "/alternate_layout.html"
|
113
|
+
Then I should not see "File Not Found"
|
114
|
+
And I should see "Alternate layout"
|
115
|
+
When I go to "/alternate_layout.html.erb.frontmatter"
|
116
|
+
Then I should see "File Not Found"
|
117
|
+
When I go to "/ignored.html"
|
118
|
+
Then I should see "File Not Found"
|
119
|
+
When I go to "/ignored.html.erb.frontmatter"
|
120
|
+
Then I should see "File Not Found"
|
121
|
+
When I go to "/ignored/index.html"
|
122
|
+
Then I should see "File Not Found"
|
123
|
+
|
124
|
+
Scenario: Changing frontmatter in preview server
|
125
|
+
Given the Server is running at "frontmatter-settings-neighbor-app"
|
126
|
+
When I go to "/ignored.html"
|
127
|
+
Then I should see "File Not Found"
|
128
|
+
And the file "source/ignored.html.erb.frontmatter" has the contents
|
129
|
+
"""
|
130
|
+
---
|
131
|
+
ignored: false
|
132
|
+
---
|
133
|
+
"""
|
134
|
+
When I go to "/ignored.html"
|
135
|
+
Then I should see "This file ignores itself! But it can still be proxied."
|
136
|
+
When I go to "/ignored.html.erb.frontmatter"
|
137
|
+
Then I should see "File Not Found"
|
138
|
+
|
139
|
+
Scenario: Overriding layout through frontmatter
|
140
|
+
Given the Server is running at "frontmatter-settings-neighbor-app"
|
141
|
+
When I go to "/override_layout.html"
|
142
|
+
Then I should see "Layout in use: Override"
|
143
|
+
When I go to "/override_layout.html.erb.frontmatter"
|
144
|
+
Then I should see "File Not Found"
|
145
|
+
|
146
|
+
Scenario: Setting layout through frontmatter even if page is mentioned in config
|
147
|
+
Given the Server is running at "frontmatter-settings-neighbor-app"
|
148
|
+
When I go to "/page_mentioned.html"
|
149
|
+
Then I should see "Layout in use: Override"
|
150
|
+
When I go to "/page_mentioned.html.erb.frontmatter"
|
151
|
+
Then I should see "File Not Found"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Feature: Queryable Selector
|
2
|
+
Scenario: Basic Selector Tests
|
3
|
+
Then should initialize with an attribute and an operator
|
4
|
+
Then should raise an exception if the operator is not supported
|
5
|
+
Scenario: Using offset and limit
|
6
|
+
Given the Server is running at "queryable-app"
|
7
|
+
Then should limit the documents to the number specified
|
8
|
+
Then should offset the documents by the number specified
|
9
|
+
Then should support offset and limit at the same time
|
10
|
+
Then should not freak out about an offset higher than the document count
|
11
|
+
Scenario: Using where queries with an equal operator
|
12
|
+
Given the Server is running at "queryable-app"
|
13
|
+
Then should return the right documents
|
14
|
+
Then should be chainable
|
15
|
+
Then should not be confused by attributes not present in all documents
|
16
|
+
Scenario: Using where queries with a complex operator
|
17
|
+
Given the Server is running at "queryable-app"
|
18
|
+
Then with a gt operator should return the right documents
|
19
|
+
Then with a gte operator should return the right documents
|
20
|
+
Then with an in operator should return the right documents
|
21
|
+
Then with an lt operator should return the right documents
|
22
|
+
Then with an lte operator should return the right documents
|
23
|
+
Then with an include operator include should return the right documents
|
24
|
+
Then with mixed operators should return the right documents
|
25
|
+
Then using multiple constrains in one where should return the right documents
|
26
|
+
Scenario: Sorting documents
|
27
|
+
Given the Server is running at "queryable-app"
|
28
|
+
Then should support ordering by attribute ascending
|
29
|
+
Then should support ordering by attribute descending
|
30
|
+
Then should order by attribute ascending by default
|
31
|
+
Then should exclude documents that do not own the attribute
|
@@ -0,0 +1,123 @@
|
|
1
|
+
Then /^should initialize with an attribute and an operator$/ do
|
2
|
+
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :author, :operator => 'equal'
|
3
|
+
:author.should == selector.attribute
|
4
|
+
'equal'.should == selector.operator
|
5
|
+
end
|
6
|
+
|
7
|
+
Then /^should raise an exception if the operator is not supported$/ do
|
8
|
+
expect {
|
9
|
+
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :author, :operator => 'zomg'
|
10
|
+
}.to raise_error(::Middleman::Sitemap::Queryable::OperatorNotSupportedError)
|
11
|
+
end
|
12
|
+
|
13
|
+
Then /^should limit the documents to the number specified$/ do
|
14
|
+
@server_inst.sitemap.order_by(:id).limit(2).all.map { |r| r.raw_data[:id] }.sort.should == [1,2].sort
|
15
|
+
end
|
16
|
+
|
17
|
+
Then /^should offset the documents by the number specified$/ do
|
18
|
+
@server_inst.sitemap.order_by(:id).offset(2).all.map { |r| r.raw_data[:id] }.sort.should == [3,4,5].sort
|
19
|
+
end
|
20
|
+
|
21
|
+
Then /^should support offset and limit at the same time$/ do
|
22
|
+
@server_inst.sitemap.order_by(:id).offset(1).limit(2).all.map { |r| r.raw_data[:id] }.sort.should == [2,3].sort
|
23
|
+
end
|
24
|
+
|
25
|
+
Then /^should not freak out about an offset higher than the document count$/ do
|
26
|
+
@server_inst.sitemap.order_by(:id).offset(5).all.should == []
|
27
|
+
end
|
28
|
+
|
29
|
+
Then /^should return the right documents$/ do
|
30
|
+
documents = @server_inst.sitemap.resources.select { |r| !r.raw_data.empty? }
|
31
|
+
document_1 = documents[0]
|
32
|
+
document_2 = documents[1]
|
33
|
+
|
34
|
+
found_document = @server_inst.sitemap.where(:title => document_1.raw_data[:title]).first
|
35
|
+
document_1.should == found_document
|
36
|
+
|
37
|
+
found_document = @server_inst.sitemap.where(:title => document_2.raw_data[:title]).first
|
38
|
+
document_2.should == found_document
|
39
|
+
end
|
40
|
+
|
41
|
+
Then /^should be chainable$/ do
|
42
|
+
documents = @server_inst.sitemap.resources.select { |r| !r.raw_data.empty? }
|
43
|
+
document_1 = documents[0]
|
44
|
+
|
45
|
+
document_proxy = @server_inst.sitemap.where(:title => document_1.raw_data[:title])
|
46
|
+
document_proxy.where(:id => document_1.raw_data[:id])
|
47
|
+
document_1.should == document_proxy.first
|
48
|
+
end
|
49
|
+
|
50
|
+
Then /^should not be confused by attributes not present in all documents$/ do
|
51
|
+
result = @server_inst.sitemap.where(:seldom_attribute => 'is seldom').all
|
52
|
+
result.map { |r| r.raw_data[:id] }.should == [4]
|
53
|
+
end
|
54
|
+
|
55
|
+
Then /^with a gt operator should return the right documents$/ do
|
56
|
+
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'gt'
|
57
|
+
found_documents = @server_inst.sitemap.where(selector => 2).all
|
58
|
+
found_documents.map { |r| r.raw_data[:id] }.sort.should == [5,3,4].sort
|
59
|
+
end
|
60
|
+
|
61
|
+
Then /^with a gte operator should return the right documents$/ do
|
62
|
+
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'gte'
|
63
|
+
found_documents = @server_inst.sitemap.where(selector => 2).all
|
64
|
+
found_documents.map { |r| r.raw_data[:id] }.sort.should == [2,5,3,4].sort
|
65
|
+
end
|
66
|
+
|
67
|
+
Then /^with an in operator should return the right documents$/ do
|
68
|
+
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'in'
|
69
|
+
found_documents = @server_inst.sitemap.where(selector => [2,3]).all
|
70
|
+
found_documents.map { |r| r.raw_data[:id] }.sort.should == [2,3].sort
|
71
|
+
end
|
72
|
+
|
73
|
+
Then /^with an lt operator should return the right documents$/ do
|
74
|
+
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'lt'
|
75
|
+
found_documents = @server_inst.sitemap.where(selector => 2).all
|
76
|
+
found_documents.map { |r| r.raw_data[:id] }.should == [1]
|
77
|
+
end
|
78
|
+
|
79
|
+
Then /^with an lte operator should return the right documents$/ do
|
80
|
+
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'lte'
|
81
|
+
found_documents = @server_inst.sitemap.where(selector => 2).all
|
82
|
+
found_documents.map { |r| r.raw_data[:id] }.sort.should == [1,2].sort
|
83
|
+
end
|
84
|
+
|
85
|
+
Then /^with an include operator include should return the right documents$/ do
|
86
|
+
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :tags, :operator => 'include'
|
87
|
+
found_documents = @server_inst.sitemap.where(selector => 'ruby').all
|
88
|
+
found_documents.map { |r| r.raw_data[:id] }.sort.should == [1,2].sort
|
89
|
+
end
|
90
|
+
|
91
|
+
Then /^with mixed operators should return the right documents$/ do
|
92
|
+
in_selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'in'
|
93
|
+
gt_selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'gt'
|
94
|
+
documents_proxy = @server_inst.sitemap.where(in_selector => [2,3])
|
95
|
+
found_documents = documents_proxy.where(gt_selector => 2).all
|
96
|
+
found_documents.map { |r| r.raw_data[:id] }.should == [3]
|
97
|
+
end
|
98
|
+
|
99
|
+
Then /^using multiple constrains in one where should return the right documents$/ do
|
100
|
+
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'lte'
|
101
|
+
found_documents = @server_inst.sitemap.where(selector => 2, :status => :published).all
|
102
|
+
found_documents.map { |r| r.raw_data[:id] }.sort.should == [1,2].sort
|
103
|
+
end
|
104
|
+
|
105
|
+
Then /^should support ordering by attribute ascending$/ do
|
106
|
+
found_documents = @server_inst.sitemap.order_by(:title => :asc).all
|
107
|
+
found_documents.map { |r| r.raw_data[:id] }.should == [2,3,1,5,4]
|
108
|
+
end
|
109
|
+
|
110
|
+
Then /^should support ordering by attribute descending$/ do
|
111
|
+
found_documents = @server_inst.sitemap.order_by(:title => :desc).all
|
112
|
+
found_documents.map { |r| r.raw_data[:id] }.should == [4,5,1,3,2]
|
113
|
+
end
|
114
|
+
|
115
|
+
Then /^should order by attribute ascending by default$/ do
|
116
|
+
found_documents = @server_inst.sitemap.order_by(:title).all
|
117
|
+
found_documents.map { |r| r.raw_data[:id] }.should == [2,3,1,5,4]
|
118
|
+
end
|
119
|
+
|
120
|
+
Then /^should exclude documents that do not own the attribute$/ do
|
121
|
+
found_documents = @server_inst.sitemap.order_by(:status).all
|
122
|
+
found_documents.map { |r| r.raw_data[:id] }.to_set.should == [1,2].to_set
|
123
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
# I'm an htaccess file!
|
@@ -0,0 +1 @@
|
|
1
|
+
I have no file extension.
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
I'm an HTML file!
|
@@ -0,0 +1 @@
|
|
1
|
+
// This is JavaScript
|
@@ -0,0 +1 @@
|
|
1
|
+
/* This is CSS */
|
File without changes
|