Skip to content

Commit

Permalink
Unify YaST module mocking in unit tests
Browse files Browse the repository at this point in the history
- Related to bsc#1194784
- 4.4.33
  • Loading branch information
lslezak committed Jan 21, 2022
1 parent 9bc4786 commit 4a535aa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
6 changes: 6 additions & 0 deletions package/yast2-network.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Jan 21 12:35:43 UTC 2022 - Ladislav Slezák <lslezak@suse.cz>

- Unify YaST module mocking in unit tests (related to bsc#1194784)
- 4.4.33

-------------------------------------------------------------------
Mon Dec 6 14:37:01 UTC 2021 - Josef Reidinger <jreidinger@suse.com>

Expand Down
4 changes: 3 additions & 1 deletion package/yast2-network.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-network
Version: 4.4.32
Version: 4.4.33
Release: 0
Summary: YaST2 - Network Configuration
License: GPL-2.0-only
Expand All @@ -43,6 +43,8 @@ BuildRequires: yast2-xml
BuildRequires: rubygem(%rb_default_ruby_abi:cfa) >= 0.6.4
# lenses are needed to use cfa
BuildRequires: augeas-lenses
# yast/rspec/helpers.rb
BuildRequires: yast2-ruby-bindings >= 4.4.7

PreReq: /bin/rm
#netconfig (FaTE #303618)
Expand Down
2 changes: 0 additions & 2 deletions test/install_inf_convertor_test.rb
Expand Up @@ -24,8 +24,6 @@
require "yast"
require "network/install_inf_convertor"

stub_module "Proxy"

describe "InstallInfConvertor" do
context "in case of no network config in /etc/install.inf" do
before(:each) do
Expand Down
24 changes: 5 additions & 19 deletions test/test_helper.rb
Expand Up @@ -82,25 +82,11 @@

DATA_PATH = File.join(__dir__, "data")

# stub module to prevent its Import
# Useful for modules from different yast packages, to avoid build dependencies
def stub_module(name)
stubbed_class = Class.new do
# fake respond_to? to avoid failure of partial doubles
singleton_class.define_method(:respond_to?) do |_mname, _include_all = nil|
true
end

# needed to fake at least one class method to avoid Yast.import
singleton_class.define_method(:fake_method) do
end
end
Yast.const_set(name.to_sym, stubbed_class)
end

# stub classes from other modules to speed up a build
stub_module("AutoInstall")
stub_module("Profile")
# stub classes from other modules to avoid build dependencies
Yast::RSpec::Helpers.define_yast_module("AutoInstall",
methods: [:issues_list, :valid_imported_values])
Yast::RSpec::Helpers.define_yast_module("Profile", methods: [:current])
Yast::RSpec::Helpers.define_yast_module("Proxy", methods: [:Export, :Import, :Read, :Write])

# A two level section/key => value store
# to remember values of /etc/sysconfig/network/ifcfg-*
Expand Down

0 comments on commit 4a535aa

Please sign in to comment.