diff options
Diffstat (limited to 'spec/ruby/library/win32ole')
81 files changed, 1671 insertions, 0 deletions
diff --git a/spec/ruby/library/win32ole/fixtures/classes.rb b/spec/ruby/library/win32ole/fixtures/classes.rb new file mode 100644 index 0000000000..830b1be0b5 --- /dev/null +++ b/spec/ruby/library/win32ole/fixtures/classes.rb @@ -0,0 +1,14 @@ +module WIN32OLESpecs + def self.new_ole(name) + retried = false + begin + WIN32OLE.new(name) + rescue WIN32OLERuntimeError => e + unless retried + retried = true + retry + end + raise e + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole/_getproperty_spec.rb b/spec/ruby/library/win32ole/win32ole/_getproperty_spec.rb new file mode 100644 index 0000000000..650a641f5b --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/_getproperty_spec.rb @@ -0,0 +1,19 @@ +require File.expand_path('../../fixtures/classes', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE#_getproperty" do + before :each do + @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application') + end + + after :each do + @ie.Quit + end + + it "gets name" do + @ie._getproperty(0, [], []).should =~ /explorer/i + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole/_invoke_spec.rb b/spec/ruby/library/win32ole/win32ole/_invoke_spec.rb new file mode 100644 index 0000000000..c2fe9a8490 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/_invoke_spec.rb @@ -0,0 +1,23 @@ +require File.expand_path('../../fixtures/classes', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE#_invoke" do + before :each do + @shell = WIN32OLESpecs.new_ole 'Shell.application' + end + + it "raises ArgumentError if insufficient number of arguments are given" do + lambda { @shell._invoke() }.should raise_error ArgumentError + lambda { @shell._invoke(0) }.should raise_error ArgumentError + lambda { @shell._invoke(0, []) }.should raise_error ArgumentError + end + + it "dispatches the method bound to a specific ID" do + @shell._invoke(0x60020002, [37], [WIN32OLE::VARIANT::VT_VARIANT]).title.should =~ /System32/i + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole/codepage_spec.rb b/spec/ruby/library/win32ole/win32ole/codepage_spec.rb new file mode 100644 index 0000000000..c84593871d --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/codepage_spec.rb @@ -0,0 +1,15 @@ +require File.expand_path('../../fixtures/classes', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE.codepage=" do + it "sets codepage" do + cp = WIN32OLE.codepage + WIN32OLE.codepage = WIN32OLE::CP_UTF8 + WIN32OLE.codepage.should == WIN32OLE::CP_UTF8 + WIN32OLE.codepage = cp + end + end + +end diff --git a/spec/ruby/library/win32ole/win32ole/connect_spec.rb b/spec/ruby/library/win32ole/win32ole/connect_spec.rb new file mode 100644 index 0000000000..ee480a727c --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/connect_spec.rb @@ -0,0 +1,17 @@ +require File.expand_path('../../fixtures/classes', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE.connect" do + it "creates WIN32OLE object given valid argument" do + obj = WIN32OLE.connect("winmgmts:") + obj.should be_kind_of WIN32OLE + end + + it "raises TypeError when given invalid argument" do + lambda { WIN32OLE.connect 1 }.should raise_error TypeError + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole/const_load_spec.rb b/spec/ruby/library/win32ole/win32ole/const_load_spec.rb new file mode 100644 index 0000000000..a3c50f215e --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/const_load_spec.rb @@ -0,0 +1,34 @@ +require File.expand_path('../../fixtures/classes', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE.const_load when passed Shell.Application OLE object" do + before :each do + @win32ole = WIN32OLESpecs.new_ole 'Shell.Application' + end + + it "loads constant SsfWINDOWS into WIN32OLE namespace" do + WIN32OLE.const_defined?(:SsfWINDOWS).should be_false + WIN32OLE.const_load @win32ole + WIN32OLE.const_defined?(:SsfWINDOWS).should be_true + end + end + + describe "WIN32OLE.const_load when namespace is specified" do + before :each do + module WIN32OLE_RUBYSPEC; end + @win32ole = WIN32OLESpecs.new_ole 'Shell.Application' + end + + it "loads constants into given namespace" do + module WIN32OLE_RUBYSPEC; end + + WIN32OLE_RUBYSPEC.const_defined?(:SsfWINDOWS).should be_false + WIN32OLE.const_load @win32ole, WIN32OLE_RUBYSPEC + WIN32OLE_RUBYSPEC.const_defined?(:SsfWINDOWS).should be_true + + end + end + +end diff --git a/spec/ruby/library/win32ole/win32ole/constants_spec.rb b/spec/ruby/library/win32ole/win32ole/constants_spec.rb new file mode 100644 index 0000000000..2a04511305 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/constants_spec.rb @@ -0,0 +1,44 @@ +require File.expand_path('../../fixtures/classes', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE class" do + it "defines constant CP_ACP" do + WIN32OLE::CP_ACP.should == 0 + end + + it "defines constant CP_OEMCP" do + WIN32OLE::CP_OEMCP.should == 1 + end + + it "defines constant CP_MACCP" do + WIN32OLE::CP_MACCP.should == 2 + end + + it "defines constant CP_THREAD_ACP" do + WIN32OLE::CP_THREAD_ACP.should == 3 + end + + it "defines constant CP_SYMBOL" do + WIN32OLE::CP_SYMBOL.should == 42 + end + + it "defines constant CP_UTF7" do + WIN32OLE::CP_UTF7.should == 65000 + end + + it "defines constant CP_UTF8" do + WIN32OLE::CP_UTF8.should == 65001 + end + + it "defines constant LOCALE_SYSTEM_DEFAULT" do + WIN32OLE::LOCALE_SYSTEM_DEFAULT.should == 0x0800 + end + + it "defines constant LOCALE_USER_DEFAULT" do + WIN32OLE::LOCALE_USER_DEFAULT.should == 0x0400 + end + end + +end diff --git a/spec/ruby/library/win32ole/win32ole/create_guid_spec.rb b/spec/ruby/library/win32ole/win32ole/create_guid_spec.rb new file mode 100644 index 0000000000..17a7df10be --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/create_guid_spec.rb @@ -0,0 +1,11 @@ +require File.expand_path('../../fixtures/classes', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE.create_guid" do + it "generates guid with valid format" do + WIN32OLE.create_guid.should =~ /^\{[A-Z0-9]{8}\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{12}/ + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole/invoke_spec.rb b/spec/ruby/library/win32ole/win32ole/invoke_spec.rb new file mode 100644 index 0000000000..41752de359 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/invoke_spec.rb @@ -0,0 +1,19 @@ +require File.expand_path('../../fixtures/classes', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE#invoke" do + before :each do + @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application') + end + + after :each do + @ie.Quit + end + + it "get name by invoking 'Name' OLE method" do + @ie.invoke('Name').should =~ /explorer/i + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole/locale_spec.rb b/spec/ruby/library/win32ole/win32ole/locale_spec.rb new file mode 100644 index 0000000000..7cf4d9bc98 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/locale_spec.rb @@ -0,0 +1,31 @@ +require File.expand_path('../../fixtures/classes', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE.locale" do + it "gets locale" do + WIN32OLE.locale.should == WIN32OLE::LOCALE_SYSTEM_DEFAULT + end + end + + describe "WIN32OLE.locale=" do + it "sets locale to Japanese, if available" do + begin + begin + WIN32OLE.locale = 1041 + rescue WIN32OLERuntimeError + STDERR.puts("\n#{__FILE__}:#{__LINE__}:#{self.class.name}.test_s_locale_set is skipped(Japanese locale is not installed)") + return + end + + WIN32OLE.locale.should == 1041 + WIN32OLE.locale = WIN32OLE::LOCALE_SYSTEM_DEFAULT + lambda { WIN32OLE.locale = 111 }.should raise_error WIN32OLERuntimeError + WIN32OLE.locale.should == WIN32OLE::LOCALE_SYSTEM_DEFAULT + ensure + WIN32OLE.locale.should == WIN32OLE::LOCALE_SYSTEM_DEFAULT + end + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole/new_spec.rb b/spec/ruby/library/win32ole/win32ole/new_spec.rb new file mode 100644 index 0000000000..78f141b608 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/new_spec.rb @@ -0,0 +1,27 @@ +require File.expand_path('../../fixtures/classes', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLESpecs.new_ole" do + it "creates a WIN32OLE object from OLE server name" do + shell = WIN32OLESpecs.new_ole 'Shell.Application' + shell.should be_kind_of WIN32OLE + end + + it "creates a WIN32OLE object from valid CLSID" do + shell = WIN32OLESpecs.new_ole("{13709620-C279-11CE-A49E-444553540000}") + shell.should be_kind_of WIN32OLE + end + + it "raises TypeError if argument cannot be converted to String" do + lambda { WIN32OLESpecs.new_ole(42) }.should raise_error( TypeError ) + end + + it "raises WIN32OLERuntimeError if invalid string is given" do + lambda { WIN32OLESpecs.new_ole('foo') }.should raise_error( WIN32OLERuntimeError ) + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb new file mode 100644 index 0000000000..82b5eb2680 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb @@ -0,0 +1,27 @@ +require File.expand_path('../../fixtures/classes', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE#ole_func_methods" do + before :each do + @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application') + end + + after :each do + @ie.Quit + end + + it "raises ArgumentError if argument is given" do + lambda { @ie.ole_func_methods(1) }.should raise_error ArgumentError + end + + it "returns an array of WIN32OLE_METHODs" do + @ie.ole_func_methods.all? { |m| m.kind_of? WIN32OLE_METHOD }.should be_true + end + + it "contains a 'AddRef' method for Internet Explorer" do + @ie.ole_func_methods.map { |m| m.name }.include?('AddRef').should be_true + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb new file mode 100644 index 0000000000..3ec92d3efc --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb @@ -0,0 +1,18 @@ +require File.expand_path('../../fixtures/classes', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE#ole_get_methods" do + + before :each do + @win32ole = WIN32OLESpecs.new_ole('Shell.Application') + end + + it "returns an array of WIN32OLE_METHOD objects" do + @win32ole.ole_get_methods.all? {|m| m.kind_of? WIN32OLE_METHOD}.should be_true + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole/ole_method_help_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_method_help_spec.rb new file mode 100644 index 0000000000..45b8e93eac --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/ole_method_help_spec.rb @@ -0,0 +1,12 @@ +require File.expand_path('../../fixtures/classes', __FILE__) +require File.expand_path('../shared/ole_method', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE#ole_method_help" do + it_behaves_like :win32ole_ole_method, :ole_method_help + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole/ole_method_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_method_spec.rb new file mode 100644 index 0000000000..cb1d1d172b --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/ole_method_spec.rb @@ -0,0 +1,12 @@ +require File.expand_path('../../fixtures/classes', __FILE__) +require File.expand_path('../shared/ole_method', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE#ole_method" do + it_behaves_like :win32ole_ole_method, :ole_method + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb new file mode 100644 index 0000000000..bba2aa73ae --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb @@ -0,0 +1,27 @@ +require File.expand_path('../../fixtures/classes', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE#ole_methods" do + before :each do + @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application') + end + + after :each do + @ie.Quit + end + + it "raises ArgumentError if argument is given" do + lambda { @ie.ole_methods(1) }.should raise_error ArgumentError + end + + it "returns an array of WIN32OLE_METHODs" do + @ie.ole_methods.all? { |m| m.kind_of? WIN32OLE_METHOD }.should be_true + end + + it "contains a 'AddRef' method for Internet Explorer" do + @ie.ole_methods.map { |m| m.name }.include?('AddRef').should be_true + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb new file mode 100644 index 0000000000..eede93bb87 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb @@ -0,0 +1,23 @@ +require File.expand_path('../../fixtures/classes', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE#ole_obj_help" do + before :each do + @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application') + end + + after :each do + @ie.Quit + end + + it "raises ArgumentError if argument is given" do + lambda { @ie.ole_obj_help(1) }.should raise_error ArgumentError + end + + it "returns an instance of WIN32OLE_TYPE" do + @ie.ole_obj_help.kind_of?(WIN32OLE_TYPE).should be_true + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb new file mode 100644 index 0000000000..5334e7a47d --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb @@ -0,0 +1,27 @@ +require File.expand_path('../../fixtures/classes', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE#ole_put_methods" do + before :each do + @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application') + end + + after :each do + @ie.Quit + end + + it "raises ArgumentError if argument is given" do + lambda { @ie.ole_put_methods(1) }.should raise_error ArgumentError + end + + it "returns an array of WIN32OLE_METHODs" do + @ie.ole_put_methods.all? { |m| m.kind_of? WIN32OLE_METHOD }.should be_true + end + + it "contains a 'Height' method for Internet Explorer" do + @ie.ole_put_methods.map { |m| m.name }.include?('Height').should be_true + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole/setproperty_spec.rb b/spec/ruby/library/win32ole/win32ole/setproperty_spec.rb new file mode 100644 index 0000000000..ae08e63f78 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/setproperty_spec.rb @@ -0,0 +1,12 @@ +require File.expand_path('../../fixtures/classes', __FILE__) +require File.expand_path('../shared/setproperty', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE#setproperty" do + it_behaves_like :win32ole_setproperty, :setproperty + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole/shared/ole_method.rb b/spec/ruby/library/win32ole/win32ole/shared/ole_method.rb new file mode 100644 index 0000000000..668000c1fc --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/shared/ole_method.rb @@ -0,0 +1,25 @@ +require File.expand_path('../../../fixtures/classes', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe :win32ole_ole_method, shared: true do + before :each do + @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application') + end + + after :each do + @ie.Quit + end + + it "raises ArgumentError if no argument is given" do + lambda { @ie.send(@method) }.should raise_error ArgumentError + end + + it "returns the WIN32OLE_METHOD 'Quit' if given 'Quit'" do + result = @ie.send(@method, "Quit") + result.kind_of?(WIN32OLE_METHOD).should be_true + result.name.should == 'Quit' + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole/shared/setproperty.rb b/spec/ruby/library/win32ole/win32ole/shared/setproperty.rb new file mode 100644 index 0000000000..9703e402bf --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole/shared/setproperty.rb @@ -0,0 +1,25 @@ +require File.expand_path('../../../fixtures/classes', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe :win32ole_setproperty, shared: true do + before :each do + @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application') + end + + after :each do + @ie.Quit + end + + it "raises ArgumentError if no argument is given" do + lambda { @ie.send(@method) }.should raise_error ArgumentError + end + + it "sets height to 500 and returns nil" do + height = 500 + result = @ie.send(@method, 'Height', height) + result.should == nil + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole_event/new_spec.rb b/spec/ruby/library/win32ole/win32ole_event/new_spec.rb new file mode 100644 index 0000000000..5fffac535e --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_event/new_spec.rb @@ -0,0 +1,33 @@ +require File.expand_path('../../fixtures/classes', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_EVENT.new" do + before :each do + @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application') + end + + after :each do + @ie.Quit if @ie + end + + it "raises TypeError given invalid argument" do + lambda { WIN32OLE_EVENT.new "A" }.should raise_error TypeError + end + + it "raises RuntimeError if event does not exist" do + lambda { WIN32OLE_EVENT.new(@ie, 'A') }.should raise_error RuntimeError + end + + it "raises RuntimeError if OLE object has no events" do + dict = WIN32OLESpecs.new_ole('Scripting.Dictionary') + lambda { WIN32OLE_EVENT.new(dict) }.should raise_error RuntimeError + end + + it "creates WIN32OLE_EVENT object" do + ev = WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents') + ev.should be_kind_of WIN32OLE_EVENT + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb b/spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb new file mode 100644 index 0000000000..6bf8d2e1da --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb @@ -0,0 +1,62 @@ +require File.expand_path('../../fixtures/classes', __FILE__) + +platform_is :windows do + require 'win32ole' + + def default_handler(event, *args) + @event += event + end + + def alternate_handler(event, *args) + @event2 = "alternate" + end + + def handler3(event, *args) + @event3 += event + end + + + describe "WIN32OLE_EVENT#on_event with no argument" do + before :each do + @ie = WIN32OLESpecs.new_ole('InternetExplorer.Application') + @ev = WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents') + @event = '' + @event2 = '' + @event3 = '' + @ie.StatusBar = true + end + + after :each do + @ie.Quit + end + + it "sets event handler properly, and the handler is invoked by event loop" do + @ev.on_event { |*args| default_handler(*args) } + @ie.StatusText='hello' + WIN32OLE_EVENT.message_loop + @event.should =~ /StatusTextChange/ + end + + it "accepts a String argument, sets event handler properly, and the handler is invoked by event loop" do + @ev.on_event("StatusTextChange") { |*args| @event = 'foo' } + @ie.StatusText='hello' + WIN32OLE_EVENT.message_loop + @event.should =~ /foo/ + end + + it "registers multiple event handlers for the same event" do + @ev.on_event("StatusTextChange") { |*args| default_handler(*args) } + @ev.on_event("StatusTextChange") { |*args| alternate_handler(*args) } + @ie.StatusText= 'hello' + WIN32OLE_EVENT.message_loop + @event2.should == 'alternate' + end + + it "accepts a Symbol argument, sets event handler properly, and the handler is invoked by event loop" do + @ev.on_event(:StatusTextChange) { |*args| @event = 'foo' } + @ie.StatusText='hello' + WIN32OLE_EVENT.message_loop + @event.should =~ /foo/ + end + end +end diff --git a/spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb b/spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb new file mode 100644 index 0000000000..840cdf72b8 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb @@ -0,0 +1,20 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_METHOD#dispid" do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + @m = WIN32OLE_METHOD.new(ole_type, "namespace") + end + + it "raises ArgumentError if argument is given" do + lambda { @m.dispid(0) }.should raise_error ArgumentError + end + + it "returns expected dispatch ID for Shell's 'namespace' method" do + @m.dispid.should == 1610743810 # value found in MRI's test + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb b/spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb new file mode 100644 index 0000000000..9d3ca2b8e4 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb @@ -0,0 +1,26 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_METHOD#event_interface" do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Internet Controls", "WebBrowser") + @navigate_method = WIN32OLE_METHOD.new(ole_type, "NavigateComplete") + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + @namespace_method = WIN32OLE_METHOD.new(ole_type, "namespace") + end + + it "raises ArgumentError if argument is given" do + lambda { @navigate_method.event_interface(1) }.should raise_error ArgumentError + end + + it "returns expected string for browser's 'NavigateComplete' method" do + @navigate_method.event_interface.should == "DWebBrowserEvents" + end + + it "returns nil if method has no event interface" do + @namespace_method.event_interface.should be_nil + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/event_spec.rb b/spec/ruby/library/win32ole/win32ole_method/event_spec.rb new file mode 100644 index 0000000000..25435438aa --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/event_spec.rb @@ -0,0 +1,20 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_METHOD#event?" do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Internet Controls", "WebBrowser") + @navigate_method = WIN32OLE_METHOD.new(ole_type, "NavigateComplete") + end + + it "raises ArgumentError if argument is given" do + lambda { @navigate_method.event?(1) }.should raise_error ArgumentError + end + + it "returns true for browser's 'NavigateComplete' method" do + @navigate_method.event?.should be_true + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb b/spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb new file mode 100644 index 0000000000..c0e66a7a18 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb @@ -0,0 +1,26 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_METHOD#helpcontext" do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Internet Controls", "WebBrowser") + @navigate_method = WIN32OLE_METHOD.new(ole_type, "NavigateComplete") + ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "File") + @m_file_name = WIN32OLE_METHOD.new(ole_type, "name") + end + + it "raises ArgumentError if argument is given" do + lambda { @navigate_method.helpcontext(1) }.should raise_error ArgumentError + end + + it "returns expected value for browser's 'NavigateComplete' method" do + @navigate_method.helpcontext.should == 0 + end + + it "returns expected value for Scripting Runtime's 'name' method" do + @m_file_name.helpcontext.should == 2181996 # value indicated in MRI's test + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb b/spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb new file mode 100644 index 0000000000..72cc4da16b --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb @@ -0,0 +1,20 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_METHOD#helpfile" do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "File") + @m_file_name = WIN32OLE_METHOD.new(ole_type, "name") + end + + it "raises ArgumentError if argument is given" do + lambda { @m_file_name.helpfile(1) }.should raise_error ArgumentError + end + + it "returns expected value for Scripting Runtime's 'File' method" do + @m_file_name.helpfile.should =~ /VBENLR.*\.CHM$/i + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb b/spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb new file mode 100644 index 0000000000..60105d0aa2 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb @@ -0,0 +1,20 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_METHOD#helpstring" do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "File") + @m_file_name = WIN32OLE_METHOD.new(ole_type, "name") + end + + it "raises ArgumentError if argument is given" do + lambda { @m_file_name.helpstring(1) }.should raise_error ArgumentError + end + + it "returns expected value for Scripting Runtime's 'File' method" do + @m_file_name.helpstring.should == "Get name of file" # value indicated in MRI's test + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb b/spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb new file mode 100644 index 0000000000..cf0a74bbce --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb @@ -0,0 +1,20 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_METHOD#invkind" do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "File") + @m_file_name = WIN32OLE_METHOD.new(ole_type, "name") + end + + it "raises ArgumentError if argument is given" do + lambda { @m_file_name.invkind(1) }.should raise_error ArgumentError + end + + it "returns expected value for Scripting Runtime's 'name' method" do + @m_file_name.invkind.should == 2 + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb b/spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb new file mode 100644 index 0000000000..4d2af8fb0c --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb @@ -0,0 +1,20 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_METHOD#invoke_kind" do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "File") + @m_file_name = WIN32OLE_METHOD.new(ole_type, "name") + end + + it "raises ArgumentError if argument is given" do + lambda { @m_file_name.invoke_kind(1) }.should raise_error ArgumentError + end + + it "returns expected value for Scripting Runtime's 'name' method" do + @m_file_name.invoke_kind.should =~ /^(UNKNOWN|PROPERTY|PROPERTYGET|PROPERTYPUT|PROPERTYPUTREF|FUNC)$/ + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/name_spec.rb b/spec/ruby/library/win32ole/win32ole_method/name_spec.rb new file mode 100644 index 0000000000..0c2b3eeba0 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/name_spec.rb @@ -0,0 +1,11 @@ +require File.expand_path('../shared/name', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_METHOD#name" do + it_behaves_like :win32ole_method_name, :name + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/new_spec.rb b/spec/ruby/library/win32ole/win32ole_method/new_spec.rb new file mode 100644 index 0000000000..fc8d1d7691 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/new_spec.rb @@ -0,0 +1,33 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_METHOD.new" do + before :each do + @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + end + + it "raises TypeError when given non-strings" do + lambda { WIN32OLE_METHOD.new(1, 2) }.should raise_error TypeError + end + + it "raises ArgumentError if only 1 arugment is given" do + lambda { WIN32OLE_METHOD.new("hello") }.should raise_error ArgumentError + lambda { WIN32OLE_METHOD.new(@ole_type) }.should raise_error ArgumentError + end + + it "returns a valid WIN32OLE_METHOD object" do + WIN32OLE_METHOD.new(@ole_type, "Open").should be_kind_of WIN32OLE_METHOD + WIN32OLE_METHOD.new(@ole_type, "open").should be_kind_of WIN32OLE_METHOD + end + + it "raises WIN32OLERuntimeError if the method does not exist" do + lambda { WIN32OLE_METHOD.new(@ole_type, "NonexistentMethod") }.should raise_error WIN32OLERuntimeError + end + + it "raises TypeError if second argument is not a String" do + lambda { WIN32OLE_METHOD.new(@ole_type, 5) }.should raise_error TypeError + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb b/spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb new file mode 100644 index 0000000000..e436441409 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb @@ -0,0 +1,21 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_METHOD#offset_vtbl" do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "File") + @m_file_name = WIN32OLE_METHOD.new(ole_type, "name") + end + + it "raises ArgumentError if argument is given" do + lambda { @m_file_name.offset_vtbl(1) }.should raise_error ArgumentError + end + + it "returns expected value for Scripting Runtime's 'name' method" do + pointer_size = RUBY_PLATFORM =~ /\bx64\b/ ? 64 : 1.size * 8 + @m_file_name.offset_vtbl.should == pointer_size + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/params_spec.rb b/spec/ruby/library/win32ole/win32ole_method/params_spec.rb new file mode 100644 index 0000000000..08c7f04bdd --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/params_spec.rb @@ -0,0 +1,28 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_METHOD#params" do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "File") + @m_file_name = WIN32OLE_METHOD.new(ole_type, "name") + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + @m_browse_for_folder = WIN32OLE_METHOD.new(ole_type, "BrowseForFolder") + end + + it "raises ArgumentError if argument is given" do + lambda { @m_file_name.params(1) }.should raise_error ArgumentError + end + + it "returns empty array for Scripting Runtime's 'name' method" do + @m_file_name.params.should be_kind_of Array + @m_file_name.params.should be_empty + end + + it "returns 4-element array of WIN32OLE_PARAM for Shell's 'BrowseForFolder' method" do + @m_browse_for_folder.params.all? { |p| p.kind_of? WIN32OLE_PARAM }.should be_true + @m_browse_for_folder.params.size == 4 + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/return_type_detail_spec.rb b/spec/ruby/library/win32ole/win32ole_method/return_type_detail_spec.rb new file mode 100644 index 0000000000..b8f2bbe084 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/return_type_detail_spec.rb @@ -0,0 +1,21 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_METHOD#return_type_detail" do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + @m_browse_for_folder = WIN32OLE_METHOD.new(ole_type, "BrowseForFolder") + end + + it "raises ArgumentError if argument is given" do + lambda { @m_browse_for_folder.return_type_detail(1) }.should raise_error ArgumentError + end + + it "returns expected value for Shell Control's 'BrowseForFolder' method" do + @m_browse_for_folder.return_type_detail.should be_kind_of Array + @m_browse_for_folder.return_type_detail.should == ['PTR', 'USERDEFINED', 'Folder'] + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb b/spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb new file mode 100644 index 0000000000..b68481fe59 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb @@ -0,0 +1,20 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_METHOD#return_type" do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "File") + @m_file_name = WIN32OLE_METHOD.new(ole_type, "name") + end + + it "raises ArgumentError if argument is given" do + lambda { @m_file_name.return_type(1) }.should raise_error ArgumentError + end + + it "returns expected value for Scripting Runtime's 'name' method" do + @m_file_name.return_type.should == 'BSTR' + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb b/spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb new file mode 100644 index 0000000000..f236de01f9 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb @@ -0,0 +1,20 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_METHOD#return_vtype" do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + @m_browse_for_folder = WIN32OLE_METHOD.new(ole_type, "BrowseForFolder") + end + + it "raises ArgumentError if argument is given" do + lambda { @m_browse_for_folder.return_vtype(1) }.should raise_error ArgumentError + end + + it "returns expected value for Shell Control's 'BrowseForFolder' method" do + @m_browse_for_folder.return_vtype.should == 26 + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/shared/name.rb b/spec/ruby/library/win32ole/win32ole_method/shared/name.rb new file mode 100644 index 0000000000..2be6478a6e --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/shared/name.rb @@ -0,0 +1,20 @@ +platform_is :windows do + require 'win32ole' + + describe :win32ole_method_name, shared: true do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "File") + @m_file_name = WIN32OLE_METHOD.new(ole_type, "name") + end + + it "raises ArgumentError if argument is given" do + lambda { @m_file_name.send(@method, 1) }.should raise_error ArgumentError + end + + it "returns expected value for Scripting Runtime's 'name' method" do + @m_file_name.send(@method).should == 'Name' # note the capitalization + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/size_opt_params_spec.rb b/spec/ruby/library/win32ole/win32ole_method/size_opt_params_spec.rb new file mode 100644 index 0000000000..a63c50474c --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/size_opt_params_spec.rb @@ -0,0 +1,20 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_METHOD#size_opt_params" do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + @m_browse_for_folder = WIN32OLE_METHOD.new(ole_type, "BrowseForFolder") + end + + it "raises ArgumentError if argument is given" do + lambda { @m_browse_for_folder.size_opt_params(1) }.should raise_error ArgumentError + end + + it "returns expected value for Shell Control's 'BrowseForFolder' method" do + @m_browse_for_folder.size_opt_params.should == 1 + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb b/spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb new file mode 100644 index 0000000000..fe93d5bc66 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb @@ -0,0 +1,20 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_METHOD#size_params" do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + @m_browse_for_folder = WIN32OLE_METHOD.new(ole_type, "BrowseForFolder") + end + + it "raises ArgumentError if argument is given" do + lambda { @m_browse_for_folder.size_params(1) }.should raise_error ArgumentError + end + + it "returns expected value for Shell Control's 'BrowseForFolder' method" do + @m_browse_for_folder.size_params.should == 4 + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/to_s_spec.rb b/spec/ruby/library/win32ole/win32ole_method/to_s_spec.rb new file mode 100644 index 0000000000..95fd2fcdb5 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/to_s_spec.rb @@ -0,0 +1,11 @@ +require File.expand_path('../shared/name', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_METHOD#name" do + it_behaves_like :win32ole_method_name, :to_s + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_method/visible_spec.rb b/spec/ruby/library/win32ole/win32ole_method/visible_spec.rb new file mode 100644 index 0000000000..b49fac6066 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_method/visible_spec.rb @@ -0,0 +1,20 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_METHOD#visible?" do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + @m_browse_for_folder = WIN32OLE_METHOD.new(ole_type, "BrowseForFolder") + end + + it "raises ArgumentError if argument is given" do + lambda { @m_browse_for_folder.visible?(1) }.should raise_error ArgumentError + end + + it "returns true for Shell Control's 'BrowseForFolder' method" do + @m_browse_for_folder.visible?.should be_true + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_param/default_spec.rb b/spec/ruby/library/win32ole/win32ole_param/default_spec.rb new file mode 100644 index 0000000000..7a1337ec7c --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/default_spec.rb @@ -0,0 +1,31 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_PARAM#default" do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + m_browse_for_folder = WIN32OLE_METHOD.new(ole_type, "BrowseForFolder") + @params = m_browse_for_folder.params + + ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "FileSystemObject") + m_copyfile = WIN32OLE_METHOD.new(ole_type, "CopyFile") + @param_overwritefiles = m_copyfile.params[2] + end + + it "raises ArgumentError if argument is given" do + lambda { @params[0].default(1) }.should raise_error ArgumentError + end + + it "returns nil for each of WIN32OLE_PARAM for Shell's 'BrowseForFolder' method" do + @params.each do |p| + p.default.should be_nil + end + end + + it "returns true for 3rd parameter of FileSystemObject's 'CopyFile' method" do + @param_overwritefiles.default.should == true # not be_true + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_param/input_spec.rb b/spec/ruby/library/win32ole/win32ole_param/input_spec.rb new file mode 100644 index 0000000000..bdf4bccc79 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/input_spec.rb @@ -0,0 +1,21 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_PARAM#input?" do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "FileSystemObject") + m_copyfile = WIN32OLE_METHOD.new(ole_type, "CopyFile") + @param_overwritefiles = m_copyfile.params[2] + end + + it "raises ArgumentError if argument is given" do + lambda { @param_overwritefiles.input?(1) }.should raise_error ArgumentError + end + + it "returns true for 3rd parameter of FileSystemObject's 'CopyFile' method" do + @param_overwritefiles.input?.should == true + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_param/name_spec.rb b/spec/ruby/library/win32ole/win32ole_param/name_spec.rb new file mode 100644 index 0000000000..b3c947d6fb --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/name_spec.rb @@ -0,0 +1,11 @@ +require File.expand_path('../shared/name', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_PARAM#name" do + it_behaves_like :win32ole_param_name, :name + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_param/ole_type_detail_spec.rb b/spec/ruby/library/win32ole/win32ole_param/ole_type_detail_spec.rb new file mode 100644 index 0000000000..3ba51c02f1 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/ole_type_detail_spec.rb @@ -0,0 +1,21 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_PARAM#ole_type_detail" do + before :each do + ole_type_detail = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "FileSystemObject") + m_copyfile = WIN32OLE_METHOD.new(ole_type_detail, "CopyFile") + @param_overwritefiles = m_copyfile.params[2] + end + + it "raises ArgumentError if argument is given" do + lambda { @param_overwritefiles.ole_type_detail(1) }.should raise_error ArgumentError + end + + it "returns ['BOOL'] for 3rd parameter of FileSystemObject's 'CopyFile' method" do + @param_overwritefiles.ole_type_detail.should == ['BOOL'] + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb b/spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb new file mode 100644 index 0000000000..52bee2c9b8 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb @@ -0,0 +1,21 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_PARAM#ole_type" do + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "FileSystemObject") + m_copyfile = WIN32OLE_METHOD.new(ole_type, "CopyFile") + @param_overwritefiles = m_copyfile.params[2] + end + + it "raises ArgumentError if argument is given" do + lambda { @param_overwritefiles.ole_type(1) }.should raise_error ArgumentError + end + + it "returns 'BOOL' for 3rd parameter of FileSystemObject's 'CopyFile' method" do + @param_overwritefiles.ole_type.should == 'BOOL' + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_param/optional_spec.rb b/spec/ruby/library/win32ole/win32ole_param/optional_spec.rb new file mode 100644 index 0000000000..2476df8641 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/optional_spec.rb @@ -0,0 +1,21 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_PARAM#optional?" do + before :each do + ole_type_detail = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "FileSystemObject") + m_copyfile = WIN32OLE_METHOD.new(ole_type_detail, "CopyFile") + @param_overwritefiles = m_copyfile.params[2] + end + + it "raises ArgumentError if argument is given" do + lambda { @param_overwritefiles.optional?(1) }.should raise_error ArgumentError + end + + it "returns true for 3rd parameter of FileSystemObject's 'CopyFile' method" do + @param_overwritefiles.optional?.should be_true + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_param/retval_spec.rb b/spec/ruby/library/win32ole/win32ole_param/retval_spec.rb new file mode 100644 index 0000000000..90946c0774 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/retval_spec.rb @@ -0,0 +1,21 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_PARAM#retval?" do + before :each do + ole_type_detail = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "FileSystemObject") + m_copyfile = WIN32OLE_METHOD.new(ole_type_detail, "CopyFile") + @param_overwritefiles = m_copyfile.params[2] + end + + it "raises ArgumentError if argument is given" do + lambda { @param_overwritefiles.retval?(1) }.should raise_error ArgumentError + end + + it "returns false for 3rd parameter of FileSystemObject's 'CopyFile' method" do + @param_overwritefiles.retval?.should be_false + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_param/shared/name.rb b/spec/ruby/library/win32ole/win32ole_param/shared/name.rb new file mode 100644 index 0000000000..b7892d92fb --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/shared/name.rb @@ -0,0 +1,21 @@ +platform_is :windows do + require 'win32ole' + + describe :win32ole_param_name, shared: true do + before :each do + ole_type_detail = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "FileSystemObject") + m_copyfile = WIN32OLE_METHOD.new(ole_type_detail, "CopyFile") + @param_overwritefiles = m_copyfile.params[2] + end + + it "raises ArgumentError if argument is given" do + lambda { @param_overwritefiles.send(@method, 1) }.should raise_error ArgumentError + end + + it "returns expected value for Scripting Runtime's 'name' method" do + @param_overwritefiles.send(@method).should == 'OverWriteFiles' # note the capitalization + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_param/to_s_spec.rb b/spec/ruby/library/win32ole/win32ole_param/to_s_spec.rb new file mode 100644 index 0000000000..7852bb0494 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/to_s_spec.rb @@ -0,0 +1,11 @@ +require File.expand_path('../shared/name', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_PARAM#to_s" do + it_behaves_like :win32ole_param_name, :to_s + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_type/guid_spec.rb b/spec/ruby/library/win32ole/win32ole_type/guid_spec.rb new file mode 100644 index 0000000000..25907c8e32 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/guid_spec.rb @@ -0,0 +1,18 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_TYPE#guid for Shell Controls" do + before :each do + @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns String with expected format" do + @ole_type.guid.should =~ /\A\{[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}\}\z/ + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/helpcontext_spec.rb b/spec/ruby/library/win32ole/win32ole_type/helpcontext_spec.rb new file mode 100644 index 0000000000..d436835188 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/helpcontext_spec.rb @@ -0,0 +1,18 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_TYPE#helpcontext for Shell Controls" do + before :each do + @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns an Integer" do + @ole_type.helpcontext.should be_kind_of Integer + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/helpfile_spec.rb b/spec/ruby/library/win32ole/win32ole_type/helpfile_spec.rb new file mode 100644 index 0000000000..01e6945138 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/helpfile_spec.rb @@ -0,0 +1,18 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_TYPE#helpfile for Shell Controls" do + before :each do + @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns an empty string" do + @ole_type.helpfile.should be_empty + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/helpstring_spec.rb b/spec/ruby/library/win32ole/win32ole_type/helpstring_spec.rb new file mode 100644 index 0000000000..3bd2cbe5dd --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/helpstring_spec.rb @@ -0,0 +1,18 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_TYPE#helpstring for Shell Controls" do + before :each do + @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns expected string" do + @ole_type.helpstring.should == "Shell Object Type Information" + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/major_version_spec.rb b/spec/ruby/library/win32ole/win32ole_type/major_version_spec.rb new file mode 100644 index 0000000000..7dae16617d --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/major_version_spec.rb @@ -0,0 +1,18 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_TYPE#major_version for Shell Controls" do + before :each do + @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns an Integer" do + @ole_type.major_version.should be_kind_of Integer + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/minor_version_spec.rb b/spec/ruby/library/win32ole/win32ole_type/minor_version_spec.rb new file mode 100644 index 0000000000..ff412dd100 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/minor_version_spec.rb @@ -0,0 +1,18 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_TYPE#minor_version for Shell Controls" do + before :each do + @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns an Integer" do + @ole_type.minor_version.should be_kind_of Integer + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/name_spec.rb b/spec/ruby/library/win32ole/win32ole_type/name_spec.rb new file mode 100644 index 0000000000..b395cf05d5 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/name_spec.rb @@ -0,0 +1,11 @@ +require File.expand_path('../shared/name', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_TYPE#name" do + it_behaves_like :win32ole_type_name, :name + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_type/new_spec.rb b/spec/ruby/library/win32ole/win32ole_type/new_spec.rb new file mode 100644 index 0000000000..9443a64c75 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/new_spec.rb @@ -0,0 +1,37 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_TYPE.new" do + it "raises ArgumentError with no argument" do + lambda { WIN32OLE_TYPE.new }.should raise_error ArgumentError + end + + it "raises ArgumentError with invalid string" do + lambda { WIN32OLE_TYPE.new("foo") }.should raise_error ArgumentError + end + + it "raises TypeError if second argument is not a String" do + lambda { WIN32OLE_TYPE.new(1,2) }.should raise_error TypeError + lambda { WIN32OLE_TYPE.new('Microsoft Shell Controls And Automation',2) }. + should raise_error TypeError + end + + it "raise WIN32OLERuntimeError if OLE object specified is not found" do + lambda { WIN32OLE_TYPE.new('Microsoft Shell Controls And Automation','foo') }. + should raise_error WIN32OLERuntimeError + lambda { WIN32OLE_TYPE.new('Microsoft Shell Controls And Automation','Application') }. + should raise_error WIN32OLERuntimeError + end + + it "creates WIN32OLE_TYPE object from name and valid type" do + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + ole_type.should be_kind_of WIN32OLE_TYPE + end + + it "creates WIN32OLE_TYPE object from CLSID and valid type" do + ole_type2 = WIN32OLE_TYPE.new("{13709620-C279-11CE-A49E-444553540000}", "Shell") + ole_type2.should be_kind_of WIN32OLE_TYPE + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/ole_classes_spec.rb b/spec/ruby/library/win32ole/win32ole_type/ole_classes_spec.rb new file mode 100644 index 0000000000..0ce0fc98a4 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/ole_classes_spec.rb @@ -0,0 +1,18 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_TYPE.ole_classes for Shell Controls" do + before :each do + @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns array of WIN32OLE_TYPEs" do + WIN32OLE_TYPE.ole_classes("Microsoft Shell Controls And Automation").all? {|e| e.kind_of? WIN32OLE_TYPE }.should be_true + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/ole_methods_spec.rb b/spec/ruby/library/win32ole/win32ole_type/ole_methods_spec.rb new file mode 100644 index 0000000000..9265549d20 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/ole_methods_spec.rb @@ -0,0 +1,18 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_TYPE#ole_methods for Shell Controls" do + before :each do + @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns an Integer" do + @ole_type.ole_methods.all? { |m| m.kind_of? WIN32OLE_METHOD }.should be_true + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/ole_type_spec.rb b/spec/ruby/library/win32ole/win32ole_type/ole_type_spec.rb new file mode 100644 index 0000000000..2bc19aa85e --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/ole_type_spec.rb @@ -0,0 +1,18 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_TYPE#ole_type for Shell Controls" do + before :each do + @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns string 'Class'" do + @ole_type.ole_type.should == "Class" + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/progid_spec.rb b/spec/ruby/library/win32ole/win32ole_type/progid_spec.rb new file mode 100644 index 0000000000..f0d80ba39e --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/progid_spec.rb @@ -0,0 +1,18 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_TYPE#progid for Shell Controls" do + before :each do + @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns expected string" do + @ole_type.progid.should == "Shell.Application.1" + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/progids_spec.rb b/spec/ruby/library/win32ole/win32ole_type/progids_spec.rb new file mode 100644 index 0000000000..0cdd3514e3 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/progids_spec.rb @@ -0,0 +1,14 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_TYPE.progids" do + it "raises ArgumentError if an argument is given" do + lambda { WIN32OLE_TYPE.progids(1) }.should raise_error ArgumentError + end + + it "returns an array containing 'Shell.Explorer'" do + WIN32OLE_TYPE.progids().include?('Shell.Explorer').should be_true + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/shared/name.rb b/spec/ruby/library/win32ole/win32ole_type/shared/name.rb new file mode 100644 index 0000000000..6484ef0ef8 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/shared/name.rb @@ -0,0 +1,19 @@ +platform_is :windows do + require 'win32ole' + + describe :win32ole_type_name, shared: true do + before :each do + @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants") + end + + it "raises ArgumentError if argument is given" do + lambda { @ole_type.send(@method, 1) }.should raise_error ArgumentError + end + + it "returns a String" do + @ole_type.send(@method).should == 'ShellSpecialFolderConstants' + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_type/src_type_spec.rb b/spec/ruby/library/win32ole/win32ole_type/src_type_spec.rb new file mode 100644 index 0000000000..71e304d80a --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/src_type_spec.rb @@ -0,0 +1,18 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_TYPE#src_type for Shell Controls" do + before :each do + @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns nil" do + @ole_type.src_type.should be_nil + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/to_s_spec.rb b/spec/ruby/library/win32ole/win32ole_type/to_s_spec.rb new file mode 100644 index 0000000000..5a50bd11de --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/to_s_spec.rb @@ -0,0 +1,11 @@ +require File.expand_path('../shared/name', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_TYPE#to_s" do + it_behaves_like :win32ole_type_name, :to_s + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_type/typekind_spec.rb b/spec/ruby/library/win32ole/win32ole_type/typekind_spec.rb new file mode 100644 index 0000000000..35f3562721 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/typekind_spec.rb @@ -0,0 +1,18 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_TYPE#typekind for Shell Controls" do + before :each do + @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns an Integer" do + @ole_type.typekind.should be_kind_of Integer + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb b/spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb new file mode 100644 index 0000000000..3a28c0496c --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb @@ -0,0 +1,22 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_TYPE.typelibs for Shell Controls" do + before :each do + @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "raises ArgumentError if any argument is give" do + lambda { WIN32OLE_TYPE.typelibs(1) }.should raise_error ArgumentError + end + + it "returns array of type libraries" do + WIN32OLE_TYPE.typelibs().include?("Microsoft Shell Controls And Automation").should be_true + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/variables_spec.rb b/spec/ruby/library/win32ole/win32ole_type/variables_spec.rb new file mode 100644 index 0000000000..fbf3dd0341 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/variables_spec.rb @@ -0,0 +1,18 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_TYPE#variables for Shell Controls" do + before :each do + @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns an empty array" do + @ole_type.variables.should == [] + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_type/visible_spec.rb b/spec/ruby/library/win32ole/win32ole_type/visible_spec.rb new file mode 100644 index 0000000000..403b2b843b --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_type/visible_spec.rb @@ -0,0 +1,18 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_TYPE#visible? for Shell Controls" do + before :each do + @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + end + + after :each do + @ole_type = nil + end + + it "returns true" do + @ole_type.visible?.should be_true + end + + end +end diff --git a/spec/ruby/library/win32ole/win32ole_variable/name_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/name_spec.rb new file mode 100644 index 0000000000..724fd5c70a --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_variable/name_spec.rb @@ -0,0 +1,11 @@ +require File.expand_path('../shared/name', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_VARIABLE#name" do + it_behaves_like :win32ole_variable_new, :name + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_variable/ole_type_detail_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/ole_type_detail_spec.rb new file mode 100644 index 0000000000..dab4edabaa --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_variable/ole_type_detail_spec.rb @@ -0,0 +1,19 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_VARIABLE#ole_type_detail" do + # not sure how WIN32OLE_VARIABLE objects are supposed to be generated + # WIN32OLE_VARIABLE.new even seg faults in some cases + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants") + @var = ole_type.variables[0] + end + + it "returns a nonempty Array" do + @var.ole_type_detail.should be_kind_of Array + @var.ole_type_detail.should_not be_empty + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_variable/ole_type_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/ole_type_spec.rb new file mode 100644 index 0000000000..d08acc9bde --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_variable/ole_type_spec.rb @@ -0,0 +1,18 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_VARIABLE#ole_type" do + # not sure how WIN32OLE_VARIABLE objects are supposed to be generated + # WIN32OLE_VARIABLE.new even seg faults in some cases + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants") + @var = ole_type.variables[0] + end + + it "returns a String" do + @var.ole_type.should be_kind_of String + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_variable/shared/name.rb b/spec/ruby/library/win32ole/win32ole_variable/shared/name.rb new file mode 100644 index 0000000000..033e830fac --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_variable/shared/name.rb @@ -0,0 +1,18 @@ +platform_is :windows do + require 'win32ole' + + describe :win32ole_variable_new, shared: true do + # not sure how WIN32OLE_VARIABLE objects are supposed to be generated + # WIN32OLE_VARIABLE.new even seg faults in some cases + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants") + @var = ole_type.variables[0] + end + + it "returns a String" do + @var.send(@method).should be_kind_of String + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_variable/to_s_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/to_s_spec.rb new file mode 100644 index 0000000000..9853f91801 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_variable/to_s_spec.rb @@ -0,0 +1,11 @@ +require File.expand_path('../shared/name', __FILE__) + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_VARIABLE#to_s" do + it_behaves_like :win32ole_variable_new, :to_s + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_variable/value_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/value_spec.rb new file mode 100644 index 0000000000..c15f64c2c5 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_variable/value_spec.rb @@ -0,0 +1,19 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_VARIABLE#value" do + # not sure how WIN32OLE_VARIABLE objects are supposed to be generated + # WIN32OLE_VARIABLE.new even seg faults in some cases + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants") + @var = ole_type.variables[0] + end + + it "returns a Integer" do + # according to doc, this could return nil + @var.value.should be_kind_of Integer + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_variable/variable_kind_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/variable_kind_spec.rb new file mode 100644 index 0000000000..4cca7f8874 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_variable/variable_kind_spec.rb @@ -0,0 +1,19 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_VARIABLE#variable_kind" do + # not sure how WIN32OLE_VARIABLE objects are supposed to be generated + # WIN32OLE_VARIABLE.new even seg faults in some cases + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants") + @var = ole_type.variables[0] + end + + it "returns a String" do + @var.variable_kind.should be_kind_of String + @var.variable_kind.should == 'CONSTANT' + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_variable/varkind_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/varkind_spec.rb new file mode 100644 index 0000000000..56cd1c337a --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_variable/varkind_spec.rb @@ -0,0 +1,19 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_VARIABLE#varkind" do + # TODO review + # not sure how WIN32OLE_VARIABLE objects are supposed to be generated + # WIN32OLE_VARIABLE.new even seg faults in some cases + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants") + @var = ole_type.variables[0] + end + + it "returns an Integer" do + @var.varkind.should be_kind_of Integer + end + + end + +end diff --git a/spec/ruby/library/win32ole/win32ole_variable/visible_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/visible_spec.rb new file mode 100644 index 0000000000..7f7a557b57 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_variable/visible_spec.rb @@ -0,0 +1,18 @@ +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE_VARIABLE#visible?" do + # not sure how WIN32OLE_VARIABLE objects are supposed to be generated + # WIN32OLE_VARIABLE.new even seg faults in some cases + before :each do + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants") + @var = ole_type.variables[0] + end + + it "returns a String" do + @var.visible?.should be_true + end + + end + +end |