diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..250186b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+spec/coverage
diff --git a/.rspec b/.rspec
index 5052887..9ae52ee 100644
--- a/.rspec
+++ b/.rspec
@@ -1 +1,3 @@
---color
\ No newline at end of file
+--colour
+--require spec_helper
+--profile
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..4fda8bd
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,6 @@
+# frozen_string_literal: true
+
+source "https://rubygems.org"
+
+gemspec
+git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
diff --git a/Gemfile.lock b/Gemfile.lock
new file mode 100644
index 0000000..5b44601
--- /dev/null
+++ b/Gemfile.lock
@@ -0,0 +1,60 @@
+PATH
+ remote: .
+ specs:
+ html2confluence (1.3.23)
+ nokogiri
+
+GEM
+ remote: https://rubygems.org/
+ specs:
+ ast (2.4.0)
+ diff-lcs (1.3)
+ docile (1.3.1)
+ json (2.1.0)
+ mini_portile2 (2.3.0)
+ nokogiri (1.8.5)
+ mini_portile2 (~> 2.3.0)
+ parallel (1.12.1)
+ parser (2.5.1.2)
+ ast (~> 2.4.0)
+ powerpack (0.1.2)
+ rainbow (3.0.0)
+ rspec (3.8.0)
+ rspec-core (~> 3.8.0)
+ rspec-expectations (~> 3.8.0)
+ rspec-mocks (~> 3.8.0)
+ rspec-core (3.8.0)
+ rspec-support (~> 3.8.0)
+ rspec-expectations (3.8.2)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.8.0)
+ rspec-mocks (3.8.0)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.8.0)
+ rspec-support (3.8.0)
+ rubocop (0.55.0)
+ parallel (~> 1.10)
+ parser (>= 2.5)
+ powerpack (~> 0.1)
+ rainbow (>= 2.2.2, < 4.0)
+ ruby-progressbar (~> 1.7)
+ unicode-display_width (~> 1.0, >= 1.0.1)
+ ruby-progressbar (1.10.0)
+ simplecov (0.16.1)
+ docile (~> 1.1)
+ json (>= 1.8, < 3)
+ simplecov-html (~> 0.10.0)
+ simplecov-html (0.10.2)
+ unicode-display_width (1.4.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ html2confluence!
+ rspec
+ rubocop (< 0.56)
+ simplecov
+
+BUNDLED WITH
+ 1.16.6
diff --git a/html2confluence.gemspec b/html2confluence.gemspec
index 2608c18..d4c7093 100644
--- a/html2confluence.gemspec
+++ b/html2confluence.gemspec
@@ -15,4 +15,7 @@ Gem::Specification.new do |s|
s.files = Dir.glob("{lib,spec}/**/*") + %w(example.rb README.mdown)
s.add_dependency "nokogiri"
+ s.add_development_dependency "rspec"
+ s.add_development_dependency "rubocop", "< 0.56"
+ s.add_development_dependency "simplecov"
end
diff --git a/spec/combination_examples_spec.rb b/spec/combination_examples_spec.rb
index f1ef51e..a6ba0c2 100644
--- a/spec/combination_examples_spec.rb
+++ b/spec/combination_examples_spec.rb
@@ -1,8 +1,7 @@
# encoding: utf-8
-$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
-require 'html2confluence'
describe HTMLToConfluenceParser, "when running combination examples" do
+ let(:parser) { HTMLToConfluenceParser.new }
it "should match complex examples" do
html = <<-END
@@ -20,7 +19,6 @@
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to include(markup.strip)
end
@@ -95,7 +93,6 @@
h1. With +nice+ formatting.
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to include(markup.strip)
end
@@ -106,10 +103,9 @@
END
markup = <<-END
-{quote}\nbq. content here\n{quote}
+{quote}\ncontent here\n{quote}
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to include(markup.strip)
end
@@ -122,7 +118,6 @@
markup = "Previous\n\n*Scenario 4a: Existing deletes their ID*\n*Given* I am an existing user"
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to eq(markup)
end
@@ -136,7 +131,6 @@
markup = "Previous line\n\n*Scenario 4a: Existing deletes their ID*\n*Given* I am an existing user"
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to eq(markup)
end
@@ -146,7 +140,6 @@
markup = "*And* first line\n\n*second line*"
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to eq(markup)
end
@@ -156,7 +149,6 @@
markup = "!a source!"
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to eq(markup)
end
@@ -165,7 +157,6 @@
html = "
familiar with the XMLHttpRequest Object
\n\n"
markup = "familiar with the XMLHttpRequest Object"
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to eq(markup)
@@ -179,7 +170,6 @@
markup = "Previous line\n\n----"
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to eq(markup)
end
@@ -191,7 +181,6 @@
markup = "A"
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to eq(markup)
end
@@ -204,7 +193,6 @@
markup = "A"
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to eq(markup)
end
diff --git a/spec/complex_tables_spec.rb b/spec/complex_tables_spec.rb
index 1c8fa12..6ee5cc8 100644
--- a/spec/complex_tables_spec.rb
+++ b/spec/complex_tables_spec.rb
@@ -1,8 +1,7 @@
# encoding: utf-8
-$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
-require 'html2confluence'
describe HTMLToConfluenceParser, "when running complex tables examples" do
+ let(:parser) { HTMLToConfluenceParser.new }
it "should handle table with newlines" do
html = <<-END
@@ -21,7 +20,6 @@
* Good for my teeth|
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to include(markup.strip)
end
@@ -35,7 +33,6 @@
| |Empty| |
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to include(markup.strip)
end
@@ -52,7 +49,6 @@
b{noformat} |c |
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to include(markup.strip)
end
@@ -79,7 +75,6 @@
2{noformat} |3 |
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to include(markup.strip)
end
diff --git a/spec/html2confluence_spec.rb b/spec/html2confluence_spec.rb
index 027f194..3debf37 100644
--- a/spec/html2confluence_spec.rb
+++ b/spec/html2confluence_spec.rb
@@ -1,10 +1,10 @@
# encoding: utf-8
-$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
-require 'html2confluence'
describe HTMLToConfluenceParser, "when converting html to textile" do
+ let(:parser) { HTMLToConfluenceParser.new }
+
context "in a large html document" do
- before :all do
+ before do
html = <<-END
@@ -126,7 +126,6 @@
|Not table
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
@textile = parser.to_wiki_markup
end
@@ -265,7 +264,6 @@
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
@textile = parser.to_wiki_markup
@@ -284,7 +282,6 @@
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
@textile = parser.to_wiki_markup
@@ -303,7 +300,6 @@
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
@textile = parser.to_wiki_markup
diff --git a/spec/jira_examples_spec.rb b/spec/jira_examples_spec.rb
index 3310541..9f06c6c 100644
--- a/spec/jira_examples_spec.rb
+++ b/spec/jira_examples_spec.rb
@@ -1,11 +1,30 @@
# encoding: utf-8
-$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
-require 'html2confluence'
describe HTMLToConfluenceParser, "when running JIRA examples" do
+ let(:parser) { HTMLToConfluenceParser.new }
- before :all do
- html = <<-END
+ it "should convert images within a link" do
+ imagetarget = "https://example.com/image.jpg"
+ link = "https://example.com/index.html"
+ test_html = %{
+
+
+
+
+
+ }
+
+ parser.feed test_html
+ @textile = parser.to_wiki_markup
+
+ expect(@textile).to eq("[!#{imagetarget}!|#{link}]")
+ end
+
+ context "with large document" do
+ before do
+ html = <<-END
Biggest heading
Bigger heading
Big heading
@@ -129,9 +148,9 @@
so *no* further _formatting_ is done here
- END
+ END
- markup = <<-END
+ markup = <<-END
h1. Biggest heading
h2. Bigger heading
h3. Big heading
@@ -213,104 +232,82 @@
preformatted piece of text
so *no* further _formatting_ is done here
{noformat}
- END
+ END
+ parser.feed(html)
+ @textile = parser.to_wiki_markup
+ #puts @textile
+ #puts RedCloth.new(@textile).to_html
+ end
+
+ it "should convert heading tags" do
+ expect(@textile).to match(/^h1. Biggest heading/)
+ expect(@textile).to match(/^h2. Bigger heading/)
+ expect(@textile).to match(/^h3. Big heading/)
+ expect(@textile).to match(/^h4. Normal heading/)
+ expect(@textile).to match(/^h5. Small heading/)
+ expect(@textile).to match(/^h6. Smallest heading/)
+ end
- parser = HTMLToConfluenceParser.new
- parser.feed(html)
- @textile = parser.to_wiki_markup
- #puts @textile
- #puts RedCloth.new(@textile).to_html
- end
-
- it "should convert images within a link" do
- imagetarget = "https://example.com/image.jpg"
- link = "https://example.com/index.html"
- test_html = %{
-
-
-
-
-
- }
-
- parser = HTMLToConfluenceParser.new
- parser.feed test_html
- @textile = parser.to_wiki_markup
-
- expect(@textile).to eq("[!#{imagetarget}!|#{link}]")
- end
-
- it "should convert heading tags" do
- expect(@textile).to match(/^h1. Biggest heading/)
- expect(@textile).to match(/^h2. Bigger heading/)
- expect(@textile).to match(/^h3. Big heading/)
- expect(@textile).to match(/^h4. Normal heading/)
- expect(@textile).to match(/^h5. Small heading/)
- expect(@textile).to match(/^h6. Smallest heading/)
- end
-
- it "should convert inline formatting" do
- expect(@textile).to match(/^\*strong\*/)
- expect(@textile).to match(/^_emphasis_/)
- expect(@textile).to match(/^\?\?citation\?\?/)
- expect(@textile).to match(/^-deleted-/)
- expect(@textile).to match(/^\+inserted\+/)
- expect(@textile).to match(/^\^superscript\^/)
- expect(@textile).to match(/^\~subscript\~/)
- expect(@textile).to match(/^\{\{monospaced\}\}/)
- end
-
- it "should convert block quotes" do
- expect(@textile).to match(/^bq. Some block quoted text/)
- expect(@textile).to match(/^\{quote\}\s*here is quotable\s*content to be quoted\s*{quote}/)
- end
-
- it "should handle text color" do
- expect(@textile).to match(/^\{color\:red\}\s*look ma, red text!\s*\{color\}/)
- end
-
- it "should convert horizontal rules" do
- expect(@textile).to match(/^----/)
- end
-
- it "should convert dashes" do
- expect(@textile).to match(/^a -- b/)
- expect(@textile).to match(/^a --- b/)
- end
-
- it "should convert links" do
- expect(@textile).to match(/^\[\#anchor\]/)
- expect(@textile).to match(/^\[http\:\/\/jira.atlassian.com\]/)
- expect(@textile).to match(/^\[Atlassian\|http\:\/\/atlassian.com\]/)
- expect(@textile).to match(/^\[file\:\/\/\/c\:\/temp\/foo.txt\]/)
- end
-
- it "should convert bullets" do
- expect(@textile).to match(/\* some\s*\* bullet\s*\*\* indented\s*\*\* bullets\s*\* points/)
- expect(@textile).to match(/- different\s*- bullet\s*- types/)
- expect(@textile).to match(/# a\s*# numbered\s*# list/)
- expect(@textile).to match(/# a\s*# numbered\s*#\* with\s*#\* nested\s*#\* bullet\s*# list/)
- expect(@textile).to match(/\* a\s*\* bulleted\s*\*# with\s*\*# nested\s*\*# numbered\s*\* list/)
- end
-
- it "should convert pre blocks" do
- expect(@textile).to match(/^\{noformat\}\s*preformatted piece of text\s*so \*no\* further _formatting_ is done here\s*\{noformat\}/)
- end
-
- it "should convert tables" do
- expect(@textile).to include("||heading 1 ||heading 2 ||heading 3 ||")
- expect(@textile).to include("|col A1 |col A2 |col A3 |")
- expect(@textile).to include("|col B1 |col B2 |col B3 |")
- end
-
- it "should convert emoji from jira" do
- expect(@textile).to include(":)")
- expect(@textile).to include("(!)")
- expect(@textile).to include("(off)")
- expect(@textile).to include("(/)")
+ it "should convert inline formatting" do
+ expect(@textile).to match(/^\*strong\*/)
+ expect(@textile).to match(/^_emphasis_/)
+ expect(@textile).to match(/^\?\?citation\?\?/)
+ expect(@textile).to match(/^-deleted-/)
+ expect(@textile).to match(/^\+inserted\+/)
+ expect(@textile).to match(/^\^superscript\^/)
+ expect(@textile).to match(/^\~subscript\~/)
+ expect(@textile).to match(/^\{\{monospaced\}\}/)
+ end
+
+ it "should convert block quotes" do
+ expect(@textile).to match(/^Some block quoted text/)
+ expect(@textile).to match(/^\{quote\}\s*here is quotable\s*content to be quoted\s*{quote}/)
+ end
+
+ it "should handle text color" do
+ expect(@textile).to match(/^\{color\:red\}\s*look ma, red text!\s*\{color\}/)
+ end
+
+ it "should convert horizontal rules" do
+ expect(@textile).to match(/^----/)
+ end
+
+ it "should convert dashes" do
+ expect(@textile).to match(/^a -- b/)
+ expect(@textile).to match(/^a --- b/)
+ end
+
+ it "should convert links" do
+ expect(@textile).to match(/^\[\#anchor\]/)
+ expect(@textile).to match(/^\[http\:\/\/jira.atlassian.com\]/)
+ expect(@textile).to match(/^\[Atlassian\|http\:\/\/atlassian.com\]/)
+ expect(@textile).to match(/^\[file\:\/\/\/c\:\/temp\/foo.txt\]/)
+ end
+
+ it "should convert bullets" do
+ expect(@textile).to match(/\* some\s*\* bullet\s*\*\* indented\s*\*\* bullets\s*\* points/)
+ expect(@textile).to match(/- different\s*- bullet\s*- types/)
+ expect(@textile).to match(/# a\s*# numbered\s*# list/)
+ expect(@textile).to match(/# a\s*# numbered\s*#\* with\s*#\* nested\s*#\* bullet\s*# list/)
+ expect(@textile).to match(/\* a\s*\* bulleted\s*\*# with\s*\*# nested\s*\*# numbered\s*\* list/)
+ end
+
+ it "should convert pre blocks" do
+ expect(@textile).to match(/^\{noformat\}\s*preformatted piece of text\s*so \*no\* further _formatting_ is done here\s*\{noformat\}/)
+ end
+
+ it "should convert tables" do
+ expect(@textile).to include("||heading 1 ||heading 2 ||heading 3 ||")
+ expect(@textile).to include("|col A1 |col A2 |col A3 |")
+ expect(@textile).to include("|col B1 |col B2 |col B3 |")
+ end
+
+ it "should convert emoji from jira" do
+ expect(@textile).to include(":)")
+ expect(@textile).to include("(!)")
+ expect(@textile).to include("(off)")
+ expect(@textile).to include("(/)")
+ end
end
-
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
new file mode 100644
index 0000000..7fc85e5
--- /dev/null
+++ b/spec/spec_helper.rb
@@ -0,0 +1,17 @@
+require 'rspec'
+require 'simplecov'
+
+SimpleCov.start do
+ coverage_dir 'spec/coverage'
+ add_filter 'spec'
+ add_filter '.bundle'
+end
+
+require 'html2confluence'
+
+RSpec.configure do |config|
+ config.filter_gems_from_backtrace "rspec-core", "rspec"
+ config.run_all_when_everything_filtered = true
+ config.order = :random
+end
+