rundoc 1.1.2 → 2.0.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/.github/workflows/check_changelog.yml +16 -7
- data/.github/workflows/ci.yml +48 -0
- data/.standard.yml +6 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +1 -1
- data/README.md +98 -5
- data/Rakefile +9 -10
- data/lib/rundoc/cli.rb +15 -17
- data/lib/rundoc/code_command/background/log/clear.rb +1 -1
- data/lib/rundoc/code_command/background/log/read.rb +1 -1
- data/lib/rundoc/code_command/background/process_spawn.rb +8 -9
- data/lib/rundoc/code_command/background/start.rb +7 -7
- data/lib/rundoc/code_command/background/stop.rb +1 -1
- data/lib/rundoc/code_command/background/wait.rb +2 -2
- data/lib/rundoc/code_command/background.rb +6 -6
- data/lib/rundoc/code_command/bash/cd.rb +6 -7
- data/lib/rundoc/code_command/bash.rb +12 -13
- data/lib/rundoc/code_command/file_command/append.rb +12 -16
- data/lib/rundoc/code_command/file_command/remove.rb +6 -9
- data/lib/rundoc/code_command/no_such_command.rb +0 -1
- data/lib/rundoc/code_command/pipe.rb +2 -5
- data/lib/rundoc/code_command/print/erb.rb +48 -0
- data/lib/rundoc/code_command/print/text.rb +33 -0
- data/lib/rundoc/code_command/raw.rb +1 -1
- data/lib/rundoc/code_command/rundoc/depend_on.rb +0 -1
- data/lib/rundoc/code_command/rundoc/require.rb +2 -3
- data/lib/rundoc/code_command/rundoc_command.rb +3 -4
- data/lib/rundoc/code_command/website/driver.rb +17 -17
- data/lib/rundoc/code_command/website/navigate.rb +2 -2
- data/lib/rundoc/code_command/website/screenshot.rb +1 -1
- data/lib/rundoc/code_command/website/visit.rb +4 -5
- data/lib/rundoc/code_command/website.rb +4 -4
- data/lib/rundoc/code_command/write.rb +10 -11
- data/lib/rundoc/code_command.rb +28 -17
- data/lib/rundoc/code_section.rb +42 -25
- data/lib/rundoc/parser.rb +17 -19
- data/lib/rundoc/peg_parser.rb +57 -59
- data/lib/rundoc/version.rb +1 -1
- data/lib/rundoc.rb +10 -14
- data/rundoc.gemspec +19 -21
- data/test/fixtures/rails_4/rundoc.md +100 -33
- data/test/fixtures/rails_5/rundoc.md +77 -14
- data/test/fixtures/rails_6/rundoc.md +231 -167
- data/test/fixtures/rails_7/rundoc.md +477 -0
- data/test/integration/print_test.rb +194 -0
- data/test/rundoc/code_commands/append_file_test.rb +5 -8
- data/test/rundoc/code_commands/background_test.rb +3 -6
- data/test/rundoc/code_commands/bash_test.rb +12 -7
- data/test/rundoc/code_commands/pipe_test.rb +9 -9
- data/test/rundoc/code_commands/print_test.rb +94 -0
- data/test/rundoc/code_commands/remove_contents_test.rb +4 -5
- data/test/rundoc/code_section_test.rb +50 -56
- data/test/rundoc/parser_test.rb +28 -61
- data/test/rundoc/peg_parser_test.rb +49 -53
- data/test/rundoc/regex_test.rb +120 -127
- data/test/rundoc/test_parse_java.rb +1 -3
- data/test/test_helper.rb +4 -6
- metadata +39 -42
- data/.travis.yml +0 -8
- data/lib/rundoc/code_command/repl.rb +0 -37
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
class BackgroundTest < Minitest::Test
|
4
4
|
def test_process_spawn_gc
|
@@ -9,8 +9,7 @@ class BackgroundTest < Minitest::Test
|
|
9
9
|
|
10
10
|
background_start = Rundoc::CodeCommand::Background::Start.new("tail -f #{file}",
|
11
11
|
name: "tail2",
|
12
|
-
wait: "f"
|
13
|
-
)
|
12
|
+
wait: "f")
|
14
13
|
|
15
14
|
GC.start
|
16
15
|
|
@@ -30,14 +29,12 @@ class BackgroundTest < Minitest::Test
|
|
30
29
|
def test_background_start
|
31
30
|
Dir.mktmpdir do |dir|
|
32
31
|
Dir.chdir(dir) do
|
33
|
-
|
34
32
|
file = "foo.txt"
|
35
33
|
`echo 'foo' >> #{file}`
|
36
34
|
|
37
35
|
background_start = Rundoc::CodeCommand::Background::Start.new("tail -f #{file}",
|
38
36
|
name: "tail",
|
39
|
-
wait: "f"
|
40
|
-
)
|
37
|
+
wait: "f")
|
41
38
|
output = background_start.call
|
42
39
|
|
43
40
|
assert_match("foo", output)
|
@@ -1,29 +1,34 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
class BashTest < Minitest::Test
|
4
|
-
|
5
4
|
def test_bash_returns_cd
|
6
5
|
original_dir = `pwd`
|
7
6
|
Rundoc::CodeCommand::Bash.new("cd ..").call
|
8
|
-
now_dir
|
7
|
+
now_dir = `pwd`
|
9
8
|
refute_equal original_dir, now_dir
|
10
9
|
ensure
|
11
10
|
Dir.chdir(original_dir.strip)
|
12
11
|
end
|
13
12
|
|
13
|
+
def test_bash_stderr_with_or_is_capture
|
14
|
+
command = "1>&2 echo 'msg to STDERR 1' || 1>&2 echo 'msg to STDERR 2'"
|
15
|
+
bash = Rundoc::CodeCommand::Bash.new(command)
|
16
|
+
assert_equal "$ #{command}", bash.to_md
|
17
|
+
assert_equal "msg to STDERR 1\n", bash.call
|
18
|
+
end
|
14
19
|
|
15
20
|
def test_bash_shells_and_shows_correctly
|
16
21
|
["pwd", "ls"].each do |command|
|
17
|
-
bash
|
22
|
+
bash = Rundoc::CodeCommand::Bash.new(command)
|
18
23
|
assert_equal "$ #{command}", bash.to_md
|
19
|
-
assert_equal `#{command}`,
|
24
|
+
assert_equal `#{command}`, bash.call
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
23
28
|
def test_stdin
|
24
29
|
command = "tail -n 2"
|
25
|
-
bash
|
30
|
+
bash = Rundoc::CodeCommand::Bash.new(command)
|
26
31
|
bash << "foo\nbar\nbaz\n"
|
27
|
-
assert_equal "bar\nbaz\n",
|
32
|
+
assert_equal "bar\nbaz\n", bash.call
|
28
33
|
end
|
29
34
|
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
class PipeTest < Minitest::Test
|
4
4
|
def test_pipe
|
5
5
|
pipe_cmd = "tail -n 2"
|
6
|
-
cmd
|
7
|
-
out
|
8
|
-
pipe
|
9
|
-
actual
|
6
|
+
cmd = "ls"
|
7
|
+
out = `#{cmd}`
|
8
|
+
pipe = Rundoc::CodeCommand::Pipe.new(pipe_cmd)
|
9
|
+
actual = pipe.call(commands: [{command: cmd, output: out}])
|
10
10
|
|
11
11
|
expected = `#{cmd} | #{pipe_cmd}`
|
12
12
|
assert_equal expected, actual
|
@@ -14,10 +14,10 @@ class PipeTest < Minitest::Test
|
|
14
14
|
|
15
15
|
def test_moar_pipe_with_dollar
|
16
16
|
pipe_cmd = "tail -n 2"
|
17
|
-
cmd
|
18
|
-
out
|
19
|
-
pipe
|
20
|
-
actual
|
17
|
+
cmd = "ls"
|
18
|
+
out = `#{cmd}`
|
19
|
+
pipe = Rundoc::CodeCommand::Pipe.new("$ #{pipe_cmd}")
|
20
|
+
actual = pipe.call(commands: [{command: cmd, output: out}])
|
21
21
|
|
22
22
|
expected = `#{cmd} | #{pipe_cmd}`
|
23
23
|
assert_equal expected, actual
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class PrintTest < Minitest::Test
|
4
|
+
def test_plain_text_before_block
|
5
|
+
env = {}
|
6
|
+
env[:before] = []
|
7
|
+
|
8
|
+
input = %($ rails new myapp # Not a command since it's missing the ":::>>")
|
9
|
+
cmd = Rundoc::CodeCommand::PrintText.new(input)
|
10
|
+
cmd.render_command = false
|
11
|
+
cmd.render_result = true
|
12
|
+
|
13
|
+
assert_equal "", cmd.to_md(env)
|
14
|
+
assert_equal "", cmd.call
|
15
|
+
assert_equal ["$ rails new myapp # Not a command since it's missing the \":::>>\""], env[:before]
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_plain_text_in_block
|
19
|
+
env = {}
|
20
|
+
env[:before] = []
|
21
|
+
|
22
|
+
input = %($ rails new myapp # Not a command since it's missing the ":::>>")
|
23
|
+
cmd = Rundoc::CodeCommand::PrintText.new(input)
|
24
|
+
cmd.render_command = true
|
25
|
+
cmd.render_result = true
|
26
|
+
|
27
|
+
assert_equal "", cmd.to_md(env)
|
28
|
+
assert_equal input, cmd.call
|
29
|
+
|
30
|
+
assert_equal [], env[:before]
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_erb_before_block
|
34
|
+
env = {}
|
35
|
+
env[:before] = []
|
36
|
+
|
37
|
+
input = %($ rails new <%= 'myapp' %> # Not a command since it's missing the ":::>>")
|
38
|
+
cmd = Rundoc::CodeCommand::PrintERB.new(input)
|
39
|
+
cmd.render_command = false
|
40
|
+
cmd.render_result = true
|
41
|
+
|
42
|
+
assert_equal "", cmd.to_md(env)
|
43
|
+
assert_equal "", cmd.call
|
44
|
+
assert_equal ["$ rails new myapp # Not a command since it's missing the \":::>>\""],
|
45
|
+
env[:before]
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_erb_in_block
|
49
|
+
env = {}
|
50
|
+
env[:before] = []
|
51
|
+
|
52
|
+
cmd = Rundoc::CodeCommand::PrintERB.new
|
53
|
+
cmd.contents = %(<%= "foo" %>)
|
54
|
+
cmd.render_command = true
|
55
|
+
cmd.render_result = true
|
56
|
+
|
57
|
+
assert_equal "", cmd.to_md(env)
|
58
|
+
assert_equal "foo", cmd.call
|
59
|
+
assert_equal [], env[:before]
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_binding_is_preserved
|
63
|
+
env = {}
|
64
|
+
env[:before] = []
|
65
|
+
cmd = Rundoc::CodeCommand::PrintERB.new
|
66
|
+
cmd.contents = %{<%= @foo = SecureRandom.hex(16) %>}
|
67
|
+
cmd.render_command = true
|
68
|
+
cmd.render_result = true
|
69
|
+
|
70
|
+
assert_equal "", cmd.to_md(env)
|
71
|
+
assert_equal [], env[:before]
|
72
|
+
expected = cmd.call
|
73
|
+
|
74
|
+
assert !expected.empty?
|
75
|
+
|
76
|
+
cmd = Rundoc::CodeCommand::PrintERB.new
|
77
|
+
cmd.contents = %(<%= @foo %>)
|
78
|
+
cmd.render_command = true
|
79
|
+
cmd.render_result = true
|
80
|
+
|
81
|
+
assert_equal "", cmd.to_md(env)
|
82
|
+
assert_equal expected, cmd.call
|
83
|
+
assert_equal [], env[:before]
|
84
|
+
|
85
|
+
cmd = Rundoc::CodeCommand::PrintERB.new(binding: "different")
|
86
|
+
cmd.contents = %(<%= @foo %>)
|
87
|
+
cmd.render_command = true
|
88
|
+
cmd.render_result = true
|
89
|
+
|
90
|
+
assert_equal "", cmd.to_md(env)
|
91
|
+
assert_equal "", cmd.call
|
92
|
+
assert_equal [], env[:before]
|
93
|
+
end
|
94
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
class RemoveContentsTest < Minitest::Test
|
4
|
-
|
5
4
|
def setup
|
6
5
|
@gemfile = <<-RUBY
|
7
6
|
|
@@ -17,7 +16,6 @@ class RemoveContentsTest < Minitest::Test
|
|
17
16
|
def test_appends_to_a_file
|
18
17
|
Dir.mktmpdir do |dir|
|
19
18
|
Dir.chdir(dir) do
|
20
|
-
|
21
19
|
@file = "foo.rb"
|
22
20
|
`echo "#{@gemfile}" >> #{@file}`
|
23
21
|
|
@@ -31,10 +29,11 @@ class RemoveContentsTest < Minitest::Test
|
|
31
29
|
|
32
30
|
env = {}
|
33
31
|
env[:commands] = []
|
34
|
-
env[:before]
|
32
|
+
env[:before] = []
|
33
|
+
env[:fence_start] = "```ruby"
|
35
34
|
cc.to_md(env)
|
36
35
|
|
37
|
-
assert_equal "In file `foo.rb` remove
|
36
|
+
assert_equal ["In file `foo.rb` remove:", Rundoc::CodeCommand::NEWLINE], env[:before]
|
38
37
|
end
|
39
38
|
end
|
40
39
|
end
|
@@ -1,21 +1,16 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
class CodeSectionTest < Minitest::Test
|
4
|
-
|
5
|
-
def setup
|
6
|
-
end
|
7
|
-
|
8
4
|
def test_does_not_render_if_all_contents_hidden
|
9
|
-
contents =
|
10
|
-
sup
|
5
|
+
contents = <<~RUBY
|
6
|
+
sup
|
11
7
|
|
12
|
-
```
|
13
|
-
:::-- $ mkdir foo
|
14
|
-
```
|
15
|
-
|
16
|
-
yo
|
17
|
-
RUBY
|
8
|
+
```
|
9
|
+
:::-- $ mkdir foo
|
10
|
+
```
|
18
11
|
|
12
|
+
yo
|
13
|
+
RUBY
|
19
14
|
|
20
15
|
Dir.mktmpdir do |dir|
|
21
16
|
Dir.chdir(dir) do
|
@@ -26,55 +21,55 @@ RUBY
|
|
26
21
|
end
|
27
22
|
end
|
28
23
|
|
29
|
-
|
30
24
|
def test_no_code
|
31
|
-
contents =
|
32
|
-
```ruby
|
33
|
-
gem 'sqlite3'
|
34
|
-
```
|
35
|
-
|
25
|
+
contents = <<~RUBY
|
26
|
+
```ruby
|
27
|
+
gem 'sqlite3'
|
28
|
+
```
|
29
|
+
|
30
|
+
RUBY
|
36
31
|
|
37
32
|
match = contents.match(Rundoc::Parser::CODEBLOCK_REGEX)
|
38
33
|
result = Rundoc::CodeSection.new(match, keyword: ":::").render
|
39
|
-
assert_equal contents, result
|
34
|
+
assert_equal contents, result.gsub(Rundoc::CodeSection::AUTOGEN_WARNING, "\n")
|
40
35
|
end
|
41
36
|
|
42
37
|
def test_show_command_hide_render
|
43
|
-
contents =
|
44
|
-
```
|
45
|
-
:::>- $ echo "foo"
|
46
|
-
```
|
47
|
-
RUBY
|
38
|
+
contents = <<~RUBY
|
39
|
+
```
|
40
|
+
:::>- $ echo "foo"
|
41
|
+
```
|
42
|
+
RUBY
|
48
43
|
|
49
44
|
match = contents.match(Rundoc::Parser::CODEBLOCK_REGEX)
|
50
45
|
code_section = Rundoc::CodeSection.new(match, keyword: ":::")
|
51
46
|
code_section.render
|
52
47
|
|
53
48
|
code_command = code_section.commands.first
|
54
|
-
assert_equal true,
|
49
|
+
assert_equal true, code_command.render_command
|
55
50
|
assert_equal false, code_command.render_result
|
56
51
|
|
57
|
-
contents =
|
58
|
-
```
|
59
|
-
:::>- $ echo "foo"
|
60
|
-
```
|
61
|
-
RUBY
|
52
|
+
contents = <<~RUBY
|
53
|
+
```
|
54
|
+
:::>- $ echo "foo"
|
55
|
+
```
|
56
|
+
RUBY
|
62
57
|
|
63
58
|
match = contents.match(Rundoc::Parser::CODEBLOCK_REGEX)
|
64
59
|
code_section = Rundoc::CodeSection.new(match, keyword: ":::")
|
65
60
|
code_section.render
|
66
61
|
|
67
62
|
code_command = code_section.commands.first
|
68
|
-
assert_equal true,
|
63
|
+
assert_equal true, code_command.render_command
|
69
64
|
assert_equal false, code_command.render_result
|
70
65
|
end
|
71
66
|
|
72
67
|
def test_show_command_show_render
|
73
|
-
contents =
|
74
|
-
```
|
75
|
-
:::>> $ echo "foo"
|
76
|
-
```
|
77
|
-
RUBY
|
68
|
+
contents = <<~RUBY
|
69
|
+
```
|
70
|
+
:::>> $ echo "foo"
|
71
|
+
```
|
72
|
+
RUBY
|
78
73
|
|
79
74
|
match = contents.match(Rundoc::Parser::CODEBLOCK_REGEX)
|
80
75
|
code_section = Rundoc::CodeSection.new(match, keyword: ":::")
|
@@ -87,49 +82,48 @@ RUBY
|
|
87
82
|
end
|
88
83
|
|
89
84
|
def test_hide_command_hide_render
|
90
|
-
contents =
|
91
|
-
```
|
92
|
-
:::-- $ echo "foo"
|
93
|
-
```
|
94
|
-
RUBY
|
85
|
+
contents = <<~RUBY
|
86
|
+
```
|
87
|
+
:::-- $ echo "foo"
|
88
|
+
```
|
89
|
+
RUBY
|
95
90
|
|
96
91
|
match = contents.match(Rundoc::Parser::CODEBLOCK_REGEX)
|
97
92
|
code_section = Rundoc::CodeSection.new(match, keyword: ":::")
|
98
93
|
code_section.render
|
99
94
|
|
100
95
|
code_command = code_section.commands.first
|
101
|
-
assert_equal false,
|
96
|
+
assert_equal false, code_command.render_command
|
102
97
|
assert_equal false, code_command.render_result
|
103
98
|
|
104
|
-
contents =
|
105
|
-
```
|
106
|
-
:::-- $ echo "foo"
|
107
|
-
```
|
108
|
-
RUBY
|
99
|
+
contents = <<~RUBY
|
100
|
+
```
|
101
|
+
:::-- $ echo "foo"
|
102
|
+
```
|
103
|
+
RUBY
|
109
104
|
|
110
105
|
match = contents.match(Rundoc::Parser::CODEBLOCK_REGEX)
|
111
106
|
code_section = Rundoc::CodeSection.new(match, keyword: ":::")
|
112
107
|
code_section.render
|
113
108
|
|
114
109
|
code_command = code_section.commands.first
|
115
|
-
assert_equal false,
|
110
|
+
assert_equal false, code_command.render_command
|
116
111
|
assert_equal false, code_command.render_result
|
117
112
|
end
|
118
113
|
|
119
114
|
def test_hide_command_show_render
|
120
|
-
contents =
|
121
|
-
```
|
122
|
-
:::-> $ echo "foo"
|
123
|
-
```
|
124
|
-
RUBY
|
115
|
+
contents = <<~RUBY
|
116
|
+
```
|
117
|
+
:::-> $ echo "foo"
|
118
|
+
```
|
119
|
+
RUBY
|
125
120
|
|
126
121
|
match = contents.match(Rundoc::Parser::CODEBLOCK_REGEX)
|
127
122
|
code_section = Rundoc::CodeSection.new(match, keyword: ":::")
|
128
123
|
code_section.render
|
129
124
|
|
130
125
|
code_command = code_section.commands.first
|
131
|
-
assert_equal false,
|
126
|
+
assert_equal false, code_command.render_command
|
132
127
|
assert_equal true, code_command.render_result
|
133
128
|
end
|
134
|
-
|
135
129
|
end
|
data/test/rundoc/parser_test.rb
CHANGED
@@ -1,98 +1,65 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
class ParserTest < Minitest::Test
|
4
|
-
|
5
|
-
def setup
|
6
|
-
end
|
7
|
-
|
8
4
|
def test_parse_bash
|
9
|
-
contents =
|
10
|
-
sup
|
5
|
+
contents = <<~RUBY
|
6
|
+
sup
|
11
7
|
|
12
|
-
```
|
13
|
-
:::>- $ mkdir foo
|
14
|
-
:::>> $ ls
|
15
|
-
```
|
16
|
-
|
17
|
-
yo
|
18
|
-
RUBY
|
8
|
+
```
|
9
|
+
:::>- $ mkdir foo
|
10
|
+
:::>> $ ls
|
11
|
+
```
|
19
12
|
|
13
|
+
yo
|
14
|
+
RUBY
|
20
15
|
|
21
16
|
Dir.mktmpdir do |dir|
|
22
17
|
Dir.chdir(dir) do
|
23
18
|
expected = "sup\n\n```\n$ mkdir foo\n$ ls\nfoo\n```\n\nyo\n"
|
24
19
|
parsed = Rundoc::Parser.new(contents)
|
25
|
-
actual = parsed.to_md
|
20
|
+
actual = parsed.to_md.gsub(Rundoc::CodeSection::AUTOGEN_WARNING, "")
|
26
21
|
assert_equal expected, actual
|
27
22
|
end
|
28
23
|
end
|
29
24
|
end
|
30
25
|
|
31
|
-
|
32
26
|
def test_parse_write_commands
|
33
|
-
contents =
|
34
|
-
sup
|
27
|
+
contents = <<~RUBY
|
28
|
+
sup
|
35
29
|
|
36
|
-
```
|
37
|
-
:::>> write foo/code.rb
|
38
|
-
a = 1 + 1
|
39
|
-
b = a * 2
|
40
|
-
```
|
41
|
-
yo
|
42
|
-
RUBY
|
30
|
+
```
|
31
|
+
:::>> write foo/code.rb
|
32
|
+
a = 1 + 1
|
33
|
+
b = a * 2
|
34
|
+
```
|
35
|
+
yo
|
36
|
+
RUBY
|
43
37
|
|
44
38
|
Dir.mktmpdir do |dir|
|
45
39
|
Dir.chdir(dir) do
|
46
|
-
|
47
40
|
expected = "sup\n\nIn file `foo/code.rb` write:\n\n```\na = 1 + 1\nb = a * 2\n```\nyo\n"
|
48
41
|
parsed = Rundoc::Parser.new(contents)
|
49
|
-
actual = parsed.to_md
|
42
|
+
actual = parsed.to_md.gsub(Rundoc::CodeSection::AUTOGEN_WARNING, "")
|
50
43
|
assert_equal expected, actual
|
51
44
|
end
|
52
45
|
end
|
53
46
|
|
47
|
+
contents = <<~RUBY
|
54
48
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
:::>>
|
59
|
-
|
60
|
-
|
61
|
-
```
|
62
|
-
RUBY
|
49
|
+
```
|
50
|
+
:::>> write foo/newb.rb
|
51
|
+
puts 'hello world'
|
52
|
+
:::>> $ cat foo/newb.rb
|
53
|
+
```
|
54
|
+
RUBY
|
63
55
|
|
64
56
|
Dir.mktmpdir do |dir|
|
65
57
|
Dir.chdir(dir) do
|
66
|
-
|
67
58
|
expected = "\nIn file `foo/newb.rb` write:\n\n```\nputs 'hello world'\n$ cat foo/newb.rb\nputs 'hello world'\n```\n"
|
68
59
|
parsed = Rundoc::Parser.new(contents)
|
69
|
-
actual = parsed.to_md
|
60
|
+
actual = parsed.to_md.gsub(Rundoc::CodeSection::AUTOGEN_WARNING, "")
|
70
61
|
assert_equal expected, actual
|
71
62
|
end
|
72
63
|
end
|
73
64
|
end
|
74
|
-
|
75
|
-
def test_irb
|
76
|
-
|
77
|
-
contents = <<-RUBY
|
78
|
-
```
|
79
|
-
:::>> irb --simple-prompt
|
80
|
-
a = 3
|
81
|
-
b = "foo" * a
|
82
|
-
puts b
|
83
|
-
```
|
84
|
-
RUBY
|
85
|
-
|
86
|
-
Dir.mktmpdir do |dir|
|
87
|
-
Dir.chdir(dir) do
|
88
|
-
|
89
|
-
parsed = Rundoc::Parser.new(contents)
|
90
|
-
actual = parsed.to_md
|
91
|
-
expected = "```\n$ irb --simple-prompt\na = 3\n=> 3\r\nb = \"foo\" * a\n=> \"foofoofoo\"\r\nputs b\nfoofoofoo\r\n=> nil\n```\n"
|
92
|
-
assert_equal expected, actual
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
97
|
-
|
98
65
|
end
|