Skip to content

Commit

Permalink
Fix command test
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Dec 27, 2023
1 parent 37f415f commit 2b67566
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions test/irb/test_cmd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -373,17 +373,19 @@ def test_measure_toggle
}
}
out, err = execute_lines(
"measure :foo",
"measure :on, :bar",
"3\n",
"measure :foo\n",
"1\n",
"measure :on, :bar\n",
"2\n",
"measure :off, :foo\n",
"measure :off, :bar\n",
"3\n",
"measure :off, :bar\n",
"4\n",
conf: conf
)

assert_empty err
assert_match(/\AFOO is added\.\n=> nil\nfoo\nBAR is added\.\n=> nil\nbar\nfoo\n=> 3\nbar\nfoo\n=> nil\nbar\n=> nil\n=> 3\n/, out)
assert_match(/\AFOO is added\.\n=> nil\nfoo\n=> 1\nBAR is added\.\n=> nil\nbar\nfoo\n=> 2\n=> nil\nbar\n=> 3\n=> nil\n=> 4\n/, out)
end

def test_measure_with_proc_warning
Expand All @@ -402,7 +404,6 @@ def test_measure_with_proc_warning
out, err = execute_lines(
"3\n",
"measure do\n",
"end\n",
"3\n",
conf: conf,
main: c
Expand Down Expand Up @@ -524,7 +525,8 @@ class WorkspacesTest < WorkspaceCommandTestCase
def test_workspaces_returns_the_array_of_non_main_workspaces
out, err = execute_lines(
"pushws #{self.class}::Foo.new\n",
"workspaces.map { |w| w.class.name }",
"workspaces\n",
"_.map { |w| w.class.name }",
)

assert_empty err
Expand All @@ -535,7 +537,8 @@ def test_workspaces_returns_the_array_of_non_main_workspaces

def test_workspaces_returns_empty_array_when_no_workspaces_were_added
out, err = execute_lines(
"workspaces.map(&:to_s)",
"workspaces\n",
"_.map(&:to_s)",
)

assert_empty err
Expand All @@ -548,7 +551,8 @@ def test_popws_replaces_the_current_workspace_with_the_previous_one
out, err = execute_lines(
"pushws Foo.new\n",
"popws\n",
"cwws.class",
"cwws\n",
"_.class",
)
assert_empty err
assert_include(out, "=> #{self.class}")
Expand All @@ -567,7 +571,8 @@ class ChwsTest < WorkspaceCommandTestCase
def test_chws_replaces_the_current_workspace
out, err = execute_lines(
"chws #{self.class}::Foo.new\n",
"cwws.class",
"cwws\n",
"_.class",
)
assert_empty err
assert_include(out, "=> #{self.class}::Foo")
Expand All @@ -576,7 +581,8 @@ def test_chws_replaces_the_current_workspace
def test_chws_does_nothing_when_receiving_no_argument
out, err = execute_lines(
"chws\n",
"cwws.class",
"cwws\n",
"_.class",
)
assert_empty err
assert_include(out, "=> #{self.class}")
Expand Down Expand Up @@ -747,18 +753,18 @@ def test_ls_grep
def test_ls_grep_empty
out, err = execute_lines("ls\n")
assert_empty err
assert_match(/whereami/, out)
assert_match(/show_source/, out)
assert_match(/assert/, out)
assert_match(/refute/, out)

[
"ls grep: /whereami/\n",
"ls -g whereami\n",
"ls -G whereami\n",
"ls grep: /assert/\n",
"ls -g assert\n",
"ls -G assert\n",
].each do |line|
out, err = execute_lines(line)
assert_empty err
assert_match(/whereami/, out)
assert_not_match(/show_source/, out)
assert_match(/assert/, out)
assert_not_match(/refute/, out)
end
end

Expand Down

0 comments on commit 2b67566

Please sign in to comment.