Skip to content

Commit

Permalink
Fix pre.erb visibility forwarding
Browse files Browse the repository at this point in the history
I accidentally swapped the order of the visibility markers. This commit fixes that problem and adds tests against future regressions.
  • Loading branch information
schneems committed Dec 13, 2024
1 parent 6e4b0ad commit b735572
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## HEAD

- Fix: Visibility forwarding for `pre.erb` was accidentally reversed, this is now fixed. (https://github.com/zombocom/rundoc/pull/93)

## 4.1.0

- Add: Rundoc command `pre.erb` command used for dynamically templating any command using ERB syntax. (https://github.com/zombocom/rundoc/pull/90)
Expand Down
2 changes: 1 addition & 1 deletion lib/rundoc/code_command/pre/erb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def render_command=(value)
def code
@code ||= begin
vis = +""
vis += @render_delegate_result ? ">" : "-"
vis += @render_delegate_command ? ">" : "-"
vis += @render_delegate_result ? ">" : "-"
code = [@line, @contents]
.compact
.reject(&:empty?)
Expand Down
44 changes: 44 additions & 0 deletions test/integration/pre_erb_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,50 @@
require "test_helper"

class IntegrationPreErb < Minitest::Test
def test_result_visibility_forwarding
contents = <<~RUBY
```
:::-> pre.erb $ echo <%= 1 + 1 %>
```
RUBY

Dir.mktmpdir do |dir|
Dir.chdir(dir) do
expected = <<~EOF
```
2
```
EOF

parsed = parse_contents(contents)
actual = parsed.to_md.gsub(Rundoc::FencedCodeBlock::AUTOGEN_WARNING, "").strip
assert_equal expected.strip, actual.strip
end
end
end

def test_command_visibility_forwarding
contents = <<~RUBY
```
:::>- pre.erb $ echo <%= 1 + 1 %>
```
RUBY

Dir.mktmpdir do |dir|
Dir.chdir(dir) do
expected = <<~EOF
```
$ echo 2
```
EOF

parsed = parse_contents(contents)
actual = parsed.to_md.gsub(Rundoc::FencedCodeBlock::AUTOGEN_WARNING, "").strip
assert_equal expected.strip, actual.strip
end
end
end

def test_file_write
key = SecureRandom.hex
contents = <<~RUBY
Expand Down

0 comments on commit b735572

Please sign in to comment.