summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradamedx <adamed@opscode.com>2014-05-17 23:09:11 -0700
committeradamedx <adamed@opscode.com>2014-05-17 23:09:11 -0700
commit78f2a403f09a201acc05416e4e05bde8f850bc0c (patch)
tree8144d2c9a50335d022f25ff7aeed861a610fc0ec
parent9dab7d27e325afd17b337e8124e5e9269f46eaaa (diff)
downloadwmi-lite-adamed/tests.tar.gz
Non-windows fixes for WIN32OLERuntimeErroradamed/tests
-rw-r--r--spec/unit/wmi_spec.rb32
1 files changed, 16 insertions, 16 deletions
diff --git a/spec/unit/wmi_spec.rb b/spec/unit/wmi_spec.rb
index 6ce84fb..dbef353 100644
--- a/spec/unit/wmi_spec.rb
+++ b/spec/unit/wmi_spec.rb
@@ -58,6 +58,7 @@ describe WmiLite::Wmi do
before(:each) do
stub_const('WIN32OLE', Class.new)
WIN32OLE.stub(:new).with("WbemScripting.SWbemLocator").and_return(wbem_locator)
+ stub_const('WIN32OLERuntimeError', Class.new(Exception))
end
let(:wmi) { WmiLite::Wmi.new }
@@ -149,50 +150,49 @@ describe WmiLite::Wmi do
end
shared_examples_for 'an invalid query' do
- before(:each) do
- stub_const('WIN32OLE', Class.new)
- WIN32OLE.stub(:new).with("WbemScripting.SWbemLocator").and_return(wbem_locator)
- end
let(:unparseable_error) { 'unparseableerror' }
it 'should raise an exception' do
- wbem_connection.should_receive(:ExecQuery).and_raise(WIN32OLERuntimeError.new(unparseable_error))
+ wbem_connection.should_receive(:ExecQuery).and_raise(WIN32OLERuntimeError)
wmi_service = WmiLite::Wmi.new
expect { wmi_service.send(query_method, wmi_query) }.to raise_error(WmiLite::WmiException)
end
- it 'should raise an exception that starts with the original exception message' do
+ it 'should raise an exception that ends with the original exception message' do
wbem_connection.should_receive(:ExecQuery).and_raise(WIN32OLERuntimeError.new(unparseable_error))
wmi_service = WmiLite::Wmi.new
+ error_message = nil
begin
wmi_service.send(query_method, wmi_query)
rescue WmiLite::WmiException => e
- expect(e.message.start_with?(unparseable_error)).to eql(false)
- expect(e.message.end_with?(unparseable_error)).to eql(true)
+ error_message = e.message
end
+ expect(error_message).not_to eql(nil)
+ expect(e.message.start_with?(unparseable_error)).to eql(false)
+ expect(e.message.end_with?(unparseable_error)).to eql(true)
end
end
shared_examples_for 'an invalid namespace' do
- before(:each) do
- stub_const('WIN32OLE', Class.new)
- WIN32OLE.stub(:new).with("WbemScripting.SWbemLocator").and_return(wbem_locator)
- end
let(:unparseable_error) { 'unparseableerror' }
it 'should raise an exception' do
- wbem_locator.should_receive(:ConnectServer).and_raise(WIN32OLERuntimeError.new('unparseableerror'))
+ wbem_locator.should_receive(:ConnectServer).and_raise(WIN32OLERuntimeError)
wmi_service = WmiLite::Wmi.new('notavalidnamespace')
expect { wmi_service.send(query_method, wmi_query) }.to raise_error(WmiLite::WmiException)
end
it 'should raise an exception that starts with the original exception message' do
- wbem_locator.should_receive(:ConnectServer).and_raise(WIN32OLERuntimeError.new('unparseableerror'))
+ wbem_locator.should_receive(:ConnectServer).and_raise(WIN32OLERuntimeError.new(unparseable_error))
wmi_service = WmiLite::Wmi.new
+ error_message = nil
begin
wmi_service.send(query_method, wmi_query)
rescue WmiLite::WmiException => e
- expect(e.message.start_with?(unparseable_error)).to eql(false)
- expect(e.message.end_with?(unparseable_error)).to eql(true)
+ error_message = e.message
end
+
+ expect(error_message).not_to eql(nil)
+ expect(error_message.start_with?(unparseable_error)).to eql(false)
+ expect(error_message.end_with?(unparseable_error)).to eql(true)
end
end