Skip to content

Commit

Permalink
Add helper method install test
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Feb 23, 2024
1 parent b32af7a commit c6e4fff
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/irb/test_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -548,12 +548,26 @@ def test_pushws_switches_to_new_workspace_and_pushes_the_current_one_to_the_stac
end

def test_pushws_extends_the_new_workspace_with_command_bundle
IRB::ExtendCommandBundle.module_eval do
def foobar; end
end
out, err = execute_lines(
"pushws Object.new\n",
"self.singleton_class.ancestors"
)
assert_empty err
assert_include(out, "IRB::ExtendCommandBundle")
ensure
IRB::ExtendCommandBundle.remove_method :foobar
end

def test_pushws_does_not_extend_command_bundle_by_default
out, err = execute_lines(
"pushws Object.new\n",
"self.singleton_class.ancestors"
)
assert_empty err
assert_not_include(out, "IRB::ExtendCommandBundle")
end

def test_pushws_prints_help_message_when_no_arg_is_given
Expand Down Expand Up @@ -995,4 +1009,28 @@ def test_history_grep

end

class HelperMethodInsallTest < CommandTestCase
def test_extend_command_bundle_not_installed_by_default
out, err = execute_lines("self.singleton_class.ancestors")
assert_empty err
assert_not_include(out, 'IRB::ExtendCommandBundle')
end

def test_helper_method_install
IRB::ExtendCommandBundle.module_eval do
def foobar
"test_helper_method_foobar"
end
end
out, err = execute_lines("self.singleton_class.ancestors")
assert_empty err
assert_include(out, "IRB::ExtendCommandBundle")

out, err = execute_lines("foobar.upcase")
assert_empty err
assert_include(out, '=> "TEST_HELPER_METHOD_FOOBAR"')
ensure
IRB::ExtendCommandBundle.remove_method :foobar
end
end
end

0 comments on commit c6e4fff

Please sign in to comment.