Skip to content

Commit

Permalink
(maint) Update specs to use correct helper classes
Browse files Browse the repository at this point in the history
 - Previously, specs were hardcoded to use the Win32::TaskScheduler
   helper during some retrieval and creation style tests, when they
   should be switching the class based on the appropriate helper,
   either PuppetX::PuppetLabs::ScheduledTask::TaskScheduler2V1Task OR
   Win32::TaskScheduler.

   This creates a minor discrepancy in a subsequent commit when
   additional testing is added for compatibility, which is implemented
   only in TaskScheduler2V1Task and *not* Win32::TaskScheduler
  • Loading branch information
Iristyle committed May 4, 2018
1 parent ceaa0bc commit 9d02582
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ def time_component
describe 'when retrieving' do
before :each do
@mock_task = stub
@mock_task.responds_like(Win32::TaskScheduler.new)
@mock_task.responds_like(concrete_klass.new)
described_class.any_instance.stubs(:task).returns(@mock_task)

Win32::TaskScheduler.stubs(:new).returns(@mock_task)
concrete_klass.stubs(:new).returns(@mock_task)
end
let(:resource) { Puppet::Type.type(:scheduled_task).new(:name => 'Test Task', :command => 'C:\Windows\System32\notepad.exe') }

Expand Down Expand Up @@ -1874,7 +1874,7 @@ def time_component
@working_dir = 'C:\Windows\Some\Directory'

@mock_task = stub
@mock_task.responds_like(Win32::TaskScheduler.new)
@mock_task.responds_like(concrete_klass.new)
@mock_task.stubs(:exists?).returns(true)
@mock_task.stubs(:activate)
@mock_task.stubs(:application_name=)
Expand All @@ -1884,9 +1884,13 @@ def time_component
@mock_task.stubs(:flags)
@mock_task.stubs(:flags=)
@mock_task.stubs(:trigger_count).returns(0)
@mock_task.stubs(:trigger=)
if resource.provider.is_a?(Puppet::Type::Scheduled_task::ProviderWin32_taskscheduler)
@mock_task.stubs(:trigger=)
else
@mock_task.stubs(:append_trigger)
end
@mock_task.stubs(:save)
Win32::TaskScheduler.stubs(:new).returns(@mock_task)
concrete_klass.stubs(:new).returns(@mock_task)

described_class.any_instance.stubs(:sync_triggers)
end
Expand Down

0 comments on commit 9d02582

Please sign in to comment.