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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 271a0085affcfa80d82b34157ff70007cbda6db5
4
- data.tar.gz: adb5ee89ce47a1a63981d7dfc7a2f39b18de72e7
3
+ metadata.gz: 313440e34ab23b1fc7dbf0f74007afac212cf8d6
4
+ data.tar.gz: 1000fa7315fecf654b1b691c3675d0a9ee45f915
5
5
  SHA512:
6
- metadata.gz: f6a5c56e9af55ef23b5c36557fd52bd046069848c6b3933b4c32346a44da47245ec7b8856e7b5e8dfc8069af70800cffa85e70317db1793f61d513a4e0657b2e
7
- data.tar.gz: dbbe4a7bc8f2bd7d46440c0031781db957818a9a10885a9f582466e0952b942e18b5ee0822621bb532ce75387ef6d4aa376e56c1b4b8dcfa62b54f98f1ac903e
6
+ metadata.gz: 03cfaf2a1f6389da446bbb38a2001242d77199e80ffc15f51a519c49736de856f5d9952d185bfc9b995007daa193f69c958d08230e0ff7f41ab76a646852b087
7
+ data.tar.gz: db4d25d8a1c4e354e89656d0c0f9658a920794ea1b40fdaab2e29a3e7f3cea19cc3fc7ad5abc80722d53cca7a08e1c1c7dd5e69068d307f623a63c64048ad4d8
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ gemspec
5
5
 
6
6
  group :test do
7
7
  gem "fakefs", require: "fakefs/safe"
8
+ gem 'nokogiri'
8
9
  gem 'pry'
9
10
  gem 'rspec'
10
11
  end
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'jekyll-code-example-tag'
3
- s.version = '0.0.3'
3
+ s.version = '0.0.4'
4
4
  s.date = '2015-02-03'
5
5
  s.authors = ['GovDelivery']
6
6
  s.email = 'support@govdelivery.com'
@@ -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-#{language}" data-lang="#{language}">#{content}</code></pre>
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
- expect(o).to include(page_markup)
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
@@ -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
- expect(o).to eq(page_markup)
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;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-code-example-tag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - GovDelivery