diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..6c6df7e9 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,22 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/ruby +{ + "name": "Ruby", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/ruby:1-3.3-bullseye" + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "ruby --version", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..f33a02cd --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for more information: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +# https://containers.dev/guide/dependabot + +version: 2 +updates: + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: weekly diff --git a/Gemfile b/Gemfile index f38b3039..08385189 100644 --- a/Gemfile +++ b/Gemfile @@ -3,9 +3,7 @@ source 'https://rubygems.org/' gemspec group :development do - gem 'rspec', '<3.0' - gem 'guard', '2.12.6' - gem 'guard-rspec' + gem 'rspec' gem 'rb-inotify', :require => false gem 'turn' gem "pry-nav" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9739f6f4..b9c20545 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,10 +5,11 @@ require 'turn/autorun' require_relative 'xml_matcher' -RSpec.configure do |rspec| - rspec.mock_with :rspec do |mocks| +RSpec.configure do |config| + config.mock_with :rspec do |mocks| mocks.yield_receiver_to_any_instance_implementation_blocks = false end + config.raise_errors_for_deprecations! end Turn.config.format = :outline diff --git a/spec/unit/ews_folder_operations_spec.rb b/spec/unit/ews_folder_operations_spec.rb index 68dd0929..be58a5dd 100644 --- a/spec/unit/ews_folder_operations_spec.rb +++ b/spec/unit/ews_folder_operations_spec.rb @@ -1,16 +1,14 @@ require_relative '../spec_helper' describe "Operations on Exchange Data Services" do - before do con = double('Connection') @ews = Viewpoint::EWS::SOAP::ExchangeWebService.new con, {:server_version => Viewpoint::EWS::SOAP::VERSION_2010_SP2} - @ews.stub(:do_soap_request) end it "generates CreateFolder XML" do - @ews.should_receive(:do_soap_request). + expect(@ews).to receive(:do_soap_request). with(match_xml(load_soap("create_folder", :request))) fname = "Test Folder" @@ -20,7 +18,7 @@ end it "generates CopyFolder XML" do - @ews.should_receive(:do_soap_request). + expect(@ews).to receive(:do_soap_request). with(match_xml(load_soap("copy_folder", :request))) tofid = {:id => 'dest_folder_id'} @@ -28,7 +26,7 @@ end it "generates DeleteFolder XML" do - @ews.should_receive(:do_soap_request). + expect(@ews).to receive(:do_soap_request). with(match_xml(load_soap("delete_folder", :request))) fid = "test_folder_id" @@ -38,7 +36,7 @@ end it "generates FindFolder XML" do - @ews.should_receive(:do_soap_request). + expect(@ews).to receive(:do_soap_request). with(match_xml(load_soap("find_folder", :request))) fname = "Test Folder" @@ -65,7 +63,7 @@ end it "generates GetFolder XML" do - @ews.should_receive(:do_soap_request). + expect(@ews).to receive(:do_soap_request). with(match_xml(load_soap("get_folder", :request))) opts = { :folder_ids => [{:id => :msgfolderroot}], @@ -91,7 +89,7 @@ end it "generates MoveFolder XML" do - @ews.should_receive(:do_soap_request). + expect(@ews).to receive(:do_soap_request). with(match_xml(load_soap("move_folder", :request))) tofid = {:id => 'dest_folder_id'} @@ -99,7 +97,7 @@ end it "generates EmptyFolder XML" do - @ews.should_receive(:do_soap_request). + expect(@ews).to receive(:do_soap_request). with(match_xml(load_soap("empty_folder", :request))) fid = "test_folder_id" diff --git a/spec/unit/ews_parser_spec.rb b/spec/unit/ews_parser_spec.rb index 0e688c35..5f95916a 100644 --- a/spec/unit/ews_parser_spec.rb +++ b/spec/unit/ews_parser_spec.rb @@ -12,13 +12,13 @@ it 'parses a successful response' do soap_resp = load_soap 'find_folder', :response resp = Viewpoint::EWS::SOAP::EwsParser.new(soap_resp).parse - resp.body.should == success_body + expect(resp.body).to eq success_body end it 'parses an unsuccessful response' do soap_resp = load_soap 'find_folder_error', :response resp = Viewpoint::EWS::SOAP::EwsParser.new(soap_resp).parse - resp.body.should == error_body + expect(resp.body).to eq error_body end end diff --git a/spec/unit/ews_rooms_operations_spec.rb b/spec/unit/ews_rooms_operations_spec.rb index 4fffeb9d..410d78dd 100644 --- a/spec/unit/ews_rooms_operations_spec.rb +++ b/spec/unit/ews_rooms_operations_spec.rb @@ -7,21 +7,21 @@ con = double('Connection') @ews = Viewpoint::EWS::SOAP::ExchangeWebService.new con, {:server_version => Viewpoint::EWS::SOAP::VERSION_2010_SP2} - @ews.stub(:do_soap_request) + allow(@ews).to receive(:do_soap_request) end it "generates GetRooms XML" do - @ews.should_receive(:do_soap_request) do |request_document| + expect(@ews).to receive(:do_soap_request) do |request_document| doc = request_document.to_s.gsub(%r{>\s+}, '>') - doc.should eq load_soap("get_rooms", :request) + expect(doc).to eq load_soap("get_rooms", :request) end @ews.get_rooms 'TestRoomList@test.microsoft.com' end it "generates GetRoomLists XML" do - @ews.should_receive(:do_soap_request) do |request_document| + expect(@ews).to receive(:do_soap_request) do |request_document| doc = request_document.to_s.gsub(%r{>\s+}, '>') - doc.should eq load_soap("get_room_lists", :request) + expect(doc).to eq load_soap("get_room_lists", :request) end.and_return(double(:resp)) @ews.get_room_lists end diff --git a/spec/unit/ews_soap_free_busy_response_spec.rb b/spec/unit/ews_soap_free_busy_response_spec.rb index b695a9e5..a6317403 100644 --- a/spec/unit/ews_soap_free_busy_response_spec.rb +++ b/spec/unit/ews_soap_free_busy_response_spec.rb @@ -39,7 +39,7 @@ let(:resp) { ews.parse_soap_response(ERROR_INVALID_SMTP_ADDRESS, :response_class => described_class) } it "should deliver the error code" do - resp.code.should eq "ErrorInvalidSmtpAddress" + expect(resp.code).to eq "ErrorInvalidSmtpAddress" end it "should extract the response message" do @@ -58,7 +58,7 @@ }} ] } - resp.response_message.should == extracted_response_message + expect(resp.response_message).to eq extracted_response_message end end @@ -106,11 +106,11 @@ let(:resp) { ews.parse_soap_response(CALENDAR_EVENT_ARRAY, :response_class => described_class) } it "response should be successful" do - resp.status.should eq "Success" + expect(resp.status).to eq "Success" end it "the calendar_event_array should have one element" do - resp.calendar_event_array.should have(1).items + expect(resp.calendar_event_array.length).to eq 1 end end @@ -141,11 +141,11 @@ let(:resp) { ews.parse_soap_response(EMPTY_RESPONSE, :response_class => described_class) } it "response should be success" do - resp.status.should eq "Success" + expect(resp.status).to eq "Success" end it "the calendar_event_array should be an empty list" do - resp.calendar_event_array.should eq [] + expect(resp.calendar_event_array).to eq [] end end diff --git a/spec/unit/folder_accessors_spec.rb b/spec/unit/folder_accessors_spec.rb index f118e947..dc5ec0c8 100644 --- a/spec/unit/folder_accessors_spec.rb +++ b/spec/unit/folder_accessors_spec.rb @@ -13,8 +13,8 @@ def self.folders ews = double("ews") @ecli = double("EWSClient") @ecli.extend subject - @ecli.stub(:ews) {ews} - @ecli.stub(:merge_restrictions!) + allow(@ecli).to receive(:ews).and_return ews + allow(@ecli).to receive(:merge_restrictions!) end context "ensure FolderAccessors methods are returning good data" do @@ -24,14 +24,14 @@ def self.folders resp.status = 'Success' rhash = {:elems => {:root_folder => {:elems => [{:folders =>{:elems => ResponseObjects.folders}}]}}} resp.response_message = rhash - @ecli.ews.stub(:find_folder).with(an_instance_of(Hash)) { resp } + allow(@ecli.ews).to receive(:find_folder).with(an_instance_of(Hash)).and_return resp cbn = double("ClassByName") - cbn.stub(:new) { double("FolderMock") } - @ecli.stub(:class_by_name) { cbn } + allow(cbn).to receive(:new).and_return double("FolderMock") + allow(@ecli).to receive(:class_by_name).and_return cbn end it '#find_folders should return folders' do - @ecli.folders.should be_instance_of(Array) + expect(@ecli.folders).to be_instance_of(Array) end end context "methods utilizing ExchangeWebService#get_folder" do @@ -40,13 +40,13 @@ def self.folders resp.status = 'Success' rhash = {:elems => {:folders =>{:elems => ResponseObjects.folders}}} resp.response_message = rhash - @ecli.ews.stub(:get_folder).with(an_instance_of(Hash)) { resp } + allow(@ecli.ews).to receive(:get_folder).with(an_instance_of(Hash)).and_return resp cbn = double("ClassByName") - cbn.stub(:new) { double("Folder") } - @ecli.stub(:class_by_name) { cbn } + allow(cbn).to receive(:new).and_return double("Folder") + allow(@ecli).to receive(:class_by_name).and_return cbn end it '#get_folder should return a Folder' do - @ecli.get_folder(:inbox).should be_instance_of(RSpec::Mocks::Mock) + expect(@ecli.get_folder(:inbox)).to be_a(RSpec::Mocks::Double) end end end @@ -55,8 +55,8 @@ def self.folders before do resp = OpenStruct.new resp.status = 'Failure' - @ecli.ews.stub(:find_folder).with(an_instance_of(Hash)) { resp } - @ecli.ews.stub(:get_folder).with(an_instance_of(Hash)) { resp } + allow(@ecli.ews).to receive(:find_folder).with(an_instance_of(Hash)).and_return resp + allow(@ecli.ews).to receive(:get_folder).with(an_instance_of(Hash)).and_return resp end it '#find_folders should raise an exception' do expect { diff --git a/spec/unit/item_accessors_spec.rb b/spec/unit/item_accessors_spec.rb index 2a91d7c1..e18e9225 100644 --- a/spec/unit/item_accessors_spec.rb +++ b/spec/unit/item_accessors_spec.rb @@ -13,7 +13,7 @@ def self.folders ews = double("ews") @ecli = double("EWSClient") @ecli.extend subject - @ecli.stub(:ews) {ews} + allow(@ecli).to receive(:ews).and_return(ews) end context "ensure that exceptions are being raised" do @@ -22,7 +22,7 @@ def self.folders rm = OpenStruct.new rm.status = 'Failure' resp.response_messages = [rm] - @ecli.ews.stub(:get_item).with(an_instance_of(Hash)) { resp } + allow(@ecli.ews).to receive(:get_item).with(an_instance_of(Hash)).and_return resp end it '#get_item should raise an exception' do expect { @@ -42,7 +42,7 @@ def call_get_item_args(*args) it "should handle an :occurrence_item_id hash" do occurrence_item_id = {:occurrence_item_id => {:recurring_master_id => 'rid1', :change_key => 'ck', :instance_index => 1}} result = GetItemArgsAccessor.new.call_get_item_args(occurrence_item_id, {}) - result[:item_ids].should eq [occurrence_item_id] + expect(result[:item_ids]).to eq [occurrence_item_id] end it "should handle an Array of :occurrence_item_id hashes" do @@ -52,19 +52,19 @@ def call_get_item_args(*args) {:occurrence_item_id => {:recurring_master_id => 'rid3', :change_key => 'ck3', :instance_index => 3}}, ] result = GetItemArgsAccessor.new.call_get_item_args(occurrences, {}) - result[:item_ids].should eq occurrences + expect(result[:item_ids]).to eq occurrences end it "should handle an :id hash" do id = {:id => 'id1', :change_key => 'ck1'} result = GetItemArgsAccessor.new.call_get_item_args(id, {}) - result[:item_ids].should eq [{:item_id => {:id => 'id1', :change_key => 'ck1'}}] + expect(result[:item_ids]).to eq [{:item_id => {:id => 'id1', :change_key => 'ck1'}}] end it "should handle an Array of id strings" do ids = ['id1', 'id2', 'id3'] result = GetItemArgsAccessor.new.call_get_item_args(ids, {}) - result[:item_ids].should eq [{:item_id=>{:id => 'id1'}},{:item_id=>{:id => 'id2'}},{:item_id=>{:id => 'id3'}}] + expect(result[:item_ids]).to eq [{:item_id=>{:id => 'id1'}},{:item_id=>{:id => 'id2'}},{:item_id=>{:id => 'id3'}}] end end diff --git a/spec/unit/mailbox_accessors_spec.rb b/spec/unit/mailbox_accessors_spec.rb index 329a84be..5afacfe4 100644 --- a/spec/unit/mailbox_accessors_spec.rb +++ b/spec/unit/mailbox_accessors_spec.rb @@ -34,9 +34,8 @@ context "#get_user_availability" do it "should care about timezones" do - Viewpoint::EWS::SOAP::ExchangeWebService.any_instance. - should_receive(:do_soap_request) do |request_document| - request_document.at_xpath('//soap:Envelope/soap:Body//t:TimeZone').to_s.should eq timezone_request + expect_any_instance_of(Viewpoint::EWS::SOAP::ExchangeWebService).to receive(:do_soap_request) do |request_document| + expect(request_document.at_xpath('//soap:Envelope/soap:Body//t:TimeZone').to_s).to eq timezone_request end. and_return(double(:resp, :status => 'Success')) diff --git a/spec/unit/meeting_accessors_spec.rb b/spec/unit/meeting_accessors_spec.rb index 4524fe16..d2dd46e6 100644 --- a/spec/unit/meeting_accessors_spec.rb +++ b/spec/unit/meeting_accessors_spec.rb @@ -28,9 +28,8 @@ end it "should form valid accept item request" do - Viewpoint::EWS::SOAP::ExchangeWebService.any_instance. - should_receive(:do_soap_request) do |request_document| - request_document.at_xpath('//soap:Envelope/soap:Body').to_s.should eq create_item_request + expect_any_instance_of(Viewpoint::EWS::SOAP::ExchangeWebService).to receive(:do_soap_request) do |request_document| + expect(request_document.at_xpath('//soap:Envelope/soap:Body').to_s).to eq create_item_request end. and_return(double(:resp, :status => 'Success')) @@ -54,9 +53,8 @@ end it "should form valid accept item request" do - Viewpoint::EWS::SOAP::ExchangeWebService.any_instance. - should_receive(:do_soap_request) do |request_document| - request_document.at_xpath('//soap:Envelope/soap:Body').to_s.should eq create_item_request + expect_any_instance_of(Viewpoint::EWS::SOAP::ExchangeWebService).to receive(:do_soap_request) do |request_document| + expect(request_document.at_xpath('//soap:Envelope/soap:Body').to_s).to eq create_item_request end. and_return(double(:resp, :status => 'success')) @@ -80,9 +78,8 @@ end it "should form valid accept item request" do - Viewpoint::EWS::SOAP::ExchangeWebService.any_instance. - should_receive(:do_soap_request) do |request_document| - request_document.at_xpath('//soap:Envelope/soap:Body').to_s.should eq create_item_request + expect_any_instance_of(Viewpoint::EWS::SOAP::ExchangeWebService).to receive(:do_soap_request) do |request_document| + expect(request_document.at_xpath('//soap:Envelope/soap:Body').to_s).to eq create_item_request end. and_return(double(:resp, :status => 'success')) diff --git a/spec/unit/soap/builders/ews_builder_spec.rb b/spec/unit/soap/builders/ews_builder_spec.rb index da6b19bc..1c6cd6c7 100644 --- a/spec/unit/soap/builders/ews_builder_spec.rb +++ b/spec/unit/soap/builders/ews_builder_spec.rb @@ -6,7 +6,7 @@ it 'should #build a basic structure' do doc = builder.build!(server_version: Viewpoint::EWS::SOAP::VERSION_2007) {|s| } - doc.should match_xml(load_soap('basic', :request)) + expect(doc).to match_xml(load_soap('basic', :request)) end it 'should build BodyType' do @@ -17,14 +17,14 @@ builder.body_type!(:best) end end - doc.xpath('//t:BodyType[1]').text.should eq('HTML') - doc.xpath('//t:BodyType[2]').text.should eq('Text') - doc.xpath('//t:BodyType[3]').text.should eq('Best') + expect(doc.xpath('//t:BodyType[1]').text).to eq('HTML') + expect(doc.xpath('//t:BodyType[2]').text).to eq('Text') + expect(doc.xpath('//t:BodyType[3]').text).to eq('Best') end it 'should format various Time inputs' do - builder.send(:format_time, Date.iso8601('2013-01-01')).should eq('2013-01-01T00:00:00+00:00') - builder.send(:format_time, DateTime.iso8601('2013-01-01T23:01:00-05:00')).should eq('2013-01-02T04:01:00+00:00') + expect(builder.send(:format_time, Date.iso8601('2013-01-01'))).to eq('2013-01-01T00:00:00+00:00') + expect(builder.send(:format_time, DateTime.iso8601('2013-01-01T23:01:00-05:00'))).to eq('2013-01-02T04:01:00+00:00') expect {builder.send(:format_time, true)}.to raise_error(Viewpoint::EWS::EwsBadArgumentError) expect {builder.send(:format_time, 'asdf')}.to raise_error(Viewpoint::EWS::EwsBadArgumentError) end @@ -32,7 +32,7 @@ it 'should contain time zone context' do doc = builder.build!(time_zone_context: {id: 'SpaceTime'}) selector = "//soap:Header/t:TimeZoneContext/t:TimeZoneDefinition[@Id='SpaceTime']" - doc.root.xpath(selector, namespaces).should be_any + expect(doc.root.xpath(selector, namespaces)).to be_any end describe "#field_uRI" do @@ -40,7 +40,7 @@ let(:match_string) { "" } before do - builder.stub(:ews_types_builder) { builder.nbuild } + allow(builder).to receive(:ews_types_builder).and_return builder.nbuild end it "builds a fieldURI from a String" do diff --git a/viewpoint.gemspec b/viewpoint.gemspec index 8d2b3a26..e8cba073 100644 --- a/viewpoint.gemspec +++ b/viewpoint.gemspec @@ -27,4 +27,6 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'httpclient' s.add_runtime_dependency 'rubyntlm' s.add_runtime_dependency 'logging' + s.add_runtime_dependency 'syslog' + s.add_runtime_dependency 'mutex_m' end