jekyll_plugin_support 1.1.0 → 3.1.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +38 -3
- data/CHANGELOG.md +30 -6
- data/README.md +474 -4
- data/jekyll_plugin_support.gemspec +3 -1
- data/lib/block/jekyll_plugin_support_block.rb +5 -6
- data/lib/block/jekyll_plugin_support_block_noarg.rb +1 -3
- data/lib/error/jekyll_custom_error.rb +6 -5
- data/lib/generator/jekyll_plugin_support_generator.rb +1 -7
- data/lib/helper/jekyll_plugin_helper.rb +5 -5
- data/lib/helper/jekyll_plugin_helper_class.rb +2 -2
- data/lib/hooks/a_page.rb +203 -0
- data/lib/hooks/all_collections_hooks.rb +61 -0
- data/lib/hooks/all_files.rb +48 -0
- data/lib/hooks/class_methods.rb +38 -0
- data/lib/jekyll_all_collections/all_collections_tag.rb +174 -0
- data/lib/jekyll_plugin_support/jekyll_plugin_support_class.rb +6 -7
- data/lib/jekyll_plugin_support/jekyll_plugin_support_spec_support.rb +1 -3
- data/lib/jekyll_plugin_support/version.rb +1 -1
- data/lib/jekyll_plugin_support.rb +27 -12
- data/lib/tag/jekyll_plugin_support_tag.rb +1 -4
- data/lib/tag/jekyll_plugin_support_tag_noarg.rb +0 -2
- data/lib/util/mslinn_binary_search.rb +152 -0
- data/lib/util/send_chain.rb +56 -0
- data/spec/all_collections_tag/all_collections_tag_sort_spec.rb +184 -0
- data/spec/bsearch_spec.rb +50 -0
- data/spec/custom_error_spec.rb +12 -10
- data/spec/date_sort_spec.rb +84 -0
- data/spec/jekyll_plugin_helper_options_spec.rb +9 -3
- data/spec/liquid_variable_parsing_spec.rb +7 -6
- data/spec/mslinn_binary_search_spec.rb +47 -0
- data/spec/send_chain_spec.rb +72 -0
- data/spec/send_spec.rb +28 -0
- data/spec/sorted_lru_files_spec.rb +82 -0
- data/spec/spec_helper.rb +15 -3
- data/spec/status_persistence.txt +4 -7
- data/spec/testable_spec.rb +38 -0
- metadata +56 -5
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../lib/jekyll_plugin_support'
|
3
|
+
|
4
|
+
# Verifies how data comparisons work
|
5
|
+
|
6
|
+
class Obj
|
7
|
+
# `last_modified` is primary sort key
|
8
|
+
# `date` (when specified) is secondary sort key
|
9
|
+
attr_reader :date, :last_modified
|
10
|
+
|
11
|
+
def initialize(param1, param2)
|
12
|
+
@last_modified = Date.parse(param1)
|
13
|
+
@date = Date.parse(param2)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
RSpec.describe(Obj) do
|
18
|
+
let(:o1) { described_class.new('2000-01-01', '2001-01-01') }
|
19
|
+
let(:o2) { described_class.new('2010-01-01', '2001-01-01') }
|
20
|
+
let(:o3) { described_class.new('2010-01-01', '2011-01-01') }
|
21
|
+
let(:o4) { described_class.new('2020-01-01', '2011-01-01') }
|
22
|
+
let(:objs) { [o1, o2, o3, o4] }
|
23
|
+
|
24
|
+
# See https://ruby-doc.org/3.2.0/Comparable.html
|
25
|
+
it 'compares one key with ascending dates' do
|
26
|
+
expect([o1.last_modified] <=> [o2.last_modified]).to eq(-1)
|
27
|
+
expect([o2.last_modified] <=> [o3.last_modified]).to eq(0)
|
28
|
+
expect([o3.last_modified] <=> [o4.last_modified]).to eq(-1)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'compares two keys with ascending dates' do
|
32
|
+
expect([o1.last_modified, o1.date] <=> [o2.last_modified, o2.date]).to eq(-1)
|
33
|
+
expect([o2.last_modified, o2.date] <=> [o3.last_modified, o3.date]).to eq(-1)
|
34
|
+
expect([o3.last_modified, o3.date] <=> [o4.last_modified, o4.date]).to eq(-1)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'compares one key with descending dates' do
|
38
|
+
expect([o1.last_modified] <=> [o2.last_modified]).to eq(-1)
|
39
|
+
expect([o2.last_modified] <=> [o3.last_modified]).to eq(0)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'compares two keys with descending dates' do
|
43
|
+
expect([o2.last_modified, o2.date] <=> [o1.last_modified, o1.date]).to eq(1)
|
44
|
+
expect([o3.last_modified, o3.date] <=> [o2.last_modified, o2.date]).to eq(1)
|
45
|
+
expect([o4.last_modified, o4.date] <=> [o3.last_modified, o3.date]).to eq(1)
|
46
|
+
end
|
47
|
+
|
48
|
+
# See https://ruby-doc.org/3.2.0/Enumerable.html#method-i-sort
|
49
|
+
it 'sort with one key ascending' do
|
50
|
+
sort_lambda = ->(a, b) { [a.last_modified] <=> [b.last_modified] }
|
51
|
+
result = objs.sort(&sort_lambda)
|
52
|
+
expect(result).to eq([o1, o2, o3, o4])
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'sort with one key descending' do
|
56
|
+
sort_lambda = ->(a, b) { [b.last_modified] <=> [a.last_modified] }
|
57
|
+
result = objs.sort(&sort_lambda)
|
58
|
+
expect(result).to eq([o4, o2, o3, o1])
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'sort with two keys ascending' do
|
62
|
+
sort_lambda = ->(a, b) { [a.last_modified, a.date] <=> [b.last_modified, b.date] }
|
63
|
+
result = objs.sort(&sort_lambda)
|
64
|
+
expect(result).to eq([o1, o2, o3, o4])
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'sort with both keys descending' do
|
68
|
+
sort_lambda = ->(a, b) { [b.last_modified, b.date] <=> [a.last_modified, a.date] }
|
69
|
+
result = objs.sort(&sort_lambda)
|
70
|
+
expect(result).to eq([o4, o3, o2, o1])
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'sort with last_modified descending and date ascending' do
|
74
|
+
sort_lambda = ->(a, b) { [b.last_modified, a.date] <=> [a.last_modified, b.date] }
|
75
|
+
result = objs.sort(&sort_lambda)
|
76
|
+
expect(result).to eq([o4, o2, o3, o1])
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'sort with last_modified ascending and date descending' do
|
80
|
+
sort_lambda = ->(a, b) { [a.last_modified, b.date] <=> [b.last_modified, a.date] }
|
81
|
+
result = objs.sort(&sort_lambda)
|
82
|
+
expect(result).to eq([o1, o3, o2, o4])
|
83
|
+
end
|
84
|
+
end
|
@@ -1,14 +1,17 @@
|
|
1
|
+
require 'jekyll'
|
1
2
|
require 'jekyll_plugin_logger'
|
2
|
-
require '
|
3
|
+
require 'spec_helper'
|
4
|
+
# require 'rspec/match_ignoring_whitespace'
|
3
5
|
require_relative '../lib/jekyll_plugin_support'
|
4
|
-
require_relative '../lib/jekyll_plugin_support_spec_support'
|
6
|
+
require_relative '../lib/jekyll_plugin_support/jekyll_plugin_support_spec_support'
|
5
7
|
|
6
8
|
class JekyllPluginHelperOptionsTest
|
7
|
-
RSpec.describe JekyllPluginHelper do
|
9
|
+
RSpec.describe ::JekyllSupport::JekyllPluginHelper do
|
8
10
|
logger = PluginMetaLogger.instance.new_logger(self, PluginMetaLogger.instance.config)
|
9
11
|
|
10
12
|
it 'parses quoted string options' do
|
11
13
|
helper = described_class.new('my_tag', "colors='blue or green' blah ick", logger, false)
|
14
|
+
helper.reinitialize helper.markup
|
12
15
|
expect(helper.keys_values.keys).to eq(%w[colors blah ick])
|
13
16
|
|
14
17
|
colors = helper.parameter_specified? 'colors'
|
@@ -19,6 +22,7 @@ class JekyllPluginHelperOptionsTest
|
|
19
22
|
|
20
23
|
it 'parses unquoted string options' do
|
21
24
|
helper = described_class.new('my_tag', 'color=blue blah ick', logger, false)
|
25
|
+
helper.reinitialize helper.markup
|
22
26
|
expect(helper.keys_values.keys).to eq(%w[color blah ick])
|
23
27
|
|
24
28
|
color = helper.parameter_specified? 'color'
|
@@ -29,6 +33,7 @@ class JekyllPluginHelperOptionsTest
|
|
29
33
|
|
30
34
|
it 'parses quoted booleans' do
|
31
35
|
helper = described_class.new('my_tag', "bool1='true' bool2='false' blah ick", logger, false)
|
36
|
+
helper.reinitialize helper.markup
|
32
37
|
expect(helper.keys_values.keys).to eq(%w[bool1 bool2 blah ick])
|
33
38
|
|
34
39
|
bool1 = helper.parameter_specified? 'bool1'
|
@@ -44,6 +49,7 @@ class JekyllPluginHelperOptionsTest
|
|
44
49
|
|
45
50
|
it 'parses unquoted booleans' do
|
46
51
|
helper = described_class.new('my_tag', 'bool1=true bool2=false blah ick', logger, false)
|
52
|
+
helper.reinitialize helper.markup
|
47
53
|
expect(helper.keys_values.keys).to eq(%w[bool1 bool2 blah ick])
|
48
54
|
|
49
55
|
bool1 = helper.parameter_specified? 'bool1'
|
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'jekyll_plugin_logger'
|
2
|
-
require '
|
2
|
+
require 'spec_helper'
|
3
|
+
# require 'rspec/match_ignoring_whitespace'
|
3
4
|
require_relative '../lib/jekyll_plugin_support'
|
4
|
-
require_relative '../lib/jekyll_plugin_support_spec_support'
|
5
|
+
require_relative '../lib/jekyll_plugin_support/jekyll_plugin_support_spec_support'
|
5
6
|
|
6
7
|
class LiquidVariableParsing
|
7
8
|
# @return copy of str with references to defined variables replaced by the values of the variables
|
8
|
-
def variable_replace(str, scopes)
|
9
|
+
def self.variable_replace(str, scopes)
|
9
10
|
result = str.clone
|
10
11
|
match_data_list = str.to_enum(:scan, /{{[a-z_][a-zA-Z_0-9]*}}/).map { Regexp.last_match }.reverse
|
11
12
|
match_data_list&.each do |md|
|
@@ -22,13 +23,13 @@ class LiquidVariableParsing
|
|
22
23
|
result
|
23
24
|
end
|
24
25
|
|
25
|
-
RSpec.describe JekyllPluginHelper do
|
26
|
+
RSpec.describe ::JekyllSupport::JekyllPluginHelper do
|
26
27
|
it 'substitutes variable references for values without recursion' do
|
27
28
|
scopes = [{ 'a' => '{{', 'b' => 'asdf', 'c' => '}}' }]
|
28
29
|
str = '{{a}}{{b}}{{c}} This should be unchanged: {{d}}'
|
29
|
-
new_str = variable_replace(str, scopes)
|
30
|
+
new_str = LiquidVariableParsing.variable_replace(str, scopes)
|
30
31
|
expect(str).to start_with('{{a}}')
|
31
|
-
expect(new_str).to
|
32
|
+
expect(new_str).to eq('{{asdf}} This should be unchanged: {{d}}')
|
32
33
|
end
|
33
34
|
end
|
34
35
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../lib/hooks/all_files'
|
3
|
+
|
4
|
+
def build_msbs(sorted_strings)
|
5
|
+
sorted_strings.each do |string|
|
6
|
+
$msbs.insert LruFile.new(string.reverse, "Page #{string}") # { |x| x.url.start_with? string }
|
7
|
+
end
|
8
|
+
$msbs.enable_search
|
9
|
+
end
|
10
|
+
|
11
|
+
RSpec.describe(MSlinnBinarySearch) do
|
12
|
+
$msbs = described_class.new [:url, %i[start_with? placeholder]]
|
13
|
+
build_msbs %w[aaa.html baa.html caa.html bbb.html cbb.html dbb.html ccc.html ccd.html cce.html]
|
14
|
+
|
15
|
+
it 'handles an empty search string by returning the index of the first item (0)' do
|
16
|
+
index = $msbs.find_index '' # { |x| x.url.start_with? '' }
|
17
|
+
expect(index).to be_zero
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'returns the index of the first partial match' do
|
21
|
+
index = $msbs.find_index 'a.html' # { |x| x.url.start_with? 'a.html' }
|
22
|
+
expect(index).to eq(0)
|
23
|
+
|
24
|
+
index = $msbs.find_index 'baa.html' # { |x| x.url.start_with? 'baa.html' }
|
25
|
+
expect(index).to eq(1)
|
26
|
+
|
27
|
+
index = $msbs.find_index 'c.html' # { |x| x.url.start_with? 'c.html' }
|
28
|
+
expect(index).to eq(6)
|
29
|
+
|
30
|
+
index = $msbs.find_index 'cce.html' # { |x| x.url.start_with? 'cce.html' }
|
31
|
+
expect(index).to eq(8)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'returns the item of the first match' do
|
35
|
+
item = $msbs.find 'a.html' # { |x| x.url.start_with? 'a.html' }
|
36
|
+
expect(item.url.reverse).to eq('aaa.html')
|
37
|
+
|
38
|
+
item = $msbs.find 'baa.html' # { |x| x.url.start_with? 'baa.html' }
|
39
|
+
expect(item.url.reverse).to eq('baa.html')
|
40
|
+
|
41
|
+
item = $msbs.find 'c.html' # { |x| x.url.start_with? 'c.html' }
|
42
|
+
expect(item.url.reverse).to eq('ccc.html')
|
43
|
+
|
44
|
+
item = $msbs.find 'cce.html' # { |x| x.url.start_with? 'cce.html' }
|
45
|
+
expect(item.url.reverse).to eq('cce.html')
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../lib/util/send_chain'
|
3
|
+
|
4
|
+
unless defined? LruFile
|
5
|
+
LruFile = Struct.new(:url, :page) do
|
6
|
+
include SendChain
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
RSpec.describe(LruFile) do
|
11
|
+
lru_file = described_class.new 'abc', 'def'
|
12
|
+
|
13
|
+
it 'can perform a simple call if no arguments are required' do
|
14
|
+
# Equivalent to: lru_file.url.reverse
|
15
|
+
actual = lru_file.send_chain %i[url reverse]
|
16
|
+
expect(actual).to eq('cba')
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'can accept a scalar argument in stages' do
|
20
|
+
lru_file.new_chain [:url, %i[end_with? placeholder]]
|
21
|
+
# Equivalent to: lru_file.url.end_with?('bc')
|
22
|
+
substituted_chain = lru_file.substitute_chain_with 'bc'
|
23
|
+
actual = lru_file.send_chain substituted_chain
|
24
|
+
expect(actual).to be true
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'can accept a vector argument in stages' do
|
28
|
+
lru_file.new_chain [:url, %i[end_with? placeholder]]
|
29
|
+
# Next 2 lines are equivalent to: lru_file.url.end_with?('bc')
|
30
|
+
substituted_chain = lru_file.substitute_chain_with ['bc']
|
31
|
+
actual = lru_file.send_chain substituted_chain
|
32
|
+
expect(actual).to be true
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'can accept a scalar argument in one stage' do
|
36
|
+
lru_file.new_chain [:url, %i[end_with? placeholder]]
|
37
|
+
# Equivalent to: lru_file.url.end_with?('bc')
|
38
|
+
actual = lru_file.substitute_and_send_chain_with 'bc'
|
39
|
+
expect(actual).to be true
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'can accept an array argument in one stage' do
|
43
|
+
lru_file.new_chain [:url, %i[end_with? placeholder]]
|
44
|
+
# Equivalent to: lru_file.url.end_with?('bc')
|
45
|
+
actual = lru_file.substitute_and_send_chain_with ['bc']
|
46
|
+
expect(actual).to be true
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'can use the evaluate_with alias' do
|
50
|
+
lru_file.new_chain [:url, %i[end_with? placeholder]]
|
51
|
+
# Equivalent to: lru_file.url.end_with?('bc')
|
52
|
+
actual = lru_file.evaluate_with ['bc']
|
53
|
+
expect(actual).to be true
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'can reuse the chain with different values' do
|
57
|
+
lru_file.new_chain [:url, %i[end_with? placeholder]]
|
58
|
+
|
59
|
+
# Equivalent to: lru_file.url.end_with?('bc')
|
60
|
+
actual = lru_file.substitute_and_send_chain_with 'bc'
|
61
|
+
expect(actual).to be true
|
62
|
+
|
63
|
+
# Equivalent to: lru_file.url.end_with?('abc')
|
64
|
+
substituted_chain = lru_file.substitute_chain_with ['abc']
|
65
|
+
actual = lru_file.send_chain substituted_chain
|
66
|
+
expect(actual).to be true
|
67
|
+
|
68
|
+
# Equivalent to: lru_file.url.end_with?('de')
|
69
|
+
actual = lru_file.substitute_and_send_chain_with 'de'
|
70
|
+
expect(actual).to be false
|
71
|
+
end
|
72
|
+
end
|
data/spec/send_spec.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Exploring how to set date attributes in an object
|
4
|
+
|
5
|
+
class Obj
|
6
|
+
# `last_modified` is primary sort key
|
7
|
+
# `date` (when specified) is secondary sort key
|
8
|
+
attr_reader :date, :last_modified
|
9
|
+
|
10
|
+
def initialize(param1, param2)
|
11
|
+
@last_modified = Date.parse(param1)
|
12
|
+
@date = Date.parse(param2)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
RSpec.describe(Obj) do
|
17
|
+
let(:obj) { described_class.new('2000-01-01', '2001-01-01') }
|
18
|
+
|
19
|
+
it 'can send date' do
|
20
|
+
date = obj.send :date
|
21
|
+
expect(obj.date).to eq(date)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'can send last_modified' do
|
25
|
+
last_modified = obj.send :last_modified
|
26
|
+
expect(obj.last_modified).to eq(last_modified)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../lib/hooks/all_files'
|
3
|
+
|
4
|
+
RSpec.describe(SortedLruFiles) do
|
5
|
+
expected1 = 'first-page.html'
|
6
|
+
expected2 = 'second-page.html'
|
7
|
+
expected3 = 'third-page.html'
|
8
|
+
|
9
|
+
it 'can read back an inserted item' do
|
10
|
+
sorted_files = described_class.new
|
11
|
+
sorted_files.insert(expected1, "https://mslinn.com/#{expected1}") # insert reverses expected1
|
12
|
+
sorted_files.enable_search
|
13
|
+
|
14
|
+
actual = sorted_files.select expected1
|
15
|
+
expect(actual.length).to eq(1)
|
16
|
+
expect(actual.first&.reverse&.start_with?(expected1.reverse)).to be true
|
17
|
+
|
18
|
+
actual = sorted_files.select expected1[5..]
|
19
|
+
expect(actual.length).to eq(1)
|
20
|
+
expect(actual.first&.reverse&.start_with?(expected1[5..].reverse)).to be true
|
21
|
+
|
22
|
+
actual = sorted_files.select 'should_not_match'
|
23
|
+
expect(actual).to be_empty
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'works with 2 items and one match' do
|
27
|
+
sorted_files = described_class.new
|
28
|
+
sorted_files.insert(expected1, "https://mslinn.com/#{expected1}") # insert reverses expected1
|
29
|
+
sorted_files.insert(expected2, "https://mslinn.com/#{expected2}")
|
30
|
+
sorted_files.enable_search
|
31
|
+
|
32
|
+
expect(sorted_files.msbs.array[0].url).to be <= sorted_files.msbs.array[1].url
|
33
|
+
|
34
|
+
actual = sorted_files.select expected1
|
35
|
+
expect(actual.length).to eq(1)
|
36
|
+
expect(actual.first&.end_with?(expected1)).to be true
|
37
|
+
|
38
|
+
actual = sorted_files.select expected2
|
39
|
+
expect(actual.length).to eq(1)
|
40
|
+
expect(actual.first&.end_with?(expected2)).to be true
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'handles multiple matches' do
|
44
|
+
sorted_files = described_class.new
|
45
|
+
sorted_files.insert(expected1, "https://mslinn.com/#{expected1}") # insert reverses expected1
|
46
|
+
sorted_files.insert(expected2, "https://mslinn.com/#{expected2}")
|
47
|
+
sorted_files.enable_search
|
48
|
+
|
49
|
+
expected = '.html'
|
50
|
+
actual = sorted_files.select expected
|
51
|
+
expect(actual.length).to eq(2)
|
52
|
+
expect(actual.first&.end_with?(expected)).to be true
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'works with 3 items' do
|
56
|
+
sorted_files = described_class.new
|
57
|
+
sorted_files.insert(expected1, "https://mslinn.com/#{expected1}") # insert reverses expected1
|
58
|
+
sorted_files.insert(expected2, "https://mslinn.com/#{expected2}")
|
59
|
+
sorted_files.insert(expected3, "https://mslinn.com/#{expected3}")
|
60
|
+
sorted_files.enable_search
|
61
|
+
|
62
|
+
expect(sorted_files.msbs.array[0].url).to be <= sorted_files.msbs.array[1].url
|
63
|
+
expect(sorted_files.msbs.array[1].url).to be <= sorted_files.msbs.array[2].url
|
64
|
+
|
65
|
+
actual = sorted_files.select expected1
|
66
|
+
expect(actual.length).to eq(1)
|
67
|
+
expect(actual.first&.end_with?(expected1)).to be true
|
68
|
+
|
69
|
+
actual = sorted_files.select expected2
|
70
|
+
expect(actual.length).to eq(1)
|
71
|
+
expect(actual.first&.end_with?(expected2)).to be true
|
72
|
+
|
73
|
+
actual = sorted_files.select expected3
|
74
|
+
expect(actual.length).to eq(1)
|
75
|
+
expect(actual.first&.end_with?(expected3)).to be true
|
76
|
+
|
77
|
+
expected = '.html'
|
78
|
+
actual = sorted_files.select expected
|
79
|
+
expect(actual.length).to eq(3)
|
80
|
+
expect(actual.first&.end_with?(expected)).to be true
|
81
|
+
end
|
82
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,22 @@
|
|
1
1
|
require 'jekyll'
|
2
2
|
require_relative '../lib/jekyll_plugin_support'
|
3
3
|
|
4
|
-
|
5
|
-
config.filter_run_when_matching focus: true
|
6
|
-
# config.order = 'random'
|
4
|
+
Jekyll.logger.log_level = :info
|
7
5
|
|
6
|
+
RSpec.configure do |config|
|
8
7
|
# See https://relishapp.com/rspec/rspec-core/docs/command-line/only-failures
|
9
8
|
config.example_status_persistence_file_path = 'spec/status_persistence.txt'
|
9
|
+
|
10
|
+
# See https://rspec.info/features/3-12/rspec-core/filtering/filter-run-when-matching/
|
11
|
+
# and https://github.com/rspec/rspec/issues/221
|
12
|
+
config.filter_run_when_matching :focus
|
13
|
+
|
14
|
+
# Other values: :progress, :html, :json, CustomFormatterClass
|
15
|
+
config.formatter = :documentation
|
16
|
+
|
17
|
+
# See https://rspec.info/features/3-12/rspec-core/command-line/order/
|
18
|
+
config.order = :defined
|
19
|
+
|
20
|
+
# See https://www.rubydoc.info/github/rspec/rspec-core/RSpec%2FCore%2FConfiguration:pending_failure_output
|
21
|
+
config.pending_failure_output = :skip
|
10
22
|
end
|
data/spec/status_persistence.txt
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
example_id | status | run_time |
|
2
2
|
------------------------------------------------ | ------ | --------------- |
|
3
|
-
./spec/
|
4
|
-
./spec/
|
5
|
-
./spec/jekyll_plugin_helper_options_spec.rb[1:
|
6
|
-
./spec/jekyll_plugin_helper_options_spec.rb[1:
|
7
|
-
./spec/jekyll_plugin_helper_options_spec.rb[1:3] | failed | 0.00003 seconds |
|
8
|
-
./spec/jekyll_plugin_helper_options_spec.rb[1:4] | failed | 0.00003 seconds |
|
9
|
-
./spec/liquid_variable_parsing_spec.rb[1:1] | failed | 0.00003 seconds |
|
3
|
+
./spec/jekyll_plugin_helper_options_spec.rb[1:1] | passed | 0.00559 seconds |
|
4
|
+
./spec/jekyll_plugin_helper_options_spec.rb[1:2] | passed | 0.00583 seconds |
|
5
|
+
./spec/jekyll_plugin_helper_options_spec.rb[1:3] | passed | 0.00543 seconds |
|
6
|
+
./spec/jekyll_plugin_helper_options_spec.rb[1:4] | passed | 0.00157 seconds |
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Exploring how to invoke methods from classes and modules
|
4
|
+
# See https://mslinn.com/jekyll/10700-designing-for-testability.html
|
5
|
+
|
6
|
+
module TestModule
|
7
|
+
def a_method
|
8
|
+
'a_method says Hi!'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
RSpec.describe(TestModule) do
|
13
|
+
extend described_class
|
14
|
+
|
15
|
+
it 'Invokes a_method from module' do
|
16
|
+
result = self.class.a_method
|
17
|
+
expect(result).to eq('a_method says Hi!')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class TestClass
|
22
|
+
extend TestModule # Defines class methods
|
23
|
+
|
24
|
+
def initialize(param1, param2)
|
25
|
+
super()
|
26
|
+
@param1 = param1
|
27
|
+
@param2 = param2
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
RSpec.describe(TestClass) do
|
32
|
+
let(:o1) { described_class.new('value1', 'value2') }
|
33
|
+
|
34
|
+
it 'Invokes a_method from class' do
|
35
|
+
result = o1.class.a_method
|
36
|
+
expect(result).to eq('a_method says Hi!')
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll_plugin_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Slinn
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: bigdecimal
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
12
26
|
- !ruby/object:Gem::Dependency
|
13
27
|
name: facets
|
14
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -29,14 +43,14 @@ dependencies:
|
|
29
43
|
requirements:
|
30
44
|
- - ">="
|
31
45
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
46
|
+
version: 4.4.1
|
33
47
|
type: :runtime
|
34
48
|
prerelease: false
|
35
49
|
version_requirements: !ruby/object:Gem::Requirement
|
36
50
|
requirements:
|
37
51
|
- - ">="
|
38
52
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
53
|
+
version: 4.4.1
|
40
54
|
- !ruby/object:Gem::Dependency
|
41
55
|
name: jekyll_plugin_logger
|
42
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -79,6 +93,20 @@ dependencies:
|
|
79
93
|
- - ">="
|
80
94
|
- !ruby/object:Gem::Version
|
81
95
|
version: '0'
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: sorted_set
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
82
110
|
email:
|
83
111
|
- mslinn@mslinn.com
|
84
112
|
executables: []
|
@@ -100,17 +128,32 @@ files:
|
|
100
128
|
- lib/helper/jekyll_plugin_helper.rb
|
101
129
|
- lib/helper/jekyll_plugin_helper_attribution.rb
|
102
130
|
- lib/helper/jekyll_plugin_helper_class.rb
|
131
|
+
- lib/hooks/a_page.rb
|
132
|
+
- lib/hooks/all_collections_hooks.rb
|
133
|
+
- lib/hooks/all_files.rb
|
134
|
+
- lib/hooks/class_methods.rb
|
135
|
+
- lib/jekyll_all_collections/all_collections_tag.rb
|
103
136
|
- lib/jekyll_plugin_support.rb
|
104
137
|
- lib/jekyll_plugin_support/jekyll_plugin_support_class.rb
|
105
138
|
- lib/jekyll_plugin_support/jekyll_plugin_support_spec_support.rb
|
106
139
|
- lib/jekyll_plugin_support/version.rb
|
107
140
|
- lib/tag/jekyll_plugin_support_tag.rb
|
108
141
|
- lib/tag/jekyll_plugin_support_tag_noarg.rb
|
142
|
+
- lib/util/mslinn_binary_search.rb
|
143
|
+
- lib/util/send_chain.rb
|
144
|
+
- spec/all_collections_tag/all_collections_tag_sort_spec.rb
|
145
|
+
- spec/bsearch_spec.rb
|
109
146
|
- spec/custom_error_spec.rb
|
147
|
+
- spec/date_sort_spec.rb
|
110
148
|
- spec/jekyll_plugin_helper_options_spec.rb
|
111
149
|
- spec/liquid_variable_parsing_spec.rb
|
150
|
+
- spec/mslinn_binary_search_spec.rb
|
151
|
+
- spec/send_chain_spec.rb
|
152
|
+
- spec/send_spec.rb
|
153
|
+
- spec/sorted_lru_files_spec.rb
|
112
154
|
- spec/spec_helper.rb
|
113
155
|
- spec/status_persistence.txt
|
156
|
+
- spec/testable_spec.rb
|
114
157
|
homepage: https://www.mslinn.com/jekyll_plugins/jekyll_plugin_support.html
|
115
158
|
licenses:
|
116
159
|
- MIT
|
@@ -138,13 +181,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
181
|
- !ruby/object:Gem::Version
|
139
182
|
version: '0'
|
140
183
|
requirements: []
|
141
|
-
rubygems_version: 3.6.
|
184
|
+
rubygems_version: 3.6.9
|
142
185
|
specification_version: 4
|
143
186
|
summary: Provides a framework for writing and testing Jekyll plugins
|
144
187
|
test_files:
|
188
|
+
- spec/all_collections_tag/all_collections_tag_sort_spec.rb
|
189
|
+
- spec/bsearch_spec.rb
|
145
190
|
- spec/custom_error_spec.rb
|
191
|
+
- spec/date_sort_spec.rb
|
146
192
|
- spec/jekyll_plugin_helper_options_spec.rb
|
147
193
|
- spec/liquid_variable_parsing_spec.rb
|
194
|
+
- spec/mslinn_binary_search_spec.rb
|
195
|
+
- spec/send_chain_spec.rb
|
196
|
+
- spec/send_spec.rb
|
197
|
+
- spec/sorted_lru_files_spec.rb
|
148
198
|
- spec/spec_helper.rb
|
149
199
|
- spec/status_persistence.txt
|
200
|
+
- spec/testable_spec.rb
|
150
201
|
...
|