From f65bf74737a148e2decaf37aac5666fb5c2e7848 Mon Sep 17 00:00:00 2001 From: Joe Weakley Date: Fri, 6 Apr 2018 12:28:24 -0700 Subject: [PATCH] Added and configured VCR --- Gemfile.lock | 20 ++++++++++++++++++++ syspro-ruby.gemspec | 2 ++ test/cassettes/test_client_block_execution.yml | 36 ++++++++++++++++++++++++++++++++++++ test/cassettes/test_get_syspro_version.yml | 36 ++++++++++++++++++++++++++++++++++++ test/cassettes/test_logoff_error.yml | 36 ++++++++++++++++++++++++++++++++++++ test/cassettes/test_logon.yml | 36 ++++++++++++++++++++++++++++++++++++ test/cassettes/test_query_browse.yml | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/cassettes/test_query_fetch.yml | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/cassettes/test_query_query.yml | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/cassettes/test_successful_logoff.yml | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/client_test.rb | 2 ++ test/logoff_test.rb | 2 ++ test/logon_test.rb | 2 ++ test/query_test.rb | 18 ++++++++++++------ test/test_helper.rb | 11 +++++++++++ 15 files changed, 504 insertions(+), 6 deletions(-) create mode 100644 test/cassettes/test_client_block_execution.yml create mode 100644 test/cassettes/test_get_syspro_version.yml create mode 100644 test/cassettes/test_logoff_error.yml create mode 100644 test/cassettes/test_logon.yml create mode 100644 test/cassettes/test_query_browse.yml create mode 100644 test/cassettes/test_query_fetch.yml create mode 100644 test/cassettes/test_query_query.yml create mode 100644 test/cassettes/test_successful_logoff.yml diff --git a/Gemfile.lock b/Gemfile.lock index e436223..8491798 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,13 +8,24 @@ PATH GEM remote: https://rubygems.org/ specs: + addressable (2.5.2) + public_suffix (>= 2.0.2, < 4.0) ast (2.4.0) coderay (1.1.2) + crack (0.4.3) + safe_yaml (~> 1.0.0) faraday (0.14.0) multipart-post (>= 1.2, < 3) + hashdiff (0.3.7) method_source (0.9.0) mini_portile2 (2.3.0) + minispec-metadata (2.0.0) + minitest minitest (5.11.3) + minitest-vcr (1.4.0) + minispec-metadata (~> 2.0) + minitest (>= 4.7.5) + vcr (>= 2.9) multipart-post (2.0.0) nokogiri (1.8.2) mini_portile2 (~> 2.3.0) @@ -25,6 +36,7 @@ GEM pry (0.11.3) coderay (~> 1.1.0) method_source (~> 0.9.0) + public_suffix (3.0.2) rainbow (3.0.0) rake (10.5.0) rubocop (0.54.0) @@ -35,7 +47,13 @@ GEM ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) ruby-progressbar (1.9.0) + safe_yaml (1.0.4) unicode-display_width (1.3.0) + vcr (4.0.0) + webmock (3.3.0) + addressable (>= 2.3.6) + crack (>= 0.3.2) + hashdiff PLATFORMS ruby @@ -43,10 +61,12 @@ PLATFORMS DEPENDENCIES bundler (~> 1.16) minitest (~> 5.0) + minitest-vcr (~> 1.4.0) pry (~> 0.11) rake (~> 10.0) rubocop (~> 0.54.0) syspro-ruby! + webmock (~> 3.3.0) BUNDLED WITH 1.16.1 diff --git a/syspro-ruby.gemspec b/syspro-ruby.gemspec index fa30b5f..a7a06d2 100644 --- a/syspro-ruby.gemspec +++ b/syspro-ruby.gemspec @@ -38,4 +38,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'pry', '~> 0.11' spec.add_development_dependency 'rake', '~> 10.0' spec.add_development_dependency 'rubocop', '~> 0.54.0' + spec.add_development_dependency 'webmock', '~> 3.3.0' + spec.add_development_dependency 'minitest-vcr', '~> 1.4.0' end diff --git a/test/cassettes/test_client_block_execution.yml b/test/cassettes/test_client_block_execution.yml new file mode 100644 index 0000000..b3bb1e5 --- /dev/null +++ b/test/cassettes/test_client_block_execution.yml @@ -0,0 +1,36 @@ +--- +http_interactions: +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/getversion + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/0.1.0 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Length: + - '7' + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Fri, 06 Apr 2018 19:23:43 GMT + body: + encoding: UTF-8 + string: 7.0.0.6 + http_version: + recorded_at: Fri, 06 Apr 2018 19:23:42 GMT +recorded_with: VCR 4.0.0 diff --git a/test/cassettes/test_get_syspro_version.yml b/test/cassettes/test_get_syspro_version.yml new file mode 100644 index 0000000..b3bb1e5 --- /dev/null +++ b/test/cassettes/test_get_syspro_version.yml @@ -0,0 +1,36 @@ +--- +http_interactions: +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/getversion + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/0.1.0 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Length: + - '7' + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Fri, 06 Apr 2018 19:23:43 GMT + body: + encoding: UTF-8 + string: 7.0.0.6 + http_version: + recorded_at: Fri, 06 Apr 2018 19:23:42 GMT +recorded_with: VCR 4.0.0 diff --git a/test/cassettes/test_logoff_error.yml b/test/cassettes/test_logoff_error.yml new file mode 100644 index 0000000..84e28f5 --- /dev/null +++ b/test/cassettes/test_logoff_error.yml @@ -0,0 +1,36 @@ +--- +http_interactions: +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/logoff?UserId=1BB5B3050954BB459A5D034DB5CC386980 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/0.1.0 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Length: + - '72' + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Fri, 06 Apr 2018 19:22:53 GMT + body: + encoding: UTF-8 + string: 'ERROR: Unable to read the SYSPRO base directory registry string BaseDir8' + http_version: + recorded_at: Fri, 06 Apr 2018 19:22:52 GMT +recorded_with: VCR 4.0.0 diff --git a/test/cassettes/test_logon.yml b/test/cassettes/test_logon.yml new file mode 100644 index 0000000..96606f2 --- /dev/null +++ b/test/cassettes/test_logon.yml @@ -0,0 +1,36 @@ +--- +http_interactions: +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/logon?CompanyId=L&CompanyPassword=&Operator=wland&OperatorPassword=piperita2016 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/0.1.0 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Length: + - '36' + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Fri, 06 Apr 2018 19:23:52 GMT + body: + encoding: UTF-8 + string: 'EC3098D6E284FB44ADF10671B3F06FCA00 ' + http_version: + recorded_at: Fri, 06 Apr 2018 19:23:51 GMT +recorded_with: VCR 4.0.0 diff --git a/test/cassettes/test_query_browse.yml b/test/cassettes/test_query_browse.yml new file mode 100644 index 0000000..fe5281d --- /dev/null +++ b/test/cassettes/test_query_browse.yml @@ -0,0 +1,72 @@ +--- +http_interactions: +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/logon?CompanyId=L&CompanyPassword=&Operator=wland&OperatorPassword=piperita2016 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/0.1.0 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Length: + - '36' + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Fri, 06 Apr 2018 19:23:03 GMT + body: + encoding: UTF-8 + string: '64C41E1DEB73024CA660211DE643705700 ' + http_version: + recorded_at: Fri, 06 Apr 2018 19:23:01 GMT +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/Query/Browse?UserId=64C41E1DEB73024CA660211DE643705700%20%20&XmlIn=%3C?xml%20version=%221.0%22%20encoding=%22Windows-1252%22?%3E%0A%3CBrowse%20xmlns:xsd=%22http://www.w3.org/2001/XMLSchema-instance%22%20xsd:noNamespaceSchemaLocation=%22COMBRW.XSD%22%3E%0A%20%20%3CBrowseName%3EInvMaster%3C/BrowseName%3E%0A%20%20%3CStartAtKey/%3E%0A%20%20%3CStartCondition%3E%3C/StartCondition%3E%0A%20%20%3CReturnRows%3E5%3C/ReturnRows%3E%0A%20%20%0A%20%20%3CBrowseDetails%3E%0A%20%20%20%20%3CTableName%3EInvMaster%3C/TableName%3E%0A%20%20%20%20%3CTitle%3EStockCodes%3C/Title%3E%0A%20%20%20%20%0A%20%20%20%20%20%20%3CColumn%3E%0A%20%20%20%20%20%20%20%20%3CColumnName%3EStockCode%3C/ColumnName%3E%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%3C/Column%3E%0A%20%20%20%20%0A%20%20%3C/BrowseDetails%3E%0A%3C/Browse%3E%0A%0A + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/0.1.0 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Length: + - '944' + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Fri, 06 Apr 2018 19:23:07 GMT + body: + encoding: UTF-8 + string: "\n\nStockCodes\n\n\n02\nAlphaNumeric\n\n\n\n\n021\nAlphaNumeric\n\n\n\n\n0214011IFF\nAlphaNumeric\n\n\n\n\n022\nAlphaNumeric\n\n\n\n\n023\nAlphaNumeric\n\n\n\n02\n023\nTrue\nFalse\n\n\n
Stock + code
\nStockCode\nStock code\nInvMaster
\n
\n
\n " + http_version: + recorded_at: Fri, 06 Apr 2018 19:23:06 GMT +recorded_with: VCR 4.0.0 diff --git a/test/cassettes/test_query_fetch.yml b/test/cassettes/test_query_fetch.yml new file mode 100644 index 0000000..c335574 --- /dev/null +++ b/test/cassettes/test_query_fetch.yml @@ -0,0 +1,96 @@ +--- +http_interactions: +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/logon?CompanyId=L&CompanyPassword=&Operator=wland&OperatorPassword=piperita2016 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/0.1.0 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Length: + - '36' + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Fri, 06 Apr 2018 19:23:16 GMT + body: + encoding: UTF-8 + string: '5B21680F424424498B7CE7CCDA98B41700 ' + http_version: + recorded_at: Fri, 06 Apr 2018 19:23:15 GMT +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/Query/Fetch?UserId=5B21680F424424498B7CE7CCDA98B41700%20%20&XmlIn=%3C?xml%20version=%221.0%22%20encoding=%22Windows-1252%22?%3E%0A%3CFetch%20xmlns:xsd=%22http://www.w3.org/2001/XMLSchema-instance%22%20xsd:noNamespaceSchemaLocation=%22COMFCH.XSD%22%3E%0A%20%20%3CTableName%3EInvMaster%3C/TableName%3E%0A%20%20%3CKey%3E02%3C/Key%3E%0A%20%20%0A%20%20%3CFullKeyProvided%3EY%3C/FullKeyProvided%3E%0A%20%20%3CDefaultType%3E%3C/DefaultType%3E%0A%20%20%3CEspressoFetch%3EN%3C/EspressoFetch%3E%0A%3C/Fetch%3E%0A%0A + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/0.1.0 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Length: + - '3911' + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Fri, 06 Apr 2018 19:23:26 GMT + body: + encoding: UTF-8 + string: "\n\n02\nSTR\nSPEARMINT + TERPENES\n\n\n\nLB\nKG\nDR\n + \ 2.204620\nM\n + \ 400.000000\nM\n 1.000000\n + \ 0.000000\n3\nA\nC\n\n + 0\nSTRP\nA\n\nA\nN\nY\nN\n + 0\n\n\nT\nN\nN\n\n + \ 0\nY\nN\n0000-00-00\nY\nN\nLB\n + \ 0.00\n 0.00000\n + \ 0.00000\n 0.00000\n + \ 0.00000\nB\n\nH1\nA\n + 0.0000\n 0\n 400.000000\n + \ 0\n 1\n 0.000000\n + \ 0\nF\n + \ 0\n\n\n 0\nN\n + \ 0\nI\n100\n + \ 0.00000\n 0.00000\n + \ 0.00000\n 0.00000\n + \ 0.00000\n\n\nA\nN\n\n\n\n + \ 0.00000\n\n\n\n\nN\nE\n + \ 0.00000\nN\n\nY\nY\n + \ 0.00000\n\n\n\n\nN\nN\n0\n\n\n\n\n\nN\n\n\n\n\n + \ 0.00000\n2005-08-26\n\n\n\n\n\n\n\n\nLB\n + \ 1.000000\nM\n 0\n + \ 0.000\n\n\n\n\n + \ 0\n 0\n\n\n\n\n\n " + http_version: + recorded_at: Fri, 06 Apr 2018 19:23:24 GMT +recorded_with: VCR 4.0.0 diff --git a/test/cassettes/test_query_query.yml b/test/cassettes/test_query_query.yml new file mode 100644 index 0000000..1d6af87 --- /dev/null +++ b/test/cassettes/test_query_query.yml @@ -0,0 +1,72 @@ +--- +http_interactions: +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/logon?CompanyId=L&CompanyPassword=&Operator=wland&OperatorPassword=piperita2016 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/0.1.0 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Length: + - '36' + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Fri, 06 Apr 2018 19:23:35 GMT + body: + encoding: UTF-8 + string: '5810EEA000F1F04BA915BAF98CA700EE00 ' + http_version: + recorded_at: Fri, 06 Apr 2018 19:23:33 GMT +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/Query/Query?BusinessObject=COMFND&UserId=5810EEA000F1F04BA915BAF98CA700EE00%20%20&XmlIn=%3C?xml%20version=%221.0%22%20encoding=%22Windows-1252%22?%3E%0A%3CQuery%20xmlns:xsd=%22http://www.w3.org/2001/XMLSchema-instance%22%20xsd:noNamespaceSchemaLocation=%22COMFND.XSD%22%3E%0A%20%20%3CTableName%3EInvMaster%3C/TableName%3E%0A%20%20%3CReturnRows%3E5%3C/ReturnRows%3E%0A%20%20%3CColumns%3E%0A%20%20%20%20%0A%20%20%20%20%20%20%3CColumn%3EStockCode%3C/Column%3E%0A%20%20%20%20%0A%20%20%3C/Columns%3E%0A%20%20%0A%20%20%20%20%3CWhere%3E%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%3CExpression%3E%0A%20%20%20%20%20%20%20%20%20%20%3COpenBracket%3E(%3C/OpenBracket%3E%0A%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CAndOr%3EAnd%3C/AndOr%3E%0A%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%3CColumn%3EStockCode%3C/Column%3E%0A%20%20%20%20%20%20%20%20%20%20%3CCondition%3EEQ%3C/Condition%3E%0A%20%20%20%20%20%20%20%20%20%20%3CValue%3E02%3C/Value%3E%0A%20%20%20%20%20%20%20%20%20%20%3CCloseBracket%3E)%3C/CloseBracket%3E%0A%20%20%20%20%20%20%20%20%3C/Expression%3E%0A%20%20%20%20%20%20%0A%20%20%20%20%3C/Where%3E%0A%20%20%0A%20%20%3COrderBy%3E%0A%20%20%20%20%3CColumn%3EStockCode%3C/Column%3E%0A%20%20%3C/OrderBy%3E%0A%3C/Query%3E%0A + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/0.1.0 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Length: + - '436' + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Fri, 06 Apr 2018 19:23:43 GMT + body: + encoding: UTF-8 + string: "\n\n\nInvMaster\n\nStockCode\n\n\nStockCode\n\n\n\n02\n\n + \ 1\n\n " + http_version: + recorded_at: Fri, 06 Apr 2018 19:23:41 GMT +recorded_with: VCR 4.0.0 diff --git a/test/cassettes/test_successful_logoff.yml b/test/cassettes/test_successful_logoff.yml new file mode 100644 index 0000000..8ff8c38 --- /dev/null +++ b/test/cassettes/test_successful_logoff.yml @@ -0,0 +1,69 @@ +--- +http_interactions: +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/logon?CompanyId=L&CompanyPassword=&Operator=wland&OperatorPassword=piperita2016 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/0.1.0 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Length: + - '36' + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Fri, 06 Apr 2018 19:22:53 GMT + body: + encoding: UTF-8 + string: '989D81EB0B184A499E7AC2E28724EE9000 ' + http_version: + recorded_at: Fri, 06 Apr 2018 19:22:52 GMT +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/logoff?UserId=989D81EB0B184A499E7AC2E28724EE9000%20%20 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/0.1.0 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Length: + - '1' + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Fri, 06 Apr 2018 19:22:53 GMT + body: + encoding: UTF-8 + string: '0' + http_version: + recorded_at: Fri, 06 Apr 2018 19:22:52 GMT +recorded_with: VCR 4.0.0 diff --git a/test/client_test.rb b/test/client_test.rb index 395923b..acb64c4 100644 --- a/test/client_test.rb +++ b/test/client_test.rb @@ -4,6 +4,8 @@ require 'test_helper' class SysproClientTest < Minitest::Test extend Minitest::Spec::DSL + before { VCR.insert_cassette name } + after { VCR.eject_cassette } let(:client) { ::Syspro::SysproClient.new } diff --git a/test/logoff_test.rb b/test/logoff_test.rb index 5d336f2..37d7f6f 100644 --- a/test/logoff_test.rb +++ b/test/logoff_test.rb @@ -4,6 +4,8 @@ require 'test_helper' class LogoffTest < Minitest::Test extend Minitest::Spec::DSL + before { VCR.insert_cassette name } + after { VCR.eject_cassette } let(:username) { 'wland' } let(:password) { 'piperita2016' } diff --git a/test/logon_test.rb b/test/logon_test.rb index 89a8779..73c5345 100644 --- a/test/logon_test.rb +++ b/test/logon_test.rb @@ -4,6 +4,8 @@ require 'test_helper' class LogonTest < Minitest::Test extend Minitest::Spec::DSL + before { VCR.insert_cassette name } + after { VCR.eject_cassette } let(:username) { 'wland' } let(:password) { 'piperita2016' } diff --git a/test/query_test.rb b/test/query_test.rb index d840223..5e1a72c 100644 --- a/test/query_test.rb +++ b/test/query_test.rb @@ -3,9 +3,19 @@ require 'test_helper' class QueryTest < Minitest::Test - def test_query_browse # rubocop:disable Metrics/MethodLength - user_id = Syspro::Logon.logon('wland', 'piperita2016', 'L', '') + extend Minitest::Spec::DSL + before { VCR.insert_cassette name } + after { VCR.eject_cassette } + + let(:username) { 'wland' } + let(:password) { 'piperita2016' } + let(:company) { 'L' } + let(:company_password) { '' } + let(:user_id) do + Syspro::Logon.logon(username, password, company, company_password) + end + def test_query_browse # rubocop:disable Metrics/MethodLength combrw = Syspro::BusinessObjects::ComBrw.new combrw.browse_name = 'InvMaster' combrw.start_condition = '' @@ -23,8 +33,6 @@ class QueryTest < Minitest::Test end def test_query_query # rubocop:disable Metrics/MethodLength - user_id = Syspro::Logon.logon('wland', 'piperita2016', 'L', '') - comfnd = Syspro::BusinessObjects::ComFnd.new comfnd.table_name = 'InvMaster' comfnd.return_rows = 5 @@ -49,8 +57,6 @@ class QueryTest < Minitest::Test end def test_query_fetch - user_id = Syspro::Logon.logon('wland', 'piperita2016', 'L', '') - comfch = Syspro::BusinessObjects::ComFch.new comfch.table_name = 'InvMaster' comfch.key = '02' diff --git a/test/test_helper.rb b/test/test_helper.rb index 4f58449..59a2236 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -5,3 +5,14 @@ require 'syspro' require 'pry' require 'minitest/autorun' +require 'minitest-vcr' +require 'webmock' + +VCR.configure do |c| + c.cassette_library_dir = 'test/cassettes' + c.hook_into :webmock + # TODO: change passwords and move them to ENV + # c.filter_sensitive_data() { ENV[] } +end + +MinitestVcr::Spec.configure! -- libgit2 0.21.4