diff options
Diffstat (limited to 'spec/ruby/library/win32ole/win32ole_param')
9 files changed, 187 insertions, 0 deletions
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..dded6833d4 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/default_spec.rb @@ -0,0 +1,32 @@ +require_relative "../../../spec_helper" +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 + -> { @params[0].default(1) }.should.raise ArgumentError + end + + it "returns nil for each of WIN32OLE::Param for Shell's 'BrowseForFolder' method" do + @params.each do |p| + p.default.should == 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..46dc305d2b --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/input_spec.rb @@ -0,0 +1,22 @@ +require_relative "../../../spec_helper" +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 + -> { @param_overwritefiles.input?(1) }.should.raise ArgumentError + end + + it "returns true for 3rd parameter of FileSystemObject's 'CopyFile' method" do + @param_overwritefiles.should.input? + 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..2c3474ffb3 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/name_spec.rb @@ -0,0 +1,12 @@ +require_relative "../../../spec_helper" +require_relative 'shared/name' + +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..bd25ec325a --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/ole_type_detail_spec.rb @@ -0,0 +1,22 @@ +require_relative "../../../spec_helper" +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 + -> { @param_overwritefiles.ole_type_detail(1) }.should.raise 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..3f0c279316 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb @@ -0,0 +1,22 @@ +require_relative "../../../spec_helper" +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 + -> { @param_overwritefiles.ole_type(1) }.should.raise 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..ca676e0950 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/optional_spec.rb @@ -0,0 +1,22 @@ +require_relative "../../../spec_helper" +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 + -> { @param_overwritefiles.optional?(1) }.should.raise ArgumentError + end + + it "returns true for 3rd parameter of FileSystemObject's 'CopyFile' method" do + @param_overwritefiles.optional?.should == 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..f25b1e7e14 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/retval_spec.rb @@ -0,0 +1,22 @@ +require_relative "../../../spec_helper" +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 + -> { @param_overwritefiles.retval?(1) }.should.raise ArgumentError + end + + it "returns false for 3rd parameter of FileSystemObject's 'CopyFile' method" do + @param_overwritefiles.retval?.should == 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..1f6cbea7a0 --- /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 + -> { @param_overwritefiles.send(@method, 1) }.should.raise 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..c59f426692 --- /dev/null +++ b/spec/ruby/library/win32ole/win32ole_param/to_s_spec.rb @@ -0,0 +1,12 @@ +require_relative "../../../spec_helper" +require_relative 'shared/name' + +platform_is :windows do + require 'win32ole' + + describe "WIN32OLE::Param#to_s" do + it_behaves_like :win32ole_param_name, :to_s + + end + +end |
