Hello community,

here is the log from the commit of package yast2-ruby-bindings for 
openSUSE:Factory checked in at 2015-01-27 12:36:19
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-ruby-bindings (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-ruby-bindings.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-ruby-bindings"

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-ruby-bindings/yast2-ruby-bindings.changes  
2014-10-25 08:33:14.000000000 +0200
+++ 
/work/SRC/openSUSE:Factory/.yast2-ruby-bindings.new/yast2-ruby-bindings.changes 
    2015-01-27 12:36:22.000000000 +0100
@@ -1,0 +2,12 @@
+Thu Jan 22 14:56:52 UTC 2015 - jreidin...@suse.com
+
+- enhance usability of Yast::Term class
+- 3.1.27
+
+-------------------------------------------------------------------
+Thu Jan 22 11:46:58 UTC 2015 - an...@suse.com
+
+- Added some RSpec helpers to easy the development of tests
+- 3.1.26
+
+-------------------------------------------------------------------

Old:
----
  yast2-ruby-bindings-3.1.25.tar.bz2

New:
----
  yast2-ruby-bindings-3.1.27.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yast2-ruby-bindings.spec ++++++
--- /var/tmp/diff_new_pack.lXpJRL/_old  2015-01-27 12:36:22.000000000 +0100
+++ /var/tmp/diff_new_pack.lXpJRL/_new  2015-01-27 12:36:22.000000000 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package yast2-ruby-bindings
 #
-# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-ruby-bindings
-Version:        3.1.25
+Version:        3.1.27
 Release:        0
 Url:            https://github.com/yast/yast-ruby-bindings
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
@@ -28,12 +28,17 @@
 BuildRequires:  gcc-c++
 BuildRequires:  yast2-core-devel
 BuildRequires:  yast2-devtools >= 3.1.10
-# libzypp-devel is missing .la requires
-BuildRequires:  ruby-devel
+%if 0%{suse_version} == 1310
+BuildRequires:  rubygem-fast_gettext
+BuildRequires:  rubygem-rspec
+Requires:       rubygem-fast_gettext
+%else
 BuildRequires:  rubygem(%{rb_default_ruby_abi}:fast_gettext)
 BuildRequires:  rubygem(%{rb_default_ruby_abi}:rspec)
-Requires:       yast2-core >= 2.24.0
 Requires:       rubygem(%{rb_default_ruby_abi}:fast_gettext)
+%endif
+BuildRequires:  ruby-devel
+Requires:       yast2-core >= 2.24.0
 BuildRequires:  yast2-core-devel >= 2.24.0
 Requires:       yast2-ycp-ui-bindings       >= 2.21.9
 BuildRequires:  yast2-ycp-ui-bindings-devel >= 2.21.9

++++++ yast2-ruby-bindings-3.1.25.tar.bz2 -> yast2-ruby-bindings-3.1.27.tar.bz2 
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ruby-bindings-3.1.25/.travis.yml 
new/yast2-ruby-bindings-3.1.27/.travis.yml
--- old/yast2-ruby-bindings-3.1.25/.travis.yml  2014-10-20 14:05:09.000000000 
+0200
+++ new/yast2-ruby-bindings-3.1.27/.travis.yml  2015-01-26 17:45:12.000000000 
+0100
@@ -2,14 +2,12 @@
 compiler:
     - gcc
 before_install:
-    - curl 
http://download.opensuse.org/repositories/YaST:/Head:/Travis/xUbuntu_12.04/Release.key
 | sudo apt-key add -
-    - echo "deb 
http://download.opensuse.org/repositories/YaST:/Head:/Travis/xUbuntu_12.04/ ./" 
| sudo tee -a /etc/apt/sources.list
-    - sudo apt-get update -q
-    - sudo apt-get install --no-install-recommends -y docbook-xsl xsltproc 
yast2-core-dev yast2-devtools libxcrypt-dev cmake yast2-ycp-ui-bindings-dev 
ruby2.1 ruby2.1-dev ruby-rspec ruby-fast-gettext
-    - sudo apt-get --reinstall install language-pack-en language-pack-cs
     # disable rvm, use system Ruby
     - rvm reset
+    - wget 
https://raw.githubusercontent.com/yast/yast-devtools/master/travis-tools/travis_setup.sh
+    - sh ./travis_setup.sh -p "docbook-xsl xsltproc yast2-core-dev 
yast2-devtools libxcrypt-dev cmake yast2-ycp-ui-bindings-dev ruby2.1 
ruby2.1-dev rake ruby-fast-gettext language-pack-en language-pack-cs" -g 
"yast-rake rspec:2.14.1"
 script:
+    - rake check:syntax
     # TODO FIXME: hack for Travis build, cmake includes 
"/usr/include/ruby-2.1.0/x86_64-linux-gnu"
     # instead of "/usr/include/x86_64-linux-gnu/ruby-2.1.0"
     - export CXXFLAGS=-I/usr/include/x86_64-linux-gnu/ruby-2.1.0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ruby-bindings-3.1.25/README.md 
new/yast2-ruby-bindings-3.1.27/README.md
--- old/yast2-ruby-bindings-3.1.25/README.md    2014-10-20 14:05:09.000000000 
+0200
+++ new/yast2-ruby-bindings-3.1.27/README.md    2015-01-26 17:45:12.000000000 
+0100
@@ -3,82 +3,88 @@
 Travis:  [![Build 
Status](https://travis-ci.org/yast/yast-ruby-bindings.svg?branch=master)](https://travis-ci.org/yast/yast-ruby-bindings)
 Jenkins: [![Jenkins 
Build](http://img.shields.io/jenkins/s/https/ci.opensuse.org/yast-ruby-bindings-master.svg)](https://ci.opensuse.org/view/Yast/job/yast-ruby-bindings-master/)
 
-
 It is part of [YaST](http://yast.github.io) where you can find more information
-about YaST and its component system. Ruby bindings covers only connection to
-component system and provide some ruby helpers.
+about YaST and its component system. The Ruby bindings cover only the 
connection to
+the component system and provide some Ruby helpers.
 
-It starts as experimental project to allow writting in ruby, but after decision
-to switch from own language YCP to ruby, it is major part of YaST needed by
-almost all parts. Relict from language switch is construct to keep backward
-compatibility, then need human decision to remove it.
+It started as an experimental project to allow writting in Ruby, but after a 
decision
+to switch from an own language YCP to Ruby, it is a major part of YaST needed 
by
+almost all parts. As a relict from the language switch it contains constructs
+to keep backward compatibility which need a human decision before being 
removed.
 
 ## Features
 
 ### Publish, Import and Include
-Connection to YaST component system has two parts. The first one is ability
-to be called from component system. Clients can be called via WFM (see below )
-and modules provide interface via publish method, where is specified type.
+
+The connection to the [YaST component system][arch] has two parts.
+The first one is the ability
+to be called from the component system. *Clients* can be called via WFM (see 
below )
+and *modules* provide an interface via the `publish` method, where the type
+signature is specified.
 Publish is very similar to dbus interface provision. For more details see 
inline
-documentation of {Yast::Exportable#publish}. If method is needed only from 
ruby,
-then publish is not needed.
+documentation of {Yast::Exportable#publish}. If a method is needed only from 
Ruby,
+then `publish` is not needed.
 
-The second part is calling methods from component system. Clients are called
-via WFM (see below). Methods from modules are imported with {Yast.import}, that
-load component and create ruby object in Yast namespace from it, on which can 
be
-called exported methods. Note that calling from ruby to ruby published methods
-are optimized, so it do not go thrue component system resulting in no speed
-penalty. If call is done from ruby to ruby, then it is not limited by component
-system and its protocol, so all ruby features can be used.
+[arch]: https://yastgithubio.readthedocs.org/en/latest/architecture/
+
+The second part is calling methods from the component system. *Clients* are 
called
+via WFM (see below). Methods from *modules* are imported with {Yast.import}, 
which
+loads a component and creates a Ruby object in the Yast namespace from it, on 
which
+exported methods can be called.
+Note that if a call is done from Ruby to Ruby, then it is not limited
+by the component
+system and its protocol, so all Ruby features can be used.
 
 ```ruby
-# how to import module and call it
+# how to import a module and call it
 require "yast"
 Yast.import "IP"
-puts Yast::IP.Valid4
+puts Yast::IP.Check4("127.0.0.333")
 ```
 
-Relict from transformation from ycp to ruby is {Yast.include} which adds 
methods
-from included class to passed object. It is very similar to ruby `include` with
-exception Include object can include other Include objects and thus there is
-special constructor instead of common ruby `included`.
+A relict from the transformation from YCP to Ruby is {Yast.include} which adds 
methods
+from the included class to passed object. It is very similar to Ruby `include` 
with
+the exception that an Include object can include other Include objects and 
thus there is
+a special constructor instead of common Ruby `included`.
 
 ### Ruby Helpers
-Ruby bindings provides set of various helpers for work with YaST component
-system or to make translation from ycp to ruby easier. Here is overview of
-important provided classes with link to inline documentation and short 
explanation:
-
-* {Yast::ArgRef} class to be used for passing arguments by reference. Works
-  even for ruby immutable types like Fixnum or Symbol.
-* {Yast::Builtins} module contains ycp builtins that need to be simulated in
-  ruby. For new code it should not be used.
-* {Yast::Client} base class for clients in ruby. It is not required.
-  Just add helpers.
-* {Yast::Convert} simulate type conversion. Not needed in new code.
-* {Yast::Exportable} provides method publish ( see above )
-* {Yast::FunRef} container used to pass reference to method to component 
system.
-* {Yast::I18n} Provides methods used for translations.
-* {Yast::Module} base class for YaST modules in ruby. It is not required.
-  Just add helpers.
-* {Yast::Ops} module contains ycp operators that need to be simulated in
-  ruby. For new code it should not be used.
-* {Yast::Path} represents path type from YCP protocol.
-* {Yast::SCR} allows usage of SCR component for communication with system.
-* {Yast::Term} represents term type from YCP protocol. Often used for UI.
-* {Yast::WFM} allows usage of WFM component. WFM is used to call clients, gets
-  argument from call and for setting new SCR instance as global one.
-* {Yast::Y2Logger} ruby logger configured to work like yast log with proper
-  place to use. Module {Yast::Logger} provides easy access to log via method
+
+Ruby bindings provide a set of various helpers for working with the YaST 
component
+system or for making the translation from YCP to Ruby easier. Here is an 
overview of
+important provided classes with links to the inline documentation and a short 
explanation:
+
+* {Yast::ArgRef}: a class to be used for passing arguments by reference. Works
+  even for Ruby immutable types like Fixnum or Symbol.
+* {Yast::Builtins}: this module contains YCP builtins that need to be 
simulated in
+  Ruby. For new code it should not be used.
+* {Yast::Client}: a base class for clients in Ruby. It is not strictly
+  required to inherit from it, but it adds useful helpers.
+* {Yast::Convert}: simulates type conversion. Not needed in new code.
+* {Yast::Exportable}: provides the method `publish` (see above).
+* {Yast::FunRef}: a container used to pass references to methods to the 
component system.
+* {Yast::I18n}: provides methods used for translations.
+* {Yast::Module}: a base class for YaST modules in Ruby. It is not strictly
+  required to inherit from it, but it adds useful helpers.
+* {Yast::Ops}: this module contains YCP operators that need to be simulated in
+  Ruby. For new code it should not be used.
+* {Yast::Path}: represents the path type from the YCP protocol.
+* {Yast::SCR}: allows usage of SCR component for communication with the Linux 
system.
+* {Yast::Term}: represents the term type from the YCP protocol. Often used for 
UI.
+* {Yast::WFM}: allows usage of WFM component. WFM is used for calling clients,
+  and for setting a new SCR instance as the global one.
+* {Yast::Y2Logger}: a Ruby Logger configured to work with the YaST log with 
proper
+  place to use. The Ruby module {Yast::Logger} provides easy access via the 
method
   `log`.
-* {Yast} namespace itself contains few helpers to be used. It contains
-  shortcuts and method for deep copy of object.
+* {Yast}: the namespace itself contains a few helpers to be used. It contains
+  shortcuts and a method for a deep copy of an object.
 
 ### UI Shortcuts
-{Yast::UIShortcuts} provides shortcut to UI terms. It is useful to construct
+
+{Yast::UIShortcuts} provides shortcuts for UI terms. It is useful to construct
 dialogs or even popups.
 
 ```ruby
-# usage with term
+# usage with Term
 content = Yast::Term.new(
   :ButtonBox,
   Yast::Term.new(
@@ -102,37 +108,67 @@
 ```
 
 ### Testing
-YaST team encourages to use rspec for testing YaST code in ruby. There is
-a plan to create helper to allow easier testing.
+
+The YaST team encourages to use RSpec for testing YaST code in Ruby. To help in
+that task, this gem includes some RSpec extensions under the {Yast::RSpec}
+namespace. In order to use these extensions, the following line must be added
+to the tests.
+
+```ruby
+require 'yast/rspec'
+```
+
+For example, the following code makes use of the #path helper provided by
+{Yast::RSpec::Shortcuts}.
+
+```ruby
+
+require 'yast/rspec'
+
+describe ".proc.meminfo agent" do
+  it "returns a Hash" do
+    value = Yast::SCR.Read(path(".proc.meminfo"))
+    expect(value).to be_a(Hash)
+  end
+end
+```
 
 ### Further Information
 
 More information about YaST can be found on its 
[homepage](http://yast.github.io).
-More information about ruby bindings can be found in generated documentation.
+More information about Ruby bindings can be found in the generated 
documentation.
 
 ## Packager information
-### How to compile
-Use latest yast2-devtools. then use this calls:
-```
+
+### How to Compile
+
+Use the latest yast2-devtools, then use these calls:
+
+```bash
 mkdir build
 cd build
 cmake ..
 make
 ```
 
-### How to install
-Compile it and from build directory call as root
-```
+### How to Install
+
+Compile it, and from the `build` directory call as root:
+
+```bash
 make install
 ```
 
-### How to create tarball
-compile and from build directory call
-```
-make srcpackage
+### How to Create a Tarball
+
+```bash
+rake package
 ```
-Then in package subdir is sources.
 
+Then the RPM sources are in the `package` subdirectory.
 
 ### Exception handling
-When ruby code raise exception, then method return `nil` in YCP and add method 
last_exception, that returns message of exception. Also exception details are 
logged.
+
+If Ruby code raises an exception, then the method returns `nil` to YCP,
+and the method `last_exception` returns the message of the exception.
+Also, exception details are logged.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ruby-bindings-3.1.25/Rakefile 
new/yast2-ruby-bindings-3.1.27/Rakefile
--- old/yast2-ruby-bindings-3.1.25/Rakefile     2014-10-20 14:05:09.000000000 
+0200
+++ new/yast2-ruby-bindings-3.1.27/Rakefile     2015-01-26 17:45:12.000000000 
+0100
@@ -4,4 +4,3 @@
   #lets ignore license check for now
   conf.skip_license_check << /.*/
 end
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ruby-bindings-3.1.25/package/yast2-ruby-bindings.changes 
new/yast2-ruby-bindings-3.1.27/package/yast2-ruby-bindings.changes
--- old/yast2-ruby-bindings-3.1.25/package/yast2-ruby-bindings.changes  
2014-10-20 14:05:09.000000000 +0200
+++ new/yast2-ruby-bindings-3.1.27/package/yast2-ruby-bindings.changes  
2015-01-26 17:45:12.000000000 +0100
@@ -1,4 +1,16 @@
 -------------------------------------------------------------------
+Thu Jan 22 14:56:52 UTC 2015 - jreidin...@suse.com
+
+- enhance usability of Yast::Term class
+- 3.1.27
+
+-------------------------------------------------------------------
+Thu Jan 22 11:46:58 UTC 2015 - an...@suse.com
+
+- Added some RSpec helpers to easy the development of tests
+- 3.1.26
+
+-------------------------------------------------------------------
 Mon Oct 20 11:59:06 UTC 2014 - lsle...@suse.cz
 
 - added Travis support (.travis.yml, xcrypt.h detection)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ruby-bindings-3.1.25/package/yast2-ruby-bindings.spec 
new/yast2-ruby-bindings-3.1.27/package/yast2-ruby-bindings.spec
--- old/yast2-ruby-bindings-3.1.25/package/yast2-ruby-bindings.spec     
2014-10-20 14:05:09.000000000 +0200
+++ new/yast2-ruby-bindings-3.1.27/package/yast2-ruby-bindings.spec     
2015-01-26 17:45:12.000000000 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-ruby-bindings
-Version:        3.1.25
+Version:        3.1.27
 Url:            https://github.com/yast/yast-ruby-bindings
 Release:        0
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
@@ -28,11 +28,16 @@
 BuildRequires:  gcc-c++
 BuildRequires:  yast2-core-devel
 BuildRequires:  yast2-devtools >= 3.1.10
-# libzypp-devel is missing .la requires
-BuildRequires:  ruby-devel
+%if 0%{suse_version} == 1310
+BuildRequires:  rubygem-fast_gettext
+BuildRequires:  rubygem-rspec
+Requires:       rubygem-fast_gettext
+%else
 BuildRequires:  rubygem(%{rb_default_ruby_abi}:fast_gettext)
 BuildRequires:  rubygem(%{rb_default_ruby_abi}:rspec)
 Requires:       rubygem(%{rb_default_ruby_abi}:fast_gettext)
+%endif
+BuildRequires:  ruby-devel
 Requires:       yast2-core >= 2.24.0
 BuildRequires:  yast2-core-devel >= 2.24.0
 Requires:       yast2-ycp-ui-bindings       >= 2.21.9
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ruby-bindings-3.1.25/src/ruby/CMakeLists.txt 
new/yast2-ruby-bindings-3.1.27/src/ruby/CMakeLists.txt
--- old/yast2-ruby-bindings-3.1.25/src/ruby/CMakeLists.txt      2014-10-20 
14:05:09.000000000 +0200
+++ new/yast2-ruby-bindings-3.1.27/src/ruby/CMakeLists.txt      2015-01-26 
17:45:12.000000000 +0100
@@ -1,6 +1,8 @@
 add_definitions(-DY2LOG=\"Ruby\")
 
 FILE(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/*/*.rb")
+FILE(GLOB rspec "${CMAKE_CURRENT_SOURCE_DIR}/yast/rspec/*.rb")
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/yast.rb DESTINATION 
${RUBY_VENDORLIB_DIR} )
 INSTALL(FILES ${files} DESTINATION ${RUBY_VENDORLIB_DIR}/yast)
+INSTALL(FILES ${rspec} DESTINATION ${RUBY_VENDORLIB_DIR}/yast/rspec)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ruby-bindings-3.1.25/src/ruby/yast/rspec/scr.rb 
new/yast2-ruby-bindings-3.1.27/src/ruby/yast/rspec/scr.rb
--- old/yast2-ruby-bindings-3.1.25/src/ruby/yast/rspec/scr.rb   1970-01-01 
01:00:00.000000000 +0100
+++ new/yast2-ruby-bindings-3.1.27/src/ruby/yast/rspec/scr.rb   2015-01-26 
17:45:12.000000000 +0100
@@ -0,0 +1,101 @@
+require "rspec"
+require "yast"
+
+module Yast
+  module RSpec
+    # RSpec extension to handle several agent operations.
+    module SCR
+      # Encapsulates SCR calls into a chroot.
+      #
+      # If a block if given, the SCR calls in the block are executed in the
+      # chroot and the corresponding SCR instance is automatically closed when
+      # the block ends (or if an exception is raised by the block).
+      #
+      # If a block is not given, the chroot must be explicitly closed calling
+      # reset_root_path.
+      #
+      # Nesting of chroots is forbidden and the method will raise an exception
+      # if is called without closing a previous chroot.
+      #
+      # @param directory [#to_s] directory to use as '/' for SCR calls
+      #
+      # @example Usage with a block
+      #   change_scr_root("/home/chroot1") do
+      #     # This reads the content of /home/chroot1/
+      #     Yast::SCR.Read(path(".target.dir"), "/")
+      #   end
+      #
+      # @example Usage without a block
+      #   change_scr_root("/home/chroot1")
+      #   # This reads the content of /home/chroot1/
+      #   Yast::SCR.Read(path(".target.dir"), "/")
+      #   reset_scr_root
+      #
+      # @example Usage within RSpec
+      #   describe YaST::SCR do
+      #     around { |example| change_scr_root("/home/chroot1", &example) }
+      #
+      #     describe "#Read" do
+      #       it "works with the .proc.meminfo path"
+      #         # This reads from /home/chroot1/proc/meminfo
+      #         values = Yast::SCR.Read(path(".proc.meminfo"))
+      #         expect(values).to include("key" => "value")
+      #       end
+      #     end
+      #   end
+      def change_scr_root(directory)
+        if @scr_handle
+          raise "There is already an open chrooted SCR instance, "\
+            "a call to reset_scr_root was expected"
+        end
+
+        if !File.directory?(directory)
+          raise "#{directory} is not a valid directory"
+        end
+
+        @scr_original_handle = Yast::WFM.SCRGetDefault
+        check_version = false
+        @scr_handle = Yast::WFM.SCROpen("chroot=#{directory}:scr", 
check_version)
+        if @scr_handle < 0
+          @scr_handle = nil
+          @scr_original_handle = nil
+          raise "Error creating the chrooted SCR instance"
+        end
+        Yast::WFM.SCRSetDefault(@scr_handle)
+
+        if block_given?
+          begin
+            yield
+          ensure
+            reset_scr_root
+          end
+        end
+      end
+
+      # Resets the SCR calls to prior behaviour, closing the SCR instance open
+      # by the call to #change_scr_root.
+      #
+      # Raises an exception if #change_scr_root has not been called before or 
if
+      # the corresponding instance has already been closed.
+      #
+      # @see #change_scr_root
+      def reset_scr_root
+        if @scr_handle.nil?
+          raise "Unable to find a chrooted SCR instance to close"
+        end
+
+        default_handle = Yast::WFM.SCRGetDefault
+        if default_handle != @scr_handle
+          raise "Error closing the chrooted SCR instance, "\
+            "it's not the current default one"
+        end
+
+        Yast::WFM.SCRClose(default_handle)
+        Yast::WFM.SCRSetDefault(@scr_original_handle)
+      ensure
+        @scr_handle = nil
+        @scr_original_handle = nil
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ruby-bindings-3.1.25/src/ruby/yast/rspec/shortcuts.rb 
new/yast2-ruby-bindings-3.1.27/src/ruby/yast/rspec/shortcuts.rb
--- old/yast2-ruby-bindings-3.1.25/src/ruby/yast/rspec/shortcuts.rb     
1970-01-01 01:00:00.000000000 +0100
+++ new/yast2-ruby-bindings-3.1.27/src/ruby/yast/rspec/shortcuts.rb     
2015-01-26 17:45:12.000000000 +0100
@@ -0,0 +1,17 @@
+require "rspec"
+require "yast"
+
+module Yast
+  module RSpec
+    # RSpec extension adding commodity shortcuts to enhance readability
+    module Shortcuts
+      # 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
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ruby-bindings-3.1.25/src/ruby/yast/rspec.rb 
new/yast2-ruby-bindings-3.1.27/src/ruby/yast/rspec.rb
--- old/yast2-ruby-bindings-3.1.25/src/ruby/yast/rspec.rb       1970-01-01 
01:00:00.000000000 +0100
+++ new/yast2-ruby-bindings-3.1.27/src/ruby/yast/rspec.rb       2015-01-26 
17:45:12.000000000 +0100
@@ -0,0 +1,7 @@
+require 'yast/rspec/scr'
+require 'yast/rspec/shortcuts'
+
+RSpec.configure do |c|
+  c.include Yast::RSpec::Shortcuts
+  c.include Yast::RSpec::SCR
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ruby-bindings-3.1.25/src/ruby/yast/term.rb 
new/yast2-ruby-bindings-3.1.27/src/ruby/yast/term.rb
--- old/yast2-ruby-bindings-3.1.25/src/ruby/yast/term.rb        2014-10-20 
14:05:09.000000000 +0200
+++ new/yast2-ruby-bindings-3.1.27/src/ruby/yast/term.rb        2015-01-26 
17:45:12.000000000 +0100
@@ -1,11 +1,40 @@
+require "forwardable"
+
 require 'yast/yast'
 require 'yast/builtins'
 require 'yast/ops'
 
 module Yast
-  # Represents YCP type term
+  # Represents YCP type term enhanced by some ruby convenient methods
+  #
+  # Terms can be compared and can act like array of params with mark alias 
value.
   class Term
     include Comparable
+    extend Forwardable
+    include Enumerable
+
+    # @!method each
+    #   Delegated directly to params
+    #   @see Array#each
+    # @!method size
+    #   @return [Integer] size of params
+    #   @see Array#size
+    # @!method empty?
+    #   @return [true,false] if params are empty
+    #   @see Array#empty?
+    # @!method []
+    #   Access element of params
+    #   @see Array#[]
+    # @!method []=
+    #   Assign element to params
+    #   @see Array#[]=
+    # @!method []=
+    #   Assign element to params
+    #   @see Array#[]=
+    # @!method <<
+    #   Append element to params
+    #   @see Array#<<
+    def_delegators :@params, :each, :size, :empty?, :[], :[]=, :<<
 
     # term symbol
     attr_reader :value
@@ -17,17 +46,37 @@
       @params = params
     end
 
-    def [] index
-      params[index]
-    end
-
-    def []= index, value
-      params[index] = value
-    end
+    # Find Object that match block even if it is in deep structure
+    # of nested terms
+    # @return [Object, nil] returns nil if doesn't find matching element
+    # @example how to find widget in complex term
+    #   # UIShortcuts included
+    #   content = VBox(
+    #               HBox(
+    #                 VBox(
+    #                   Hbox(
+    #                     InputField(Id(:input1), "Input1"),
+    #                     InputField(Id(:input2), "Input2")
+    #                   )
+    #                 )
+    #               )
+    #             )
+    #  last_hbox = content.nested_find do |t|
+    #                t.all? { |i| i.value == :InputField }
+    #              end
+    #  last_hbox << InputField(Id(:input3), "Input3") if more_info?
+    #
+    def nested_find(&block)
+      res = find(&block)
+      return res if res
+
+      each do |o|
+        next unless o.respond_to?(:nested_find)
+        res = o.nested_find(&block)
+        break if res
+      end
 
-    # gets number of parameters
-    def size
-      params.size
+      res
     end
 
     def clone
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ruby-bindings-3.1.25/tests/ruby/builtins_spec.rb 
new/yast2-ruby-bindings-3.1.27/tests/ruby/builtins_spec.rb
--- old/yast2-ruby-bindings-3.1.25/tests/ruby/builtins_spec.rb  2014-10-20 
14:05:09.000000000 +0200
+++ new/yast2-ruby-bindings-3.1.27/tests/ruby/builtins_spec.rb  2015-01-26 
17:45:12.000000000 +0100
@@ -898,7 +898,7 @@
     [ "test", Yast::Term.new(:test) ],
     [ :test, Yast::Term.new(:test) ],
     [ [:test, [:lest, :srst]], Yast::Term.new(:test, :lest, :srst) ],
-    [ Yast::Term.new(:test), Yast::Term.new(:test) ],
+    [ [Yast::Term.new(:test)], Yast::Term.new(:test) ]
   ]
 
   it "tests toterm" do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ruby-bindings-3.1.25/tests/ruby/rspec_scr_spec.rb 
new/yast2-ruby-bindings-3.1.27/tests/ruby/rspec_scr_spec.rb
--- old/yast2-ruby-bindings-3.1.25/tests/ruby/rspec_scr_spec.rb 1970-01-01 
01:00:00.000000000 +0100
+++ new/yast2-ruby-bindings-3.1.27/tests/ruby/rspec_scr_spec.rb 2015-01-26 
17:45:12.000000000 +0100
@@ -0,0 +1,120 @@
+#!/usr/bin/env rspec
+
+require_relative "test_helper"
+
+require "yast/rspec"
+
+describe Yast::RSpec::SCR do
+  let(:chroot) { File.join(File.dirname(__FILE__), "chroot") }
+
+  class DummyError < Exception; end
+
+  def root_content
+    Yast::SCR.Read(path(".target.dir"), "/")
+  end
+
+  describe "#change_scr_root" do
+    describe "file check" do
+      it "raises an exception if the directory does not exist" do
+        expect { change_scr_root("not/found/file") }.
+          to raise_exception(RuntimeError, /not a valid directory/)
+      end
+
+      it "raises an exception if called on a regular file" do
+        expect { change_scr_root(File.join(chroot, "just_a_file")) }.
+          to raise_exception(RuntimeError, /not a valid directory/)
+      end
+    end
+
+    describe "block syntax" do
+      it "changes the root path inside the block" do
+        expect(root_content).not_to eq(["just_a_file"])
+        change_scr_root(chroot) do
+          expect(root_content).to eq(["just_a_file"])
+        end
+      end
+
+      it "restores the original path after running the block" do
+        change_scr_root(chroot) do
+          # Do something in the chroot
+        end
+        expect(root_content).not_to eq(["just_a_file"])
+      end
+
+      it "restores the original path after a exception" do
+        begin
+          change_scr_root(chroot) do
+            raise DummyError
+          end
+        rescue DummyError
+          # Just catch the exception
+        end
+        expect(root_content).not_to eq(["just_a_file"])
+      end
+
+      it "raises an exception for nested calls" do
+        change_scr_root(chroot) do
+          expect { change_scr_root(chroot) }.
+            to raise_exception(RuntimeError, /reset_scr_root was expected/)
+        end
+        expect(root_content).not_to eq(["just_a_file"])
+      end
+    end
+
+    describe "usage with an around hook" do
+      around { |example| change_scr_root(chroot, &example) }
+
+      it "changes the root path within the example" do
+        expect(root_content).to eq(["just_a_file"])
+      end
+
+      it "raises an exception for nested calls" do
+        expect { change_scr_root(chroot) }.
+          to raise_exception(RuntimeError, /reset_scr_root was expected/)
+      end
+    end
+
+    describe "non-block syntax" do
+      after do
+        reset_scr_root
+      end
+
+      it "changes the root path" do
+        expect(root_content).not_to eq(["just_a_file"])
+        change_scr_root(chroot)
+        expect(root_content).to eq(["just_a_file"])
+      end
+
+      it "raises an exception for consecutive calls" do
+        change_scr_root(chroot)
+        expect { change_scr_root(chroot) }.
+          to raise_exception(RuntimeError, /reset_scr_root was expected/)
+      end
+    end
+  end
+
+  describe "#reset_scr_root" do
+    it "restores the original path" do
+      change_scr_root(chroot)
+      reset_scr_root
+      expect(root_content).not_to eq(["just_a_file"])
+    end
+
+    it "raises an exception if #change_scr_root was not called before" do
+      expect { reset_scr_root }.
+        to raise_exception(RuntimeError, /Unable to find a chrooted SCR/)
+    end
+
+    it "raises an exception if default SCR was modified" do
+      original_handle = Yast::WFM.SCRGetDefault
+      change_scr_root(chroot)
+
+      # Manually close the chroot
+      Yast::WFM.SCRClose(Yast::WFM.SCRGetDefault)
+      Yast::WFM.SCRSetDefault(original_handle)
+
+      expect { reset_scr_root }.
+        to raise_exception(RuntimeError, /not the current default/)
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ruby-bindings-3.1.25/tests/ruby/rspec_shortcuts_spec.rb 
new/yast2-ruby-bindings-3.1.27/tests/ruby/rspec_shortcuts_spec.rb
--- old/yast2-ruby-bindings-3.1.25/tests/ruby/rspec_shortcuts_spec.rb   
1970-01-01 01:00:00.000000000 +0100
+++ new/yast2-ruby-bindings-3.1.27/tests/ruby/rspec_shortcuts_spec.rb   
2015-01-26 17:45:12.000000000 +0100
@@ -0,0 +1,13 @@
+#!/usr/bin/env rspec
+
+require_relative "test_helper"
+
+require "yast/rspec"
+
+describe Yast::RSpec::Shortcuts do
+  describe "#path" do
+    it "returns the expected Yast::Path object" do
+      expect(path(".target.dir")).to eq(Yast::Path.new(".target.dir"))
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ruby-bindings-3.1.25/tests/ruby/term_spec.rb 
new/yast2-ruby-bindings-3.1.27/tests/ruby/term_spec.rb
--- old/yast2-ruby-bindings-3.1.25/tests/ruby/term_spec.rb      2014-10-20 
14:05:09.000000000 +0200
+++ new/yast2-ruby-bindings-3.1.27/tests/ruby/term_spec.rb      2015-01-26 
17:45:12.000000000 +0100
@@ -9,33 +9,123 @@
 
 require "yast/term"
 
-describe "TermTest" do
-  it "tests initialize" do
-    expect(Yast::Term.new(:HBox).value).to eq(:HBox)
-    expect(Yast::Term.new(:HBox).params).to eq([])
-    expect(Yast::Term.new(:HBox, "test").params).to eq(["test"])
-    expect(Yast::Term.new(:HBox, "test").params.first).to eq("test")
+describe Yast::Term do
+  def term(*params)
+    Yast::Term.new(*params)
+  end
+
+  describe ".new" do
+    context "with single parameter" do
+      it "sets value to parameter" do
+        expect(term(:HBox).value).to eq(:HBox)
+      end
+
+      it "have empty params" do
+        expect(term(:HBox).params).to eq([])
+      end
+    end
+
+    context "with more parameters" do
+      it "set all parameters except first one to params array" do
+        expect(term(:HBox, "test").params).to eq(["test"])
+      end
+    end
+  end
+
+  describe "#[]=" do
+    it "updates inplace parameters" do
+      t = term(:HBox, 1, 2)
+      t.params[0] = 0
+      expect(t.params.first).to eq(0)
+    end
+  end
+
+  describe "#[]" do
+    it "returns elements from params on given index" do
+      t = term(:HBox, 1, 2)
+      expect(t.params[0]).to eq(1)
+    end
+  end
+
+  describe "#<<" do
+    it "appends parameter to params" do
+      t = term(:HBox, 1, 2)
+      t << 3
+      expect(t[2]).to eq(3)
+    end
+  end
 
-    expect(Yast::Term.new(:HBox, Yast::Term.new(:VBox)).params.first.value).to 
eq(:VBox)
+  describe "comparison" do
+    it "if value and params are equal, then it is equal terms" do
+      expect(term(:HBox)).to eq(term(:HBox))
+    end
+
+    it "if value are different then terms are not equal" do
+      expect(term(:VBox)).to_not eq(term(:HBox))
+    end
+
+    it "if params are different then terms are not equal" do
+      expect(term(:HBox, "test")).to_not eq(term(:HBox))
+    end
+
+    it "if value are different then it compare value for comparison" do
+      expect(term(:VBox)).to be > term(:HBox)
+    end
+
+    it "if value is equal, then use params to comparison" do
+      expect(term(:HBox, "test")).to be > term(:HBox)
+    end
   end
 
-  it "tests update" do
-    t = Yast::Term.new(:HBox, 1, 2)
-    t.params[0] = 0
-    expect(t.params.first).to eq(0)
+  describe "#size" do
+    it "returns size of params" do
+      expect(term(:HBox).size).to eq(0)
+      expect(term(:HBox, "test").size).to eq(1)
+      expect(term(:HBox, term(:VBox, "test", "test")).size).to eq(1)
+    end
   end
 
-  it "tests equal" do
-    expect(Yast::Term.new(:HBox)).to eq(Yast::Term.new(:HBox))
-    expect(Yast::Term.new(:VBox)).to_not eq(Yast::Term.new(:HBox))
-    expect(Yast::Term.new(:HBox, "test")).to_not eq(Yast::Term.new(:HBox))
+  describe "#empty?" do
+    it "returns if params are empty" do
+      expect(term(:HBox).empty?).to eq(true)
+      expect(term(:HBox, "test").empty?).to eq(false)
+    end
   end
 
-  it "tests size" do
-    expect(Yast::Term.new(:HBox).size).to eq(0)
-    expect(Yast::Term.new(:HBox, "test").size).to eq(1)
-    expect(Yast::Term.new(:HBox, "test").size).to eq(1)
-    expect(Yast::Term.new(:HBox, Yast::Term.new(:VBox, "test", 
"test")).size).to eq(1)
+  describe "Enumerable" do
+    it "includes enumerable module that iterate over params" do
+      t = term(:HBox, 1, 2, 3)
+
+      expect(t).to include(1)
+      expect(t.first).to eq(1)
+
+      expect(t.max).to eq(3)
+
+      nested = term(:HBox, term(:InputField, term(:id, "ID")))
+
+      widget = nested.find do |t|
+        t.include?(term(:id, "ID"))
+      end
+
+      expect(widget.value).to eq :InputField
+    end
   end
 
+  describe "#nested_find" do
+    it "returns object passing block even if it is deep in nested terms" do
+      nested = term(:HBox, term(:VBox, term(:InputField, term(:id, "ID"))))
+
+      widget = nested.nested_find do |t|
+        t.include?(term(:id, "ID"))
+      end
+
+      expect(widget.value).to eq :InputField
+    end
+
+    it "returns nil if it doesn't find any matching object" do
+      nested = term(:HBox, term(:InputField, term(:id, "ID")))
+
+      expect(nested.nested_find{ |o| o == 5 }).to be_nil
+    end
+  end
 end

-- 
To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org
For additional commands, e-mail: opensuse-commit+h...@opensuse.org

Reply via email to