Skip to content

Commit

Permalink
Add first specs; do some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ikapelyukhin committed Feb 21, 2018
1 parent 2dd1ba6 commit 35de742
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 10 deletions.
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper --color spec
17 changes: 16 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-02-20 13:29:43 +0100 using RuboCop version 0.52.1.
# on 2018-02-21 17:27:56 +0100 using RuboCop version 0.52.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -19,6 +19,21 @@ Metrics/MethodLength:
Metrics/PerceivedComplexity:
Max: 14

# Offense count: 6
# Configuration parameters: .
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
EnforcedStyle: receive

# Offense count: 1
RSpec/MultipleExpectations:
Max: 6

# Offense count: 2
RSpec/SubjectStub:
Exclude:
- 'spec/rmt/wizard_spec.rb'

# Offense count: 2
Style/MultipleComparison:
Exclude:
Expand Down
26 changes: 26 additions & 0 deletions spec/rmt/wizard_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require 'rmt/wizard'

Yast.import 'Wizard'
Yast.import 'Sequencer'

describe RMT::Wizard do
subject(:wizard) { described_class.new }

let(:config) { { foo: 'bar' } }

before do
end

it 'runs and goes through the sequence' do
expect(RMT::Base).to receive(:read_config_file).and_return({})

expect(Yast::Wizard).to receive(:CreateDialog)
expect(Yast::Wizard).to receive(:SetTitleIcon)

expect(wizard).to receive(:step1).and_return(:next)
expect(wizard).to receive(:step2).and_return(:next)

expect(Yast::UI).to receive(:CloseDialog)
wizard.run
end
end
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$LOAD_PATH.unshift(File.expand_path('../../src/lib/', __FILE__))

require 'yast'
require 'yast/rspec'

Expand Down
2 changes: 1 addition & 1 deletion src/lib/rmt/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def run_command(command, *params)
params = params.map { |p| String.Quote(p) }

SCR.Execute(
path('.target.bash'),
path('.target.bash'),
Builtins.sformat(command, *params)
)
end
Expand Down
10 changes: 2 additions & 8 deletions src/lib/rmt/wizard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RMT::Wizard < RMT::Base
include Yast::UIShortcuts
include Yast::Logger

def run
def initialize
Yast.import 'UI'
Yast.import 'Wizard'
Yast.import 'Sequencer'
Expand All @@ -40,8 +40,6 @@ def run
textdomain 'rmt'

@config = RMT::Base.read_config_file

run_wizard
end

def step1
Expand All @@ -54,7 +52,7 @@ def step2
page.run
end

def run_wizard
def run
aliases = {
'step1' => -> { step1 },
'step2' => -> { step2 }
Expand All @@ -71,10 +69,6 @@ def run_wizard

Sequencer.Run(aliases, sequence)

Wizard.RestoreNextButton
Wizard.RestoreAbortButton
Wizard.RestoreBackButton

UI.CloseDialog()
end
end

0 comments on commit 35de742

Please sign in to comment.