From fc23faf79d66bd440fabc11587ed26db4487e190 Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Wed, 28 Jan 2015 15:12:35 +0100 Subject: [PATCH] improve shortcuts provided by rspec helper --- src/ruby/yast/rspec/shortcuts.rb | 10 ++++++++++ tests/ruby/rspec_shortcuts_spec.rb | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/ruby/yast/rspec/shortcuts.rb b/src/ruby/yast/rspec/shortcuts.rb index 7e72ab2a..c578bb05 100644 --- a/src/ruby/yast/rspec/shortcuts.rb +++ b/src/ruby/yast/rspec/shortcuts.rb @@ -5,6 +5,8 @@ module Yast module RSpec # RSpec extension adding commodity shortcuts to enhance readability module Shortcuts + include Yast::UIShortcuts + # Shortcut for generating Yast::Path objects # # @param route [String] textual representation of the path @@ -12,6 +14,14 @@ module Shortcuts def path(route) Yast::Path.new(route) end + + # Shortcut for generating Yast::Term objects + # + # @param args parameter for term initialization + # @return [Yast::Term] the corresponding Term object + def term(*args) + Yast::Term.new(*args) + end end end end diff --git a/tests/ruby/rspec_shortcuts_spec.rb b/tests/ruby/rspec_shortcuts_spec.rb index fdeb0652..2e40b697 100644 --- a/tests/ruby/rspec_shortcuts_spec.rb +++ b/tests/ruby/rspec_shortcuts_spec.rb @@ -10,4 +10,14 @@ expect(path(".target.dir")).to eq(Yast::Path.new(".target.dir")) end end + + describe "#term" do + it "returns the expected Yast::Term object" do + expect(term(:ButtonBox)).to eq(Yast::Term.new(:ButtonBox)) + end + end + + it "include Yast::UIShortcuts" do + expect(ButtonBox()).to eq(Yast::Term.new(:ButtonBox)) + end end