Skip to content

Commit 5ce6178

Browse files
committed
add test
1 parent 492d740 commit 5ce6178

File tree

11 files changed

+104
-3
lines changed

11 files changed

+104
-3
lines changed

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: ruby
2+
rvm:
3+
- 1.9.3
4+
- 1.9.2
5+
gemfile:
6+
- Gemfile

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Markup Previw Command
22
=======================
33

4+
[![Build Status](https://secure.travis-ci.org/mori-dev/markup-preview-command.png)](http://travis-ci.org/mori-dev/markup-preview-command)
5+
46
We use this library on Github when rendering your README or any other
57
rich text file, *When We are editing by Emacs or other editor*.
68

@@ -51,4 +53,4 @@ Fork, fix, then send me a pull request.
5153
Copyright
5254
------------
5355

54-
Copyright (c) mori_dev. See LICENSE for details.
56+
Copyright (c) mori_dev. See LICENSE for details.

lib/markup-preview-command/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Markup
22
module Preview
33
module Command
4-
VERSION = "0.0.6"
4+
VERSION = "0.0.7"
55
end
66
end
77
end

markup-preview-command.gemspec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ $:.push File.expand_path("../lib", __FILE__)
33
require "markup-preview-command/version"
44

55
Gem::Specification.new do |s|
6+
67
s.name = "markup-preview-command"
78
s.version = Markup::Preview::Command::VERSION
89
s.authors = ["mori_dev"]
910
s.email = ["mori.dev.asdf@gmail.com"]
10-
s.homepage = "https://github.com/wakaran/markup-preview-command"
11+
s.homepage = "https://github.com/mori-dev/markup-preview-command"
1112
s.summary = %q{Previw your wiki file as local html file.}
1213
s.description = %q{Previw your wiki file as local html file. (format: markdown, rest, textile, rdoc and so on.)}
1314

@@ -27,5 +28,6 @@ Gem::Specification.new do |s|
2728
s.add_dependency('wikicloth', '~>0.7.0')
2829
s.add_dependency('rake', '~>0.9.0')
2930
s.add_dependency('slop', '~>2.4.0')
31+
s.add_development_dependency("rspec", "~> 2.11.0")
3032

3133
end

spec/fixtures/test.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# title

spec/fixtures/test.org

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* title

spec/fixtures/test.rdoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
= title

spec/fixtures/test.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
title
2+
======

spec/fixtures/test.textile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
h1. title

spec/markup-preview-command_spec.rb

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# -*- coding: utf-8 -*-
2+
require 'markup-preview-command'
3+
require File.join(File.dirname(__FILE__), "spec_helper")
4+
5+
describe "markup-preview command" do
6+
7+
let(:command) { File.join(File.dirname(__FILE__), "..", "bin", "markup-preview") }
8+
9+
context "Markdown file" do
10+
let(:fixture_file) { File.join(File.dirname(__FILE__), "fixtures", "test.md") }
11+
it "convert to html" do
12+
@stdout = capture(:stdout) do
13+
puts `"#{command}" -f "#{fixture_file}"`
14+
end
15+
@stdout.should include "<h1>title</h1>"
16+
end
17+
end
18+
19+
context "reStructuredText file" do
20+
let(:fixture_file) { File.join(File.dirname(__FILE__), "fixtures", "test.rst") }
21+
it "convert to html" do
22+
@stdout = capture(:stdout) do
23+
puts `"#{command}" -f "#{fixture_file}"`
24+
end
25+
@stdout.should include "<h1>title</h1>"
26+
end
27+
end
28+
29+
context "Textile file" do
30+
let(:fixture_file) { File.join(File.dirname(__FILE__), "fixtures", "test.textile") }
31+
it "convert to html" do
32+
@stdout = capture(:stdout) do
33+
puts `"#{command}" -f "#{fixture_file}"`
34+
end
35+
@stdout.should include "<h1>title</h1>"
36+
end
37+
end
38+
39+
context "Textile file" do
40+
let(:fixture_file) { File.join(File.dirname(__FILE__), "fixtures", "test.textile") }
41+
it "convert to html" do
42+
@stdout = capture(:stdout) do
43+
puts `"#{command}" -f "#{fixture_file}"`
44+
end
45+
@stdout.should include "<h1>title</h1>"
46+
end
47+
end
48+
49+
context "Org file" do
50+
let(:fixture_file) { File.join(File.dirname(__FILE__), "fixtures", "test.org") }
51+
it "convert to html" do
52+
@stdout = capture(:stdout) do
53+
puts `"#{command}" -f "#{fixture_file}"`
54+
end
55+
@stdout.should include %Q[<h1 class="title">title</h1>]
56+
end
57+
end
58+
59+
context "RDoc file" do
60+
let(:fixture_file) { File.join(File.dirname(__FILE__), "fixtures", "test.rdoc") }
61+
it "convert to html" do
62+
@stdout = capture(:stdout) do
63+
puts `"#{command}" -f "#{fixture_file}"`
64+
end
65+
@stdout.should include "<h1>title</h1>"
66+
end
67+
end
68+
end

spec/spec_helper.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require "stringio"
2+
3+
RSpec.configure do |config|
4+
# This method is almost copy of wycats's implementation.
5+
# I found it at http://d.hatena.ne.jp/POCHI_BLACK/comment?date=20100324 .
6+
def capture(stream)
7+
begin
8+
stream = stream.to_s
9+
eval "$#{stream} = StringIO.new"
10+
yield
11+
result = eval("$#{stream}").string
12+
ensure
13+
eval "$#{stream} = #{stream.upcase}"
14+
end
15+
result
16+
end
17+
end

0 commit comments

Comments
 (0)