benoit 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.gitmodules +3 -0
- data/.rspec +1 -0
- data/.rspec-turnip +1 -0
- data/.ruby-version +1 -0
- data/Assetfile +44 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +110 -0
- data/Rakefile +9 -0
- data/benoit.gemspec +50 -0
- data/bin/benoit +121 -0
- data/bin/bundle-development +1 -0
- data/bin/bundle-sandbox +1 -0
- data/lib/benoit.rb +36 -0
- data/lib/benoit/cadenza.rb +11 -0
- data/lib/benoit/cadenza/output_filters.rb +21 -0
- data/lib/benoit/cleaner.rb +10 -0
- data/lib/benoit/compiler_error.rb +49 -0
- data/lib/benoit/configuration.rb +24 -0
- data/lib/benoit/current_site.rb +12 -0
- data/lib/benoit/file_wrapper_extensions.rb +13 -0
- data/lib/benoit/filters.rb +15 -0
- data/lib/benoit/filters/base_filter.rb +44 -0
- data/lib/benoit/filters/blacklist_filter.rb +18 -0
- data/lib/benoit/filters/cadenza_filter.rb +75 -0
- data/lib/benoit/filters/content_page_filter.rb +45 -0
- data/lib/benoit/filters/markdown_filter.rb +19 -0
- data/lib/benoit/filters/metadata_cleaner.rb +30 -0
- data/lib/benoit/filters/move_to_root_filter.rb +22 -0
- data/lib/benoit/filters/pagination_filter.rb +23 -0
- data/lib/benoit/filters/pass_thru_filter.rb +22 -0
- data/lib/benoit/filters/sass_filter.rb +74 -0
- data/lib/benoit/filters/set_metadata_filter.rb +15 -0
- data/lib/benoit/logger.rb +69 -0
- data/lib/benoit/page.rb +88 -0
- data/lib/benoit/page_metadata.rb +8 -0
- data/lib/benoit/page_metadata/container.rb +74 -0
- data/lib/benoit/page_metadata/json_converter.rb +28 -0
- data/lib/benoit/page_metadata/parser.rb +38 -0
- data/lib/benoit/page_metadata/store.rb +75 -0
- data/lib/benoit/pipeline.rb +1 -0
- data/lib/benoit/pipeline/dsl_extensions.rb +8 -0
- data/lib/benoit/pipeline/pagination_matcher.rb +53 -0
- data/lib/benoit/pipeline_project.rb +81 -0
- data/lib/benoit/site_context.rb +123 -0
- data/lib/benoit/utils/finds_layouts_for_template.rb +77 -0
- data/lib/benoit/utils/normalizes_path_to_template.rb +43 -0
- data/lib/benoit/utils/paginated_list.rb +102 -0
- data/lib/benoit/version.rb +3 -0
- data/lib/build_notifiers/file_built_notifier.rb +20 -0
- data/lib/build_notifiers/progress_notifier.rb +57 -0
- data/lib/cli.rb +39 -0
- data/spec/.rbenv-gemsets +1 -0
- data/spec/Gemfile +9 -0
- data/spec/Gemfile.lock +57 -0
- data/spec/bin/autospec +16 -0
- data/spec/bin/cucumber +16 -0
- data/spec/bin/htmldiff +16 -0
- data/spec/bin/ldiff +16 -0
- data/spec/bin/rspec +16 -0
- data/spec/features/build_command.feature +46 -0
- data/spec/features/frontmatter_metadata.feature +99 -0
- data/spec/features/javascript_files.feature +35 -0
- data/spec/features/output_filters.feature +20 -0
- data/spec/features/page_layouts.feature +72 -0
- data/spec/features/pagination.feature +58 -0
- data/spec/features/sass_files.feature +30 -0
- data/spec/features/version.feature +5 -0
- data/spec/lib/filters/base_filter_spec.rb +141 -0
- data/spec/lib/filters/markdown_filter_spec.rb +65 -0
- data/spec/lib/filters/sass_filter_spec.rb +73 -0
- data/spec/lib/metadata_json_converter_spec.rb +65 -0
- data/spec/lib/metadata_store_spec.rb +148 -0
- data/spec/lib/page_spec.rb +19 -0
- data/spec/lib/site_context_spec.rb +106 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/steps/output_file_steps.rb +45 -0
- data/spec/steps/run_steps.rb +71 -0
- data/spec/steps/staticly_steps.rb +194 -0
- data/spec/support/aruba/rspec.rb +66 -0
- data/spec/support/files/img.png +0 -0
- data/spec/support/files/input.css.scss +7 -0
- data/spec/support/files/input.scss +7 -0
- data/spec/support/spec_helpers/file_helpers.rb +8 -0
- data/spec/support/spec_helpers/memory_file_wrapper.rb +43 -0
- data/spec/support/spec_helpers/memory_manifest.rb +19 -0
- data/spec/turnip_helper.rb +19 -0
- data/vendor/frontmatter/frontmatter.gemspec +24 -0
- data/vendor/frontmatter/lib/frontmatter.rb +92 -0
- data/vendor/frontmatter/lib/frontmatter/version.rb +3 -0
- data/vendor/rake-pipeline/.gitignore +18 -0
- data/vendor/rake-pipeline/.rspec +1 -0
- data/vendor/rake-pipeline/.travis.yml +12 -0
- data/vendor/rake-pipeline/.yardopts +2 -0
- data/vendor/rake-pipeline/GETTING_STARTED.md +268 -0
- data/vendor/rake-pipeline/Gemfile +14 -0
- data/vendor/rake-pipeline/LICENSE +20 -0
- data/vendor/rake-pipeline/README.markdown +11 -0
- data/vendor/rake-pipeline/README.yard +178 -0
- data/vendor/rake-pipeline/Rakefile +21 -0
- data/vendor/rake-pipeline/bin/rakep +4 -0
- data/vendor/rake-pipeline/examples/copying_files.md +12 -0
- data/vendor/rake-pipeline/examples/minifying_files.md +37 -0
- data/vendor/rake-pipeline/examples/modifying_pipelines.md +67 -0
- data/vendor/rake-pipeline/examples/multiple_pipelines.md +77 -0
- data/vendor/rake-pipeline/lib/generators/rake/pipeline/install/install_generator.rb +70 -0
- data/vendor/rake-pipeline/lib/rake-pipeline.rb +509 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/cli.rb +57 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/dsl.rb +9 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/dsl/pipeline_dsl.rb +246 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/dsl/project_dsl.rb +108 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/dynamic_file_task.rb +194 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/error.rb +17 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/file_wrapper.rb +195 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/filter.rb +267 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/filters.rb +4 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/filters/concat_filter.rb +63 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/filters/gsub_filter.rb +56 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/filters/ordering_concat_filter.rb +38 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/filters/pipeline_finalizing_filter.rb +21 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/graph.rb +178 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/manifest.rb +82 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/manifest_entry.rb +34 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/matcher.rb +141 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/middleware.rb +73 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/precompile.rake +8 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/project.rb +338 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/rails_plugin.rb +10 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/railtie.rb +34 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/reject_matcher.rb +29 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/server.rb +15 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/sorted_pipeline.rb +19 -0
- data/vendor/rake-pipeline/lib/rake-pipeline/version.rb +6 -0
- data/vendor/rake-pipeline/rails/init.rb +2 -0
- data/vendor/rake-pipeline/rake-pipeline.gemspec +24 -0
- data/vendor/rake-pipeline/spec/cli_spec.rb +73 -0
- data/vendor/rake-pipeline/spec/concat_filter_spec.rb +37 -0
- data/vendor/rake-pipeline/spec/dsl/pipeline_dsl_spec.rb +165 -0
- data/vendor/rake-pipeline/spec/dsl/project_dsl_spec.rb +41 -0
- data/vendor/rake-pipeline/spec/dynamic_file_task_spec.rb +119 -0
- data/vendor/rake-pipeline/spec/encoding_spec.rb +106 -0
- data/vendor/rake-pipeline/spec/file_wrapper_spec.rb +132 -0
- data/vendor/rake-pipeline/spec/filter_spec.rb +367 -0
- data/vendor/rake-pipeline/spec/graph_spec.rb +56 -0
- data/vendor/rake-pipeline/spec/gsub_filter_spec.rb +87 -0
- data/vendor/rake-pipeline/spec/manifest_entry_spec.rb +46 -0
- data/vendor/rake-pipeline/spec/manifest_spec.rb +67 -0
- data/vendor/rake-pipeline/spec/matcher_spec.rb +141 -0
- data/vendor/rake-pipeline/spec/middleware_spec.rb +199 -0
- data/vendor/rake-pipeline/spec/ordering_concat_filter_spec.rb +42 -0
- data/vendor/rake-pipeline/spec/pipeline_spec.rb +232 -0
- data/vendor/rake-pipeline/spec/project_spec.rb +295 -0
- data/vendor/rake-pipeline/spec/rake_acceptance_spec.rb +720 -0
- data/vendor/rake-pipeline/spec/rake_tasks_spec.rb +21 -0
- data/vendor/rake-pipeline/spec/reject_matcher_spec.rb +31 -0
- data/vendor/rake-pipeline/spec/sorted_pipeline_spec.rb +27 -0
- data/vendor/rake-pipeline/spec/spec_helper.rb +38 -0
- data/vendor/rake-pipeline/spec/support/spec_helpers/file_utils.rb +35 -0
- data/vendor/rake-pipeline/spec/support/spec_helpers/filters.rb +37 -0
- data/vendor/rake-pipeline/spec/support/spec_helpers/input_helpers.rb +23 -0
- data/vendor/rake-pipeline/spec/support/spec_helpers/memory_file_wrapper.rb +35 -0
- data/vendor/rake-pipeline/spec/support/spec_helpers/memory_manifest.rb +19 -0
- data/vendor/rake-pipeline/tools/perfs +101 -0
- metadata +497 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
require "benoit/page_metadata/store"
|
2
|
+
require "benoit/page_metadata/json_converter"
|
3
|
+
|
4
|
+
RSpec::Matchers.define :contain_page do |expected|
|
5
|
+
match do |actual|
|
6
|
+
page_name = expected
|
7
|
+
page_name.sub! /\./, "_"
|
8
|
+
expect(actual).to have_page(page_name)
|
9
|
+
value = actual[InputWrapper.new(page_name)]
|
10
|
+
expect(value).to eq(@metadata) if @metadata
|
11
|
+
end
|
12
|
+
chain :with_metadata do |metadata|
|
13
|
+
@metadata = metadata
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
include Benoit::PageMetadata
|
18
|
+
describe Benoit::PageMetadata do
|
19
|
+
|
20
|
+
let(:index_html_metadata) do
|
21
|
+
{ "title" => "blah", "attr1" => "val1" }
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:about_html_metadata) do
|
25
|
+
{ "title" => "about", "attr2" => "val2" }
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:existing_metadata) do
|
29
|
+
{
|
30
|
+
"__index_html_metadata" => index_html_metadata,
|
31
|
+
"__about_html_metadata" => about_html_metadata
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
describe JsonConverter do
|
36
|
+
|
37
|
+
let(:json) { existing_metadata.to_json }
|
38
|
+
|
39
|
+
it "loads all metadata into cache" do
|
40
|
+
JsonConverter.import!(json)
|
41
|
+
store = Benoit::PageMetadata::Store.current
|
42
|
+
expect(store).to contain_page("index.html").with_metadata(index_html_metadata)
|
43
|
+
expect(store).to contain_page("about.html").with_metadata(about_html_metadata)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "exports all metadata currently in the cache" do
|
47
|
+
JsonConverter.import!(json)
|
48
|
+
new_json = JsonConverter.export
|
49
|
+
expect(new_json).to eq(json)
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
describe SiteContextConverter do
|
56
|
+
|
57
|
+
it "exports a hash with site paths instead of metadata keys" do
|
58
|
+
JsonConverter.import!(existing_metadata.to_json)
|
59
|
+
exported = SiteContextConverter.export
|
60
|
+
expect(exported.keys).to eq(["index_html", "about_html"])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1,148 @@
|
|
1
|
+
require "json"
|
2
|
+
require "spec_helper"
|
3
|
+
require "spec_helpers/file_helpers"
|
4
|
+
require "benoit/page_metadata/store"
|
5
|
+
require "benoit/page_metadata/container"
|
6
|
+
require "benoit/page_metadata/parser"
|
7
|
+
|
8
|
+
class InputWrapper < Struct.new(:path, :read)
|
9
|
+
end
|
10
|
+
|
11
|
+
RSpec::Matchers.define :have_metadata do |expected|
|
12
|
+
match do |actual|
|
13
|
+
expect(actual).to have_key(expected)
|
14
|
+
expect(actual.fetch(expected)).to eq(@value) if @value
|
15
|
+
end
|
16
|
+
chain :with_value do |actual|
|
17
|
+
@value = actual
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe Benoit::PageMetadata::Store do
|
22
|
+
include FileHelpers
|
23
|
+
|
24
|
+
let(:content) do
|
25
|
+
<<-EOF.unindent
|
26
|
+
---
|
27
|
+
title: blah
|
28
|
+
attr1: val1
|
29
|
+
attr2: val2
|
30
|
+
---
|
31
|
+
|
32
|
+
THE CONTENT
|
33
|
+
EOF
|
34
|
+
end
|
35
|
+
|
36
|
+
let(:new_content) do
|
37
|
+
<<-EOF.unindent
|
38
|
+
---
|
39
|
+
key1: blah1
|
40
|
+
key2: blah2
|
41
|
+
---
|
42
|
+
|
43
|
+
THE CONTENT
|
44
|
+
EOF
|
45
|
+
end
|
46
|
+
|
47
|
+
let(:write_page) { write_file(input.path, input.read) }
|
48
|
+
let(:write_new_page) { write_file(input.path, new_content) }
|
49
|
+
|
50
|
+
let(:input) { InputWrapper.new("tmp/index.html", content) }
|
51
|
+
|
52
|
+
let(:store) { described_class.current }
|
53
|
+
|
54
|
+
before(:each) do
|
55
|
+
store.expire!
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "the metadata hash" do
|
59
|
+
|
60
|
+
subject { write_page; store.import_from_page(input) }
|
61
|
+
|
62
|
+
it "contains the original content" do
|
63
|
+
expect(subject).to have_metadata("content").with_value("THE CONTENT\n")
|
64
|
+
end
|
65
|
+
|
66
|
+
it "contains additional attributes" do
|
67
|
+
expect(subject).to have_metadata("title").with_value("blah")
|
68
|
+
expect(subject).to have_metadata("attr1").with_value("val1")
|
69
|
+
expect(subject).to have_metadata("attr2").with_value("val2")
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "without metadata" do
|
75
|
+
|
76
|
+
|
77
|
+
let(:content) { "THE CONTENT" }
|
78
|
+
|
79
|
+
subject { write_page; store.import_from_page(input) }
|
80
|
+
|
81
|
+
|
82
|
+
it "returns only original path" do
|
83
|
+
expect(subject).to eq({"_original_path" => input.path})
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "memoizing" do
|
89
|
+
|
90
|
+
subject { write_page; store.import_from_page(input) }
|
91
|
+
|
92
|
+
it "keeps it from parsing again" do
|
93
|
+
write_new_page
|
94
|
+
new_input = InputWrapper.new("tmp/index.html", new_content)
|
95
|
+
new_metadata = store.import_from_page(new_input)
|
96
|
+
expect(new_metadata).to eq(subject)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "always returns the same hash" do
|
100
|
+
write_new_page
|
101
|
+
new_input = InputWrapper.new("tmp/index.html", new_content)
|
102
|
+
new_metadata = store.import_from_page(new_input)
|
103
|
+
expect(new_metadata.object_id).to eq(subject.object_id)
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "expiring the entire collection" do
|
109
|
+
|
110
|
+
subject { write_page; store.import_from_page(input) }
|
111
|
+
|
112
|
+
it "clears memoized keys, allowing new keys to be written" do
|
113
|
+
subject
|
114
|
+
store.expire!
|
115
|
+
write_new_page
|
116
|
+
new_input = InputWrapper.new("tmp/index.html", new_content)
|
117
|
+
new_metadata = store.import_from_page(new_input)
|
118
|
+
expect(new_metadata).to have_metadata("key1").with_value("blah1")
|
119
|
+
expect(new_metadata).to have_metadata("key2").with_value("blah2")
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
describe "accessing using [] notation" do
|
125
|
+
|
126
|
+
let(:input_no_metadata) { InputWrapper.new("tmp/blah.html", "") }
|
127
|
+
let(:default_hash) {
|
128
|
+
{ "_original_path" => input_no_metadata.path }
|
129
|
+
}
|
130
|
+
|
131
|
+
it "caches on the first access" do
|
132
|
+
write_page
|
133
|
+
metadata = store[input]
|
134
|
+
new_metadata = store[input]
|
135
|
+
expect(metadata).to_not be_nil
|
136
|
+
expect(metadata.object_id).to eq(new_metadata.object_id)
|
137
|
+
end
|
138
|
+
|
139
|
+
it "returns default hash for empty pages" do
|
140
|
+
write_file input_no_metadata.path, input_no_metadata.read
|
141
|
+
no_metadata = store[input_no_metadata]
|
142
|
+
expect(no_metadata).to eq(default_hash)
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'benoit/page'
|
3
|
+
|
4
|
+
describe Benoit::Page do
|
5
|
+
|
6
|
+
let(:metadata) { { "blah" => "diddy" } }
|
7
|
+
subject { described_class.new(metadata) }
|
8
|
+
|
9
|
+
describe "page metadata" do
|
10
|
+
it "is accessible via []" do
|
11
|
+
expect(subject["blah"]).to eq("diddy")
|
12
|
+
end
|
13
|
+
it "allows changing attributes via []" do
|
14
|
+
subject["blah"] = "doo"
|
15
|
+
expect(subject["blah"]).to eq("doo")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'benoit/page'
|
3
|
+
require 'benoit/site_context'
|
4
|
+
require 'benoit/utils/paginated_list'
|
5
|
+
|
6
|
+
include Benoit
|
7
|
+
|
8
|
+
describe SiteContext do
|
9
|
+
|
10
|
+
subject { described_class.new(pages) }
|
11
|
+
|
12
|
+
describe "looking up pages" do
|
13
|
+
let(:output_page) { Page.new("_original_path" => output_path) }
|
14
|
+
let(:pages) { [output_page] }
|
15
|
+
let(:output_path) { "blah" }
|
16
|
+
|
17
|
+
it "uses paths map to normalize input paths to output paths" do
|
18
|
+
subject.paths_map = { "input" => output_path }
|
19
|
+
expect(subject["input"]).to eq(output_page)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
RSpec::Matchers.define :be_pointing_at_first_page do
|
27
|
+
match do |expected|
|
28
|
+
expected.peek == [pages.first]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe SiteContext::ContextObject do
|
33
|
+
|
34
|
+
let(:type) { "post" }
|
35
|
+
let(:page) { {"_type" => type} }
|
36
|
+
let(:num_pages) { 2 }
|
37
|
+
let(:site) { SiteContext.new(pages) }
|
38
|
+
let(:context) { site.to_context }
|
39
|
+
let(:pages) do
|
40
|
+
(1..num_pages).map do |i|
|
41
|
+
page.merge("page" => i)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
subject { context.posts }
|
46
|
+
|
47
|
+
after do
|
48
|
+
SiteContext.clear_paginated_collections!
|
49
|
+
end
|
50
|
+
|
51
|
+
it "returns posts from content collection via method call" do
|
52
|
+
expect(subject).to eq(pages)
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "returns other types of content" do
|
56
|
+
let(:type) { "comic" }
|
57
|
+
subject { context.comics }
|
58
|
+
|
59
|
+
it { should eq(pages) }
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "for non-existant collections" do
|
63
|
+
subject { context.blah }
|
64
|
+
it "raises an error" do
|
65
|
+
expect(->{subject}).to raise_error(NoMethodError)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "pagination" do
|
70
|
+
let(:num_pages) { 3 }
|
71
|
+
subject { context.paginated_posts }
|
72
|
+
|
73
|
+
before do
|
74
|
+
SiteContext.paginate_collection("posts", 1)
|
75
|
+
pages << {"posts_per_page" => 1}
|
76
|
+
end
|
77
|
+
|
78
|
+
it "collects resource names with per_page count" do
|
79
|
+
expect(site.paginated_collections["posts"]).to eq([1])
|
80
|
+
end
|
81
|
+
|
82
|
+
it "returns the collection sliced by page" do
|
83
|
+
collection = subject.each
|
84
|
+
expect(collection.next.first).to eq(pages.first)
|
85
|
+
expect(collection.next.first).to eq(pages[1])
|
86
|
+
expect(collection.next.first).to eq(pages[2])
|
87
|
+
end
|
88
|
+
|
89
|
+
it "returns the existing list if already set" do
|
90
|
+
list = context.paginated_collection("posts")
|
91
|
+
expect(context.paginated_collection("posts")).to eq(list)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "rewinds the list if it is at the end" do
|
95
|
+
# Fast-forward list to end
|
96
|
+
1.upto(num_pages) do
|
97
|
+
subject.each{|p|}
|
98
|
+
end
|
99
|
+
new_list = context.paginated_posts
|
100
|
+
expect{new_list.peek}.to_not raise_error(StopIteration)
|
101
|
+
expect(new_list).to be_pointing_at_first_page
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
require "pry"
|
5
|
+
require "pry-nav"
|
6
|
+
|
7
|
+
require "spec_helpers/memory_file_wrapper"
|
8
|
+
require "spec_helpers/memory_manifest"
|
9
|
+
|
10
|
+
|
11
|
+
class String
|
12
|
+
def unindent
|
13
|
+
gsub(/^#{scan(/^\s*/).min_by{|l|l.length}}/, "")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module OutputFileSteps
|
2
|
+
extend Turnip::DSL
|
3
|
+
|
4
|
+
step "the output file should have content:" do |content|
|
5
|
+
step 'the output file "%s" should have content:' % @page.name, content
|
6
|
+
end
|
7
|
+
|
8
|
+
step "the output file should only have content:" do |content|
|
9
|
+
step 'the output file "%s" should only have content:' % @page.name, content
|
10
|
+
end
|
11
|
+
|
12
|
+
step "the output file :file_name should only contain the :ordinal :num :type" do |file_name,ordinal,num,type|
|
13
|
+
pages =
|
14
|
+
case ordinal
|
15
|
+
when "first"
|
16
|
+
@site.pages[0, num.to_i]
|
17
|
+
when "last"
|
18
|
+
@site.pages[-1 * num.to_i, num.to_i]
|
19
|
+
end
|
20
|
+
content = pages.map(&:content).join("\n") + "\n"
|
21
|
+
step 'the output file "%s" should only have content:' % file_name, content
|
22
|
+
end
|
23
|
+
|
24
|
+
step "the output file :file_name should exist" do |file_name|
|
25
|
+
file_name = File.join("_build", file_name)
|
26
|
+
step 'a file named "%s" should exist' % file_name
|
27
|
+
end
|
28
|
+
|
29
|
+
step "the output file :file_name should have content:" do |file_name, content|
|
30
|
+
file_name = File.join("_build", file_name)
|
31
|
+
step 'the file "%s" should contain:' % file_name, content
|
32
|
+
end
|
33
|
+
|
34
|
+
step "the output file :file_name should only have content:" do |file_name, content|
|
35
|
+
file_name = File.join("_build", file_name)
|
36
|
+
step 'the file "%s" should contain exactly:' % file_name, content
|
37
|
+
end
|
38
|
+
|
39
|
+
step "the output file :file_name should match :pattern" do |file_name, pattern|
|
40
|
+
file_name = File.join("_build", file_name)
|
41
|
+
step 'the file "%s" should match /%s/' % [file_name, pattern]
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module RunSteps
|
2
|
+
extend ::Turnip::DSL
|
3
|
+
|
4
|
+
step "I run :cmd" do |cmd|
|
5
|
+
run_simple(unescape(cmd), false)
|
6
|
+
end
|
7
|
+
|
8
|
+
step "I successfully run :cmd" do |cmd|
|
9
|
+
run_simple(unescape(cmd))
|
10
|
+
end
|
11
|
+
|
12
|
+
step "a directory named :directory should exist" do |directory|
|
13
|
+
if directory =~ /^~/
|
14
|
+
directory = File.expand_path(directory)
|
15
|
+
end
|
16
|
+
check_directory_presence([directory], true)
|
17
|
+
end
|
18
|
+
|
19
|
+
step "an empty file named :file_name" do |file_name|
|
20
|
+
write_file(file_name, "")
|
21
|
+
end
|
22
|
+
|
23
|
+
step "a file named :file_name with content:" do |file_name, content|
|
24
|
+
write_file(file_name, content)
|
25
|
+
end
|
26
|
+
|
27
|
+
step "the file :file_name should contain exactly:" do |file_name, partial_content|
|
28
|
+
check_exact_file_content(file_name, partial_content)
|
29
|
+
end
|
30
|
+
|
31
|
+
step "the file :file_name should contain:" do |file_name, partial_content|
|
32
|
+
check_file_content(file_name, partial_content, true)
|
33
|
+
end
|
34
|
+
|
35
|
+
step "the file :file_name should match :pattern" do |file_name, pattern|
|
36
|
+
check_file_content(file_name, /#{pattern}/, true)
|
37
|
+
end
|
38
|
+
|
39
|
+
step "I cd to :directory" do |directory|
|
40
|
+
cd directory
|
41
|
+
end
|
42
|
+
|
43
|
+
step "I remove the file :file_name" do |file_name|
|
44
|
+
remove_file(file_name)
|
45
|
+
end
|
46
|
+
|
47
|
+
step "a :size byte file named :file_name should exist" do |file_size, file_name|
|
48
|
+
check_file_size([[file_name, file_size.to_i]])
|
49
|
+
end
|
50
|
+
|
51
|
+
step "a file named :file_name should exist" do |file_name|
|
52
|
+
check_file_presence([file_name], true)
|
53
|
+
end
|
54
|
+
|
55
|
+
step "a file named :file_name should not exist" do |file_name|
|
56
|
+
check_file_presence([file_name], false)
|
57
|
+
end
|
58
|
+
|
59
|
+
placeholder :cmd do
|
60
|
+
match /`([^`]*)`/ do |cmd|
|
61
|
+
cmd
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
placeholder :pattern do
|
66
|
+
match /\/([^\/]*)\/$/ do |pattern|
|
67
|
+
pattern
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|