Skip to content

Commit

Permalink
improve shortcuts provided by rspec helper
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Jan 28, 2015
1 parent 66dab9d commit fc23faf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ruby/yast/rspec/shortcuts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,23 @@ 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
# @return [Yast::Path] the corresponding Path object
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
10 changes: 10 additions & 0 deletions tests/ruby/rspec_shortcuts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fc23faf

Please sign in to comment.