Skip to content

Commit

Permalink
more adaptation for ruby3 including tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Dec 23, 2021
1 parent 323f9cc commit 1d2df88
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions library/cwm/src/lib/cwm/dialog.rb
Expand Up @@ -27,8 +27,8 @@ def title
abstract_method :contents

# A shortcut for `.new(*args).run`
def self.run(*args)
new(*args).run
def self.run(*args, **kws)
new(*args, **kws).run
end

# The entry point.
Expand Down
14 changes: 14 additions & 0 deletions library/cwm/test/dialog_test.rb
Expand Up @@ -6,10 +6,17 @@

describe "CWM::Dialog" do
class TestCWMDialog < CWM::Dialog
attr_reader :title, :disable
def initialize(title = "test", disable: :abort)
@title = title
@disable = disable
end

def contents
VBox()
end
end

subject { TestCWMDialog.new }

include_examples "CWM::Dialog"
Expand All @@ -19,6 +26,13 @@ def contents
allow(Yast::Wizard).to receive(:IsWizardDialog).and_return(false)
allow(Yast::Wizard).to receive(:CreateDialog)
allow(Yast::Wizard).to receive(:CloseDialog)
allow(Yast::CWM).to receive(:show).and_return(:next)
end

it "pass all arguments to constructor" do
expect(TestCWMDialog).to receive(:new).with("test2", disable: :next).and_call_original

TestCWMDialog.run("test2", disable: :next)
end

it "opens a dialog when needed, and calls CWM#show" do
Expand Down
14 changes: 2 additions & 12 deletions library/general/src/lib/ui/text_helpers.rb
Expand Up @@ -30,18 +30,8 @@ def plain_text(text, **args, &block)
end

# (see Yast2::Refinements::StringManipulations#wrap_text)
def wrap_text(text, *args)
width = args.find { |a| a.is_a?(Integer) }
map = args.find { |a| a.is_a?(Hash) }
if map && width
text.wrap_text(width, **map)
elsif width
text.wrap_text(width)
elsif map
text.wrap_text(**map)
else
text.wrap_text
end
def wrap_text(text, *args, **kwa)
text.wrap_text(*args, **kwa)
end

# (see Yast2::Refinements::StringManipulations#head)
Expand Down

0 comments on commit 1d2df88

Please sign in to comment.