Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken rspec #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/puppet/provider/wsusgroup/wsusgroup.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
require File.join(File.dirname(__FILE__), '..', 'wsus')

Puppet::Type.type(:wsusgroup).provide(:wsusgroup, :parent => Puppet::Provider::Wsus) do
Puppet::Type.type(:wsusgroup).provide :wsusgroup do
desc "WSUS group"

commands :poshexec =>
Expand All @@ -12,7 +10,7 @@
'powershell.exe'
end

@@connstr= "import-module poshwsus | out-null; $null=(Connect-PoshWSUSServer localhost -port 8530)"
@@connstr= 'import-module poshwsus | out-null; $null=(Connect-PoshWSUSServer localhost -port 8530)'

def exists?
rc=false
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def horizontal_rule(width = 5)
'mocha/setup', # http://gofreerange.com/mocha/docs/Mocha/Configuration.html
'jumanjiman_spec_helper',
'puppet',
'rspec',
]
begin
gems.each {|gem| require gem}
Expand Down
51 changes: 51 additions & 0 deletions spec/unit/puppet/provider/wsusgroup/wsusgroup_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#! /usr/bin/env ruby
require File.dirname(__FILE__) + '/../../../../spec_helper'
require 'puppet'
require 'puppet/type'
require 'puppet/provider/wsusgroup/wsusgroup'

provider = Puppet::Type.type(:wsusgroup).provider(:wsusgroup)

describe provider do

let(:poshexec) {
if File.exists?("#{ENV['SYSTEMROOT']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe")
"#{ENV['SYSTEMROOT']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe"
elsif File.exists?("#{ENV['SYSTEMROOT']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe")
"#{ENV['SYSTEMROOT']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe"
else
'powershell.exe'
end
}

before :each do
@resource = Puppet::Type.type(:wsusgroup).new(
:name => "wsusgroup",
:ensure => :present,
:server => "server.example.com"
)
@provider = provider.new(@resource)
provider.stubs(:healthcheck)
end

context "when an instance" do
it "should have a method for creating the instance" do
@provider.should respond_to(:create)
end

it "should have a method for removing the instance" do
@provider.should respond_to(:destroy)
end

it "should have an exists? method" do
@provider.should respond_to(:exists?)
end
end

context "#create" do
it "should execute wsusgroup create" do
@provider.expects(:wsusgroup).with('create', poshexec)
@provider.create
end
end
end