Skip to content

Commit

Permalink
add test for finish_client and also fix founded bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Nov 20, 2014
1 parent 4810296 commit 808060f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/general/src/lib/installation/finish_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Installation
# ::Installation::ExampleFinish.run
# @see for example client in installation clone_finish.rb
# @see inst_finish in yast2-installation doc to get overview of finish client API
class FinishClient < Client
class FinishClient < Yast::Client
include Yast::Logger

# Entry point for calling client. Only part needed in client rb file.
Expand All @@ -20,7 +20,7 @@ def self.run

# Dispatches to abstract method based on passed arguments to client
def run
func = Yast::WFM.Args
func = Yast::WFM.Args.first
case func
when "Info"
info
Expand Down
1 change: 1 addition & 0 deletions library/general/test/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
TESTS = \
asciifile_test.rb \
finish_client_test.rb \
hooks_test.rb \
linuxrc_test.rb \
os_release_test.rb \
Expand Down
51 changes: 51 additions & 0 deletions library/general/test/finish_client_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
require_relative "test_helper"

require "installation/finish_client"

class TestFinish < ::Installation::FinishClient
def info
"info"
end

def write
"write"
end
end

describe ::Installation::FinishClient do
subject { ::TestFinish }
describe ".run" do
it "raise exception if unknown first argument is passed" do
allow(Yast::WFM).to receive(:Args).and_return(["Unknown", {}])
expect{::Installation::ProposalClient.run}.to raise_error
end

context "first client argument is Info" do
before do
allow(Yast::WFM).to receive(:Args).and_return(["Info"])
end

it "dispatch call to abstract method info" do
expect(subject.run).to eq "info"
end

it "raise NotImplementedError exception if abstract method not defined" do
expect{::Installation::FinishClient.run}.to raise_error(NotImplementedError)
end
end

context "first client argument is Write" do
before do
allow(Yast::WFM).to receive(:Args).and_return(["Write"])
end

it "dispatch call to abstract method write" do
expect(subject.run).to eq "write"
end

it "raise NotImplementedError exception if abstract method not defined" do
expect{::Installation::FinishClient.run}.to raise_error(NotImplementedError)
end
end
end
end

0 comments on commit 808060f

Please sign in to comment.