jekyll-code-example-tag 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +4 -0
- data/jekyll-code-example-tag.gemspec +1 -1
- data/lib/jekyll-code-example-tag.rb +1 -1
- data/spec/all_page_code_examples_spec.rb +3 -17
- data/spec/code_example_spec.rb +10 -19
- data/spec/spec_helper.rb +6 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 313440e34ab23b1fc7dbf0f74007afac212cf8d6
|
4
|
+
data.tar.gz: 1000fa7315fecf654b1b691c3675d0a9ee45f915
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03cfaf2a1f6389da446bbb38a2001242d77199e80ffc15f51a519c49736de856f5d9952d185bfc9b995007daa193f69c958d08230e0ff7f41ab76a646852b087
|
7
|
+
data.tar.gz: db4d25d8a1c4e354e89656d0c0f9658a920794ea1b40fdaab2e29a3e7f3cea19cc3fc7ad5abc80722d53cca7a08e1c1c7dd5e69068d307f623a63c64048ad4d8
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -55,6 +55,9 @@ GEM
|
|
55
55
|
rb-inotify (>= 0.9)
|
56
56
|
mercenary (0.3.5)
|
57
57
|
method_source (0.8.2)
|
58
|
+
mini_portile (0.6.2)
|
59
|
+
nokogiri (1.6.6.2)
|
60
|
+
mini_portile (~> 0.6.0)
|
58
61
|
parslet (1.5.0)
|
59
62
|
blankslate (~> 2.0)
|
60
63
|
posix-spawn (0.3.9)
|
@@ -97,5 +100,6 @@ PLATFORMS
|
|
97
100
|
DEPENDENCIES
|
98
101
|
fakefs
|
99
102
|
jekyll-code-example-tag!
|
103
|
+
nokogiri
|
100
104
|
pry
|
101
105
|
rspec
|
@@ -45,7 +45,7 @@ EOF
|
|
45
45
|
def self.example_markup(language, content)
|
46
46
|
<<EOF
|
47
47
|
<div class="highlight example #{language}">
|
48
|
-
<pre><code class="language
|
48
|
+
<pre><code class="language #{language}" data-lang="#{language}">#{content}</code></pre>
|
49
49
|
</div>
|
50
50
|
EOF
|
51
51
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require_relative './spec_helper.rb'
|
2
|
+
require 'pry'
|
2
3
|
|
3
4
|
describe 'all_page_code_examples', fakefs: true do
|
4
5
|
|
5
|
-
# TODO: Make this soo much better
|
6
6
|
let(:page) do
|
7
7
|
page = <<EOF
|
8
8
|
{% code_example hello_world %}
|
@@ -11,21 +11,6 @@ describe 'all_page_code_examples', fakefs: true do
|
|
11
11
|
EOF
|
12
12
|
end
|
13
13
|
|
14
|
-
let(:page_markup) do
|
15
|
-
page_markup = <<EOF
|
16
|
-
<div class='code-examples'> <div class="buttons examples">
|
17
|
-
<ul>
|
18
|
-
<li><a href='#' class='button' target='python'>Python</a></li>
|
19
|
-
</ul>
|
20
|
-
</div>
|
21
|
-
<div class="highlight example python">
|
22
|
-
<pre><code class="language-python" data-lang="python">print "Hello World"print "Goodbye World"</code></pre>
|
23
|
-
</div>
|
24
|
-
</div>
|
25
|
-
EOF
|
26
|
-
page_markup.rstrip
|
27
|
-
end
|
28
|
-
|
29
14
|
before(:all) do
|
30
15
|
FakeFS.activate!
|
31
16
|
FileUtils.mkdir_p('code_examples/python')
|
@@ -40,6 +25,7 @@ EOF
|
|
40
25
|
it 'can be used' do
|
41
26
|
t = Liquid::Template.parse(page)
|
42
27
|
o = t.render!({'site' => {}, 'page' => {'content' => page}})
|
43
|
-
|
28
|
+
o_html = Nokogiri::HTML.parse(o)
|
29
|
+
expect(o_html.search("[text()*='print \"Hello World\"print \"Goodbye World\"']")).not_to be_empty
|
44
30
|
end
|
45
31
|
end
|
data/spec/code_example_spec.rb
CHANGED
@@ -2,28 +2,11 @@ require_relative './spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe 'code_example', fakefs: true do
|
4
4
|
|
5
|
-
# TODO: Make this soo much better
|
6
5
|
let(:page) { "{% code_example hello_world %}" }
|
7
|
-
let(:page_markup) do
|
8
|
-
page_markup = <<EOF
|
9
|
-
<div class='code-examples'> <div class="buttons examples">
|
10
|
-
<ul>
|
11
|
-
<li><a href='#' class='button' target='ruby'>Ruby</a></li><li><a href='#' class='button' target='python'>Python</a></li>
|
12
|
-
</ul>
|
13
|
-
</div>
|
14
|
-
<div class="highlight example ruby">
|
15
|
-
<pre><code class="language-ruby" data-lang="ruby">puts "Hello World"</code></pre>
|
16
|
-
</div>
|
17
|
-
<div class="highlight example python">
|
18
|
-
<pre><code class="language-python" data-lang="python">print "Hello World"</code></pre>
|
19
|
-
</div>
|
20
|
-
</div>
|
21
|
-
EOF
|
22
|
-
page_markup.rstrip
|
23
|
-
end
|
24
6
|
|
25
7
|
before(:all) do
|
26
8
|
FakeFS.activate!
|
9
|
+
|
27
10
|
FileUtils.mkdir_p('code_examples/ruby')
|
28
11
|
FileUtils.mkdir_p('code_examples/python')
|
29
12
|
File.open('code_examples/ruby/hello_world', 'w') { |f| f << 'puts "Hello World"'}
|
@@ -37,6 +20,14 @@ EOF
|
|
37
20
|
it 'can be used' do
|
38
21
|
t = Liquid::Template.parse(page)
|
39
22
|
o = t.render!({'site' => {}})
|
40
|
-
|
23
|
+
o_obj = Nokogiri::XML.parse(o)
|
24
|
+
expect(o_obj.xpath('/div[@class="code-examples"]/div[@class="buttons examples"]/ul/li/a[@class="button"][@target="ruby"][.="Ruby"]')).not_to be_empty
|
25
|
+
expect(o_obj.xpath('/div[@class="code-examples"]/div[@class="buttons examples"]/ul/li/a[@class="button"][@target="python"][.="Python"]')).not_to be_empty
|
26
|
+
ruby_example = o_obj.xpath('/div[@class="code-examples"]/div[@class="highlight example ruby"]/pre/code[@class="language ruby"][@data-lang="ruby"]')
|
27
|
+
expect(ruby_example).not_to be_empty
|
28
|
+
expect(ruby_example.first.content).to eq 'puts "Hello World"'
|
29
|
+
python_example = o_obj.xpath('/div[@class="code-examples"]/div[@class="highlight example python"]/pre/code[@class="language python"][@data-lang="python"]')
|
30
|
+
expect(python_example).not_to be_empty
|
31
|
+
expect(python_example.first.content).to eq 'print "Hello World"'
|
41
32
|
end
|
42
33
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
|
+
require 'fakefs/spec_helpers'
|
1
2
|
require 'jekyll'
|
2
3
|
require 'liquid'
|
4
|
+
require 'nokogiri'
|
5
|
+
require 'pry'
|
3
6
|
require 'rspec'
|
4
|
-
require 'fakefs/spec_helpers'
|
5
7
|
require_relative '../lib/jekyll-code-example-tag.rb'
|
6
8
|
|
7
9
|
RSpec.configure do |config|
|
8
10
|
config.include FakeFS::SpecHelpers, fakefs: true
|
9
11
|
end
|
12
|
+
|
13
|
+
Pry.config.history.should_save = false;
|
14
|
+
Pry.config.history.should_load = false;
|