vagrant-unbundled 2.0.0.1 → 2.0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/CHANGELOG.md +34 -0
- data/Gemfile.lock +10 -10
- data/README.md +2 -2
- data/contrib/sudoers/linux-suse +6 -7
- data/lib/vagrant/plugin/v2/command.rb +3 -0
- data/lib/vagrant/plugin/v2/communicator.rb +1 -1
- data/lib/vagrant/registry.rb +1 -1
- data/lib/vagrant/util/downloader.rb +1 -2
- data/lib/vagrant/util/is_port_open.rb +2 -1
- data/lib/vagrant/util/keypair.rb +1 -1
- data/lib/vagrant/util/platform.rb +39 -23
- data/plugins/commands/destroy/command.rb +31 -10
- data/plugins/communicators/ssh/communicator.rb +1 -0
- data/plugins/communicators/winrm/helper.rb +6 -1
- data/plugins/guests/solaris11/cap/change_host_name.rb +0 -2
- data/plugins/guests/solaris11/cap/configure_networks.rb +1 -7
- data/plugins/guests/solaris11/plugin.rb +5 -35
- data/plugins/guests/windows/cap/public_key.rb +2 -0
- data/plugins/guests/windows/guest_network.rb +3 -3
- data/plugins/guests/windows/scripts/reboot_detect.ps1 +5 -0
- data/plugins/providers/docker/driver.rb +1 -1
- data/plugins/providers/docker/executor/local.rb +4 -0
- data/plugins/providers/docker/executor/vagrant.rb +4 -0
- data/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 +1 -1
- data/plugins/providers/virtualbox/driver/meta.rb +1 -0
- data/plugins/providers/virtualbox/driver/version_5_2.rb +16 -0
- data/plugins/providers/virtualbox/plugin.rb +1 -0
- data/plugins/providers/virtualbox/synced_folder.rb +1 -1
- data/plugins/provisioners/chef/provisioner/chef_client.rb +30 -23
- data/plugins/provisioners/chef/provisioner/chef_solo.rb +26 -19
- data/plugins/provisioners/chef/provisioner/chef_zero.rb +29 -22
- data/plugins/provisioners/puppet/provisioner/puppet.rb +23 -4
- data/plugins/provisioners/salt/bootstrap-salt.ps1 +15 -3
- data/plugins/provisioners/salt/bootstrap-salt.sh +2 -0
- data/plugins/provisioners/salt/config.rb +11 -0
- data/plugins/provisioners/salt/provisioner.rb +10 -7
- data/plugins/provisioners/shell/provisioner.rb +1 -1
- data/templates/locales/en.yml +5 -0
- data/test/unit/base.rb +2 -0
- data/test/unit/plugins/commands/destroy/command_test.rb +155 -0
- data/test/unit/plugins/communicators/winrm/helper_test.rb +33 -0
- data/test/unit/plugins/guests/solaris11/cap/change_host_name_test.rb +36 -0
- data/test/unit/plugins/guests/solaris11/cap/configure_networks_test.rb +56 -0
- data/test/unit/plugins/providers/virtualbox/synced_folder_test.rb +26 -0
- data/test/unit/plugins/provisioners/salt/config_test.rb +42 -0
- data/test/unit/plugins/provisioners/salt/provisioner_test.rb +16 -1
- data/test/unit/plugins/provisioners/shell/config_test.rb +3 -3
- data/test/unit/plugins/pushes/local-exec/config_test.rb +2 -2
- data/test/unit/vagrant/util/downloader_test.rb +28 -0
- data/test/unit/vagrant/util/platform_test.rb +58 -0
- data/vagrant.gemspec +1 -1
- data/vendor/bundle/ruby/2.4.0/bin/rwinrmcp +5 -0
- data/vendor/bundle/ruby/2.4.0/bin/vagrant +5 -0
- data/vendor/bundle/ruby/2.4.0/bin/vagrant-spec +5 -0
- data/vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-spec-af86757912f7/vagrant-spec.gemspec +3 -3
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/CHANGELOG.md +216 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/Gemfile +32 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/LICENSE.txt +202 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/README.md +121 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/Rakefile +32 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/data/unicode.data +0 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/lib/addressable/idna/native.rb +59 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/lib/addressable/idna/pure.rb +677 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/lib/addressable/idna.rb +25 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/lib/addressable/template.rb +1065 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/lib/addressable/uri.rb +2492 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/lib/addressable/version.rb +30 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/lib/addressable.rb +2 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/spec/addressable/idna_spec.rb +298 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/spec/addressable/net_http_compat_spec.rb +28 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/spec/addressable/rack_mount_compat_spec.rb +104 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/spec/addressable/security_spec.rb +57 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/spec/addressable/template_spec.rb +1419 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/spec/addressable/uri_spec.rb +6468 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/spec/spec_helper.rb +21 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/tasks/clobber.rake +2 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/tasks/gem.rake +91 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/tasks/git.rake +45 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/tasks/metrics.rake +22 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/tasks/rspec.rake +21 -0
- data/vendor/bundle/ruby/2.4.0/gems/addressable-2.5.2/tasks/yard.rake +27 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/.gitignore +15 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/.rspec +1 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/.travis.yml +13 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/.yardopts +1 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/Gemfile +6 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/LICENSE +19 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/README.md +265 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/Rakefile +13 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/changelog.md +72 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/hashdiff.gemspec +25 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/lib/hashdiff/diff.rb +232 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/lib/hashdiff/lcs.rb +69 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/lib/hashdiff/linear_compare_array.rb +155 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/lib/hashdiff/patch.rb +88 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/lib/hashdiff/util.rb +146 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/lib/hashdiff/version.rb +3 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/lib/hashdiff.rb +6 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/spec/hashdiff/best_diff_spec.rb +74 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/spec/hashdiff/diff_array_spec.rb +60 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/spec/hashdiff/diff_spec.rb +339 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/spec/hashdiff/lcs_spec.rb +75 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/spec/hashdiff/linear_compare_array_spec.rb +48 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/spec/hashdiff/patch_spec.rb +183 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/spec/hashdiff/util_spec.rb +78 -0
- data/vendor/bundle/ruby/2.4.0/gems/hashdiff-0.3.7/spec/spec_helper.rb +13 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/CHANGELOG.md +250 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/CONTRIBUTING.md +46 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/LICENSE.md +20 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/README.md +122 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/lib/multi_json/adapter.rb +49 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/lib/multi_json/adapter_error.rb +15 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/lib/multi_json/adapters/gson.rb +20 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/lib/multi_json/adapters/jr_jackson.rb +25 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/lib/multi_json/adapters/json_common.rb +23 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/lib/multi_json/adapters/json_gem.rb +11 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/lib/multi_json/adapters/json_pure.rb +11 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/lib/multi_json/adapters/nsjsonserialization.rb +32 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/lib/multi_json/adapters/oj.rb +25 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/lib/multi_json/adapters/ok_json.rb +23 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/lib/multi_json/adapters/yajl.rb +19 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/lib/multi_json/convertible_hash_keys.rb +43 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/lib/multi_json/options.rb +39 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/lib/multi_json/options_cache.rb +29 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/lib/multi_json/parse_error.rb +17 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/lib/multi_json/vendor/okjson.rb +606 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/lib/multi_json/version.rb +17 -0
- data/vendor/bundle/ruby/2.4.0/gems/multi_json-1.12.2/lib/multi_json.rb +161 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/.gitignore +11 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/.rubocop.yml +32 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/.rubocop_defaults.yml +177 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/.travis.yml +24 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/.yardopts +1 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/2.0-Upgrade.md +52 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/CHANGELOG.md +330 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/Gemfile +10 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/LICENSE.txt +22 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/README.md +202 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/Rakefile +49 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/bin/console +14 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/data/list.txt +12288 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/lib/public_suffix/domain.rb +235 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/lib/public_suffix/errors.rb +39 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/lib/public_suffix/list.rb +243 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/lib/public_suffix/rule.rb +348 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/lib/public_suffix/version.rb +10 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/lib/public_suffix.rb +175 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/public_suffix.gemspec +25 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/.empty +2 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/acceptance_test.rb +127 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/benchmarks/bm_find.rb +66 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/benchmarks/bm_find_all.rb +102 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/benchmarks/bm_names.rb +91 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/benchmarks/bm_select.rb +26 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/benchmarks/bm_select_incremental.rb +25 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/benchmarks/bm_valid.rb +101 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/profilers/domain_profiler.rb +12 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/profilers/find_profiler.rb +12 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/profilers/find_profiler_jp.rb +12 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/profilers/initialization_profiler.rb +11 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/profilers/list_profsize.rb +11 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/profilers/object_binsize.rb +57 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/psl_test.rb +49 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/test_helper.rb +13 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/tests.txt +98 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/unit/domain_test.rb +104 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/unit/errors_test.rb +23 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/unit/list_test.rb +239 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/unit/public_suffix_test.rb +186 -0
- data/vendor/bundle/ruby/2.4.0/gems/public_suffix-3.0.1/test/unit/rule_test.rb +220 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/.gemtest +0 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/.gitignore +34 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/.rspec-tm +2 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/.travis.yml +24 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/CHANGELOG.md +1460 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/Gemfile +9 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/LICENSE +20 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/README.md +1045 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/Rakefile +30 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/api.rb +97 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/assertion_failure.rb +11 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/callback_registry.rb +35 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/config.rb +18 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/cucumber.rb +10 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/deprecation.rb +9 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/errors.rb +17 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/http_lib_adapters/curb_adapter.rb +337 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +228 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/http_lib_adapters/excon_adapter.rb +162 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/http_lib_adapters/http_lib_adapter.rb +7 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/http_lib_adapters/http_lib_adapter_registry.rb +19 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/http_lib_adapters/http_rb/client.rb +14 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/http_lib_adapters/http_rb/request.rb +10 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/http_lib_adapters/http_rb/response.rb +43 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/http_lib_adapters/http_rb/streamer.rb +25 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/http_lib_adapters/http_rb/webmock.rb +68 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/http_lib_adapters/http_rb_adapter.rb +37 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/http_lib_adapters/httpclient_adapter.rb +240 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/http_lib_adapters/manticore_adapter.rb +127 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/http_lib_adapters/net_http.rb +362 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/http_lib_adapters/net_http_response.rb +34 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/http_lib_adapters/patron_adapter.rb +130 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb +174 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/matchers/hash_including_matcher.rb +36 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/minitest.rb +41 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/rack_response.rb +69 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/request_body_diff.rb +64 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/request_execution_verifier.rb +78 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/request_pattern.rb +343 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/request_registry.rb +35 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/request_signature.rb +54 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/request_signature_snippet.rb +61 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/request_stub.rb +100 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/response.rb +153 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/responses_sequence.rb +40 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/rspec/matchers/request_pattern_matcher.rb +78 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/rspec/matchers/webmock_matcher.rb +52 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/rspec/matchers.rb +27 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/rspec.rb +35 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/stub_registry.rb +67 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/stub_request_snippet.rb +34 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/test_unit.rb +22 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/util/hash_counter.rb +32 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/util/hash_keys_stringifier.rb +25 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/util/hash_validator.rb +17 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/util/headers.rb +49 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/util/json.rb +78 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/util/query_mapper.rb +279 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/util/uri.rb +111 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/util/version_checker.rb +111 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/version.rb +3 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/webmock.rb +156 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock.rb +54 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/minitest/test_helper.rb +34 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/minitest/test_webmock.rb +9 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/minitest/webmock_spec.rb +60 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/curb/curb_spec.rb +466 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/curb/curb_spec_helper.rb +147 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/em_http_request/em_http_request_spec.rb +406 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/em_http_request/em_http_request_spec_helper.rb +77 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/excon/excon_spec.rb +75 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/excon/excon_spec_helper.rb +50 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/http_rb/http_rb_spec.rb +73 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/http_rb/http_rb_spec_helper.rb +51 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/httpclient/httpclient_spec.rb +209 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/httpclient/httpclient_spec_helper.rb +57 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/manticore/manticore_spec.rb +56 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/manticore/manticore_spec_helper.rb +35 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/net_http/net_http_shared.rb +142 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/net_http/net_http_spec.rb +317 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/net_http/net_http_spec_helper.rb +64 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/net_http/real_net_http_spec.rb +20 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/patron/patron_spec.rb +118 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/patron/patron_spec_helper.rb +54 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/shared/allowing_and_disabling_net_connect.rb +313 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/shared/callbacks.rb +147 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/shared/complex_cross_concern_behaviors.rb +36 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/shared/enabling_and_disabling_webmock.rb +95 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/shared/precedence_of_stubs.rb +15 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/shared/request_expectations.rb +916 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/shared/returning_declared_responses.rb +388 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/shared/stubbing_requests.rb +583 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/typhoeus/typhoeus_hydra_spec.rb +135 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/typhoeus/typhoeus_hydra_spec_helper.rb +60 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/webmock_shared.rb +41 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/fixtures/test.txt +1 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/quality_spec.rb +84 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/spec_helper.rb +48 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/support/example_curl_output.txt +22 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/support/failures.rb +9 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/support/my_rack_app.rb +53 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/support/network_connection.rb +19 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/support/webmock_server.rb +69 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/api_spec.rb +75 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/errors_spec.rb +129 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/http_lib_adapters/http_lib_adapter_registry_spec.rb +17 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/http_lib_adapters/http_lib_adapter_spec.rb +12 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/matchers/hash_including_matcher_spec.rb +87 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/rack_response_spec.rb +112 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/request_body_diff_spec.rb +90 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/request_execution_verifier_spec.rb +208 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/request_pattern_spec.rb +590 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/request_registry_spec.rb +76 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/request_signature_snippet_spec.rb +89 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/request_signature_spec.rb +155 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/request_stub_spec.rb +199 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/response_spec.rb +282 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/stub_registry_spec.rb +103 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/stub_request_snippet_spec.rb +95 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/util/hash_counter_spec.rb +39 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/util/hash_keys_stringifier_spec.rb +27 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/util/headers_spec.rb +28 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/util/json_spec.rb +33 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/util/query_mapper_spec.rb +138 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/util/uri_spec.rb +299 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/util/version_checker_spec.rb +65 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/unit/webmock_spec.rb +11 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/test/http_request.rb +24 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/test/shared_test.rb +95 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/test/test_helper.rb +23 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/test/test_webmock.rb +6 -0
- data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/webmock.gemspec +46 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/.gitignore +11 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/.rspec +3 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/.rubocop.yml +9 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/.travis.yml +9 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/Gemfile +5 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/LICENSE +202 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/README.md +79 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/Rakefile +28 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/VERSION +1 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/Vagrantfile +9 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/appveyor.yml +38 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/bin/rwinrmcp +86 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/changelog.md +60 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/lib/winrm-fs/core/file_transporter.rb +527 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/lib/winrm-fs/core/tmp_zip.rb +177 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/lib/winrm-fs/exceptions.rb +28 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/lib/winrm-fs/file_manager.rb +118 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/lib/winrm-fs/scripts/check_files.ps1.erb +49 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/lib/winrm-fs/scripts/checksum.ps1.erb +13 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/lib/winrm-fs/scripts/create_dir.ps1.erb +6 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/lib/winrm-fs/scripts/delete.ps1.erb +6 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/lib/winrm-fs/scripts/download.ps1.erb +8 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/lib/winrm-fs/scripts/exists.ps1.erb +10 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/lib/winrm-fs/scripts/extract_files.ps1.erb +52 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/lib/winrm-fs/scripts/scripts.rb +31 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/lib/winrm-fs.rb +28 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/spec/config-example.yml +3 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/spec/integration/file_manager_spec.rb +224 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/spec/integration/tmp_zip_spec.rb +26 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/spec/matchers.rb +58 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/spec/spec_helper.rb +71 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/spec/unit/tmp_zip_spec.rb +79 -0
- data/vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.1.1/winrm-fs.gemspec +37 -0
- data/vendor/bundle/ruby/2.4.0/specifications/addressable-2.5.2.gemspec +39 -0
- data/vendor/bundle/ruby/2.4.0/specifications/hashdiff-0.3.7.gemspec +39 -0
- data/vendor/bundle/ruby/2.4.0/specifications/multi_json-1.12.2.gemspec +33 -0
- data/vendor/bundle/ruby/2.4.0/specifications/public_suffix-3.0.1.gemspec +41 -0
- data/vendor/bundle/ruby/2.4.0/specifications/webmock-2.3.2.gemspec +79 -0
- data/vendor/bundle/ruby/2.4.0/specifications/winrm-fs-1.1.1.gemspec +57 -0
- data/version.txt +1 -1
- metadata +295 -11
- data/plugins/guests/solaris11/cap/halt.rb +0 -26
- data/plugins/guests/solaris11/cap/insert_public_key.rb +0 -21
- data/plugins/guests/solaris11/cap/mount_virtualbox_shared_folder.rb +0 -45
- data/plugins/guests/solaris11/cap/remove_public_key.rb +0 -21
- data/plugins/guests/solaris11/cap/rsync.rb +0 -29
- data/test/unit/plugins/guests/solaris11/cap/halt_test.rb +0 -44
@@ -0,0 +1,147 @@
|
|
1
|
+
shared_context "callbacks" do |*adapter_info|
|
2
|
+
describe "when after_request callback is declared" do
|
3
|
+
before(:each) do
|
4
|
+
@called = nil
|
5
|
+
WebMock.reset_callbacks
|
6
|
+
stub_request(:get, "http://www.example.com")
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should not invoke callback unless request is made" do
|
10
|
+
WebMock.after_request {
|
11
|
+
@called = true
|
12
|
+
}
|
13
|
+
expect(@called).to eq(nil)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should invoke a callback after request is made" do
|
17
|
+
WebMock.after_request {
|
18
|
+
@called = true
|
19
|
+
}
|
20
|
+
http_request(:get, "http://www.example.com/")
|
21
|
+
expect(@called).to eq(true)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should not invoke a callback if this http library should be ignored" do
|
25
|
+
WebMock.after_request(except: [http_library()]) {
|
26
|
+
@called = true
|
27
|
+
}
|
28
|
+
http_request(:get, "http://www.example.com/")
|
29
|
+
expect(@called).to eq(nil)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should invoke a callback even if other http libraries should be ignored" do
|
33
|
+
WebMock.after_request(except: [:other_lib]) {
|
34
|
+
@called = true
|
35
|
+
}
|
36
|
+
http_request(:get, "http://www.example.com/")
|
37
|
+
expect(@called).to eq(true)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should pass request signature to the callback" do
|
41
|
+
WebMock.after_request(except: [:other_lib]) do |request_signature, _|
|
42
|
+
@request_signature = request_signature
|
43
|
+
end
|
44
|
+
http_request(:get, "http://www.example.com/")
|
45
|
+
expect(@request_signature.uri.to_s).to eq("http://www.example.com:80/")
|
46
|
+
end
|
47
|
+
|
48
|
+
after(:each) do
|
49
|
+
WebMock::StubRegistry.instance.global_stubs.clear
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'passes the same request signature instance to the callback that was passed to the global stub callback' do
|
53
|
+
global_stub_request_sig = after_request_request_sig = nil
|
54
|
+
WebMock.globally_stub_request do |request_sig|
|
55
|
+
global_stub_request_sig = request_sig
|
56
|
+
nil
|
57
|
+
end
|
58
|
+
|
59
|
+
WebMock.after_request do |request_sig, _|
|
60
|
+
after_request_request_sig = request_sig
|
61
|
+
end
|
62
|
+
|
63
|
+
http_request(:get, "http://www.example.com/")
|
64
|
+
expect(global_stub_request_sig).to be(after_request_request_sig)
|
65
|
+
end
|
66
|
+
|
67
|
+
context "passing response to callback" do
|
68
|
+
context "when request is stubbed" do
|
69
|
+
before(:each) do
|
70
|
+
stub_request(:get, "http://www.example.com").
|
71
|
+
to_return(
|
72
|
+
status: [200, "hello"],
|
73
|
+
headers: {'Content-Length' => '666', 'Hello' => 'World'},
|
74
|
+
body: "foo bar"
|
75
|
+
)
|
76
|
+
WebMock.after_request(except: [:other_lib]) do |_, response|
|
77
|
+
@response = response
|
78
|
+
end
|
79
|
+
http_request(:get, "http://www.example.com/")
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should pass response to callback with the status and message" do
|
83
|
+
expect(@response.status).to eq([200, "hello"])
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should pass response to callback with headers" do
|
87
|
+
expect(@response.headers).to eq({
|
88
|
+
'Content-Length' => '666',
|
89
|
+
'Hello' => 'World'
|
90
|
+
})
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should pass response to callback with body" do
|
94
|
+
expect(@response.body).to eq("foo bar")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "when request is not stubbed", net_connect: true do
|
99
|
+
before(:each) do
|
100
|
+
WebMock.reset!
|
101
|
+
WebMock.allow_net_connect!
|
102
|
+
WebMock.after_request(except: [:other_lib]) do |_, response|
|
103
|
+
@response = response
|
104
|
+
end
|
105
|
+
http_request(:get, "http://httpstat.us/201")
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should pass real response to callback with status and message" do
|
109
|
+
expect(@response.status[0]).to eq(201)
|
110
|
+
expect(@response.status[1]).to eq("Created") unless adapter_info.include?(:no_status_message)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should pass real response to callback with headers" do
|
114
|
+
expect(@response.headers["Content-Length"]).to eq("11")
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should pass response to callback with body" do
|
118
|
+
expect(@response.body.size).to eq(11)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should invoke multiple callbacks in order of their declarations" do
|
124
|
+
WebMock.after_request { @called = 1 }
|
125
|
+
WebMock.after_request { @called += 1 }
|
126
|
+
http_request(:get, "http://www.example.com/")
|
127
|
+
expect(@called).to eq(2)
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should invoke callbacks only for real requests if requested", net_connect: true do
|
131
|
+
WebMock.after_request(real_requests_only: true) { @called = true }
|
132
|
+
http_request(:get, "http://www.example.com/")
|
133
|
+
expect(@called).to eq(nil)
|
134
|
+
WebMock.allow_net_connect!
|
135
|
+
http_request(:get, "http://www.example.net/")
|
136
|
+
expect(@called).to eq(true)
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should not invoke any callbacks after callbacks were reset" do
|
140
|
+
WebMock.after_request { @called = 1 }
|
141
|
+
WebMock.reset_callbacks
|
142
|
+
stub_request(:get, "http://www.example.com/")
|
143
|
+
http_request(:get, "http://www.example.com/")
|
144
|
+
expect(@called).to eq(nil)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
shared_context "complex cross-concern behaviors" do |*adapter_info|
|
2
|
+
it 'allows a response with multiple values for the same header to be recorded and played back exactly as-is' do
|
3
|
+
WebMock.allow_net_connect!
|
4
|
+
|
5
|
+
recorded_response = nil
|
6
|
+
WebMock.after_request { |_,r| recorded_response = r }
|
7
|
+
real_response = http_request(:get, webmock_server_url)
|
8
|
+
|
9
|
+
stub_request(:get, webmock_server_url).to_return(
|
10
|
+
status: recorded_response.status,
|
11
|
+
body: recorded_response.body,
|
12
|
+
headers: recorded_response.headers
|
13
|
+
)
|
14
|
+
|
15
|
+
played_back_response = http_request(:get, webmock_server_url)
|
16
|
+
|
17
|
+
expect(played_back_response.headers.keys).to include('Set-Cookie')
|
18
|
+
expect(played_back_response).to eq(real_response)
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:no_content_url) { 'http://httpstat.us/204' }
|
22
|
+
[nil, ''].each do |stub_val|
|
23
|
+
it "returns the same value (nil or "") for a request stubbed as #{stub_val.inspect} that a real empty response has", net_connect: true do
|
24
|
+
unless http_library == :curb
|
25
|
+
WebMock.allow_net_connect!
|
26
|
+
|
27
|
+
real_response = http_request(:get, no_content_url)
|
28
|
+
stub_request(:get, no_content_url).to_return(status: 204, body: stub_val)
|
29
|
+
stubbed_response = http_request(:get, no_content_url)
|
30
|
+
|
31
|
+
expect(stubbed_response.body).to eq(real_response.body)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
shared_context "enabled and disabled webmock" do |*adapter_info|
|
2
|
+
describe "when webmock is disabled" do
|
3
|
+
before(:each) do
|
4
|
+
WebMock.disable!
|
5
|
+
end
|
6
|
+
after(:each) do
|
7
|
+
WebMock.enable!
|
8
|
+
end
|
9
|
+
include_context "disabled WebMock"
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "when webmock is enabled again" do
|
13
|
+
before(:each) do
|
14
|
+
WebMock.disable!
|
15
|
+
WebMock.enable!
|
16
|
+
end
|
17
|
+
include_context "enabled WebMock"
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "when webmock is disabled except this lib" do
|
21
|
+
before(:each) do
|
22
|
+
WebMock.disable!(except: [http_library])
|
23
|
+
end
|
24
|
+
after(:each) do
|
25
|
+
WebMock.enable!
|
26
|
+
end
|
27
|
+
include_context "enabled WebMock"
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "when webmock is enabled except this lib" do
|
31
|
+
before(:each) do
|
32
|
+
WebMock.disable!
|
33
|
+
WebMock.enable!(except: [http_library])
|
34
|
+
end
|
35
|
+
after(:each) do
|
36
|
+
WebMock.enable!
|
37
|
+
end
|
38
|
+
include_context "disabled WebMock"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
shared_context "disabled WebMock" do
|
43
|
+
it "should not register executed requests" do
|
44
|
+
http_request(:get, webmock_server_url)
|
45
|
+
expect(a_request(:get, webmock_server_url)).not_to have_been_made
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should not block unstubbed requests" do
|
49
|
+
expect {
|
50
|
+
http_request(:get, webmock_server_url)
|
51
|
+
}.not_to raise_error
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should return real response even if there are stubs" do
|
55
|
+
stub_request(:get, /.*/).to_return(body: "x")
|
56
|
+
expect(http_request(:get, webmock_server_url).body).to eq("hello world")
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should not invoke any callbacks" do
|
60
|
+
WebMock.reset_callbacks
|
61
|
+
stub_request(:get, webmock_server_url)
|
62
|
+
@called = nil
|
63
|
+
WebMock.after_request { @called = 1 }
|
64
|
+
http_request(:get, webmock_server_url)
|
65
|
+
expect(@called).to eq(nil)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
shared_context "enabled WebMock" do
|
70
|
+
it "should register executed requests" do
|
71
|
+
WebMock.allow_net_connect!
|
72
|
+
http_request(:get, webmock_server_url)
|
73
|
+
expect(a_request(:get, webmock_server_url)).to have_been_made
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should block unstubbed requests" do
|
77
|
+
expect {
|
78
|
+
http_request(:get, "http://www.example.com/")
|
79
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should return stubbed response" do
|
83
|
+
stub_request(:get, /.*/).to_return(body: "x")
|
84
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("x")
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should invoke callbacks" do
|
88
|
+
WebMock.allow_net_connect!
|
89
|
+
WebMock.reset_callbacks
|
90
|
+
@called = nil
|
91
|
+
WebMock.after_request { @called = 1 }
|
92
|
+
http_request(:get, webmock_server_url)
|
93
|
+
expect(@called).to eq(1)
|
94
|
+
end
|
95
|
+
end
|
data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/shared/precedence_of_stubs.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
shared_context "precedence of stubs" do |*adapter_info|
|
2
|
+
describe "when choosing a matching request stub" do
|
3
|
+
it "should use the last declared matching request stub" do
|
4
|
+
stub_request(:get, "www.example.com").to_return(body: "abc")
|
5
|
+
stub_request(:get, "www.example.com").to_return(body: "def")
|
6
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("def")
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should not be affected by the type of uri or request method" do
|
10
|
+
stub_request(:get, "www.example.com").to_return(body: "abc")
|
11
|
+
stub_request(:any, /.*example.*/).to_return(body: "def")
|
12
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("def")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/acceptance/shared/request_expectations.rb
ADDED
@@ -0,0 +1,916 @@
|
|
1
|
+
shared_context "request expectations" do |*adapter_info|
|
2
|
+
describe "when request expectations are set" do
|
3
|
+
describe "when net connect is not allowed" do
|
4
|
+
before(:each) do
|
5
|
+
WebMock.disable_net_connect!
|
6
|
+
stub_request(:any, "http://www.example.com")
|
7
|
+
stub_request(:any, "https://www.example.com")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should satisfy expectation if request was executed with the same uri and method" do
|
11
|
+
expect {
|
12
|
+
http_request(:get, "http://www.example.com/")
|
13
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.once
|
14
|
+
}.not_to raise_error
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should satisfy expectation declared on WebMock.resuest" do
|
18
|
+
expect {
|
19
|
+
http_request(:get, "http://www.example.com/")
|
20
|
+
expect(WebMock.request(:get, "http://www.example.com")).to have_been_made.once
|
21
|
+
}.not_to raise_error
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should satisfy expectation if request was not expected and not executed" do
|
25
|
+
expect {
|
26
|
+
expect(a_request(:get, "http://www.example.com")).not_to have_been_made
|
27
|
+
}.not_to raise_error
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should fail if request was not expected but executed" do
|
31
|
+
expect {
|
32
|
+
http_request(:get, "http://www.example.com/")
|
33
|
+
expect(a_request(:get, "http://www.example.com")).not_to have_been_made
|
34
|
+
}.to fail_with(%r(The request GET http://www.example.com/ was not expected to execute but it executed 1 time))
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should fail resulting with failure with a message and executed requests listed" do
|
38
|
+
expect {
|
39
|
+
http_request(:get, "http://www.example.com/")
|
40
|
+
expect(a_request(:get, "http://www.example.com")).not_to have_been_made
|
41
|
+
}.to fail_with(%r{The following requests were made:\n\nGET http://www.example.com/.+was made 1 time})
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should fail if request was not executed" do
|
45
|
+
expect {
|
46
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made
|
47
|
+
}.to fail_with(%r(The request GET http://www.example.com/ was expected to execute 1 time but it executed 0 times))
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should fail if request was executed to different uri" do
|
51
|
+
expect {
|
52
|
+
http_request(:get, "http://www.example.com/")
|
53
|
+
expect(a_request(:get, "http://www.example.org")).to have_been_made
|
54
|
+
}.to fail_with(%r(The request GET http://www.example.org/ was expected to execute 1 time but it executed 0 times))
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should fail if request was executed with different method" do
|
58
|
+
expect {
|
59
|
+
http_request(:post, "http://www.example.com/", body: "abc")
|
60
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made
|
61
|
+
}.to fail_with(%r(The request GET http://www.example.com/ was expected to execute 1 time but it executed 0 times))
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should satisfy expectation if request was executed with different form of uri" do
|
65
|
+
expect {
|
66
|
+
http_request(:get, "http://www.example.com/")
|
67
|
+
expect(a_request(:get, "www.example.com")).to have_been_made
|
68
|
+
}.not_to raise_error
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should satisfy expectation if request was executed with different form of uri without port " do
|
72
|
+
expect {
|
73
|
+
http_request(:get, "http://www.example.com/")
|
74
|
+
expect(a_request(:get, "www.example.com:80")).to have_been_made
|
75
|
+
}.not_to raise_error
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should satisfy expectation if request was executed with different form of uri with port" do
|
79
|
+
expect {
|
80
|
+
http_request(:get, "http://www.example.com/")
|
81
|
+
expect(a_request(:get, "www.example.com:80")).to have_been_made
|
82
|
+
}.not_to raise_error
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should fail if request was executed to a different port" do
|
86
|
+
expect {
|
87
|
+
http_request(:get, "http://www.example.com:80/")
|
88
|
+
expect(a_request(:get, "www.example.com:90")).to have_been_made
|
89
|
+
}.to fail_with(%r(The request GET http://www.example.com:90/ was expected to execute 1 time but it executed 0 times))
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should satisfy expectation if request was executed with different form of uri with https port" do
|
93
|
+
expect {
|
94
|
+
http_request(:get, "https://www.example.com/")
|
95
|
+
expect(a_request(:get, "https://www.example.com:443/")).to have_been_made
|
96
|
+
}.not_to raise_error
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should satisfy expectations even if requests were executed in different order than expectations were declared" do
|
100
|
+
stub_request(:post, "http://www.example.com")
|
101
|
+
http_request(:post, "http://www.example.com/", body: "def")
|
102
|
+
http_request(:post, "http://www.example.com/", body: "abc")
|
103
|
+
expect(WebMock).to have_requested(:post, "www.example.com").with(body: "abc")
|
104
|
+
expect(WebMock).to have_requested(:post, "www.example.com").with(body: "def")
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "when matching requests with escaped or unescaped uris" do
|
108
|
+
before(:each) do
|
109
|
+
WebMock.disable_net_connect!
|
110
|
+
stub_request(:any, "http://www.example.com/?#{NOT_ESCAPED_PARAMS}")
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should satisfy expectation if request was executed with escaped params" do
|
114
|
+
expect {
|
115
|
+
http_request(:get, "http://www.example.com/?#{ESCAPED_PARAMS}")
|
116
|
+
expect(a_request(:get, "http://www.example.com/?#{NOT_ESCAPED_PARAMS}")).to have_been_made
|
117
|
+
}.not_to raise_error
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should satisfy expectation if request was executed with non escaped params" do
|
121
|
+
expect {
|
122
|
+
http_request(:get, "http://www.example.com/?#{NOT_ESCAPED_PARAMS}")
|
123
|
+
expect(a_request(:get, "http://www.example.com/?#{ESCAPED_PARAMS}")).to have_been_made
|
124
|
+
}.not_to raise_error
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should satisfy expectation if request was executed with escaped params and uri matching regexp was expected" do
|
128
|
+
expect {
|
129
|
+
http_request(:get, "http://www.example.com/?#{ESCAPED_PARAMS}")
|
130
|
+
expect(a_request(:get, /.*example.*/)).to have_been_made
|
131
|
+
}.not_to raise_error
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "when matching requests with query params" do
|
137
|
+
before(:each) do
|
138
|
+
stub_request(:any, /.*example.*/)
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should satisfy expectation if the request was executed with query params declared as a hash in a query option" do
|
142
|
+
expect {
|
143
|
+
http_request(:get, "http://www.example.com/?a[]=b&a[]=c")
|
144
|
+
expect(a_request(:get, "www.example.com").with(query: {"a" => ["b", "c"]})).to have_been_made
|
145
|
+
}.not_to raise_error
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should satisfy expectation if the request was executed with query params declared as string in query option" do
|
149
|
+
expect {
|
150
|
+
http_request(:get, "http://www.example.com/?a[]=b&a[]=c")
|
151
|
+
expect(a_request(:get, "www.example.com").with(query: "a[]=b&a[]=c")).to have_been_made
|
152
|
+
}.not_to raise_error
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should satisfy expectation if the request was executed with query params both in uri and in query option" do
|
156
|
+
expect {
|
157
|
+
http_request(:get, "http://www.example.com/?x=3&a[]=b&a[]=c")
|
158
|
+
expect(a_request(:get, "www.example.com/?x=3").with(query: {"a" => ["b", "c"]})).to have_been_made
|
159
|
+
}.not_to raise_error
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should satisfy expectation if the request was executed with only part query params declared as a hash in a query option" do
|
163
|
+
expect {
|
164
|
+
http_request(:get, "http://www.example.com/?a[]=b&a[]=c&b=1")
|
165
|
+
expect(a_request(:get, "www.example.com").with(query: hash_including({"a" => ["b", "c"]}))).to have_been_made
|
166
|
+
}.not_to raise_error
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
context "when using flat array notation" do
|
171
|
+
before :all do
|
172
|
+
WebMock::Config.instance.query_values_notation = :flat_array
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should satisfy expectation if request includes different repeated query params in flat array notation" do
|
176
|
+
expect {
|
177
|
+
stub_request(:get, "http://www.example.com/?a=1&a=2")
|
178
|
+
http_request(:get, "http://www.example.com/?a=1&a=2")
|
179
|
+
expect(a_request(:get, "http://www.example.com/?a=1&a=2")).to have_been_made
|
180
|
+
}.not_to raise_error
|
181
|
+
end
|
182
|
+
|
183
|
+
after :all do
|
184
|
+
WebMock::Config.instance.query_values_notation = nil
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
describe "at_most_times" do
|
191
|
+
it "fails if request was made more times than maximum" do
|
192
|
+
expect {
|
193
|
+
http_request(:get, "http://www.example.com/")
|
194
|
+
http_request(:get, "http://www.example.com/")
|
195
|
+
http_request(:get, "http://www.example.com/")
|
196
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_times(2)
|
197
|
+
}.to fail_with(%r(The request GET http://www.example.com/ was expected to execute at most 2 times but it executed 3 times))
|
198
|
+
end
|
199
|
+
|
200
|
+
it "passes if request was made the maximum number of times" do
|
201
|
+
expect {
|
202
|
+
http_request(:get, "http://www.example.com/")
|
203
|
+
http_request(:get, "http://www.example.com/")
|
204
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_times(2)
|
205
|
+
}.not_to raise_error
|
206
|
+
end
|
207
|
+
|
208
|
+
it "passes if request was made fewer than the maximum number of times" do
|
209
|
+
expect {
|
210
|
+
http_request(:get, "http://www.example.com/")
|
211
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_times(2)
|
212
|
+
}.not_to raise_error
|
213
|
+
end
|
214
|
+
|
215
|
+
it "passes if request was not made at all" do
|
216
|
+
expect {
|
217
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_times(2)
|
218
|
+
}.not_to raise_error
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
|
223
|
+
describe "at_least_times" do
|
224
|
+
it "fails if request was made fewer times than minimum" do
|
225
|
+
expect {
|
226
|
+
http_request(:get, "http://www.example.com/")
|
227
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_times(2)
|
228
|
+
}.to fail_with(%r(The request GET http://www.example.com/ was expected to execute at least 2 times but it executed 1 time))
|
229
|
+
end
|
230
|
+
|
231
|
+
it "passes if request was made the minimum number of times" do
|
232
|
+
expect {
|
233
|
+
http_request(:get, "http://www.example.com/")
|
234
|
+
http_request(:get, "http://www.example.com/")
|
235
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_times(2)
|
236
|
+
}.not_to raise_error
|
237
|
+
end
|
238
|
+
|
239
|
+
it "passes if request was made more than the minimum number of times" do
|
240
|
+
expect {
|
241
|
+
http_request(:get, "http://www.example.com/")
|
242
|
+
http_request(:get, "http://www.example.com/")
|
243
|
+
http_request(:get, "http://www.example.com/")
|
244
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_times(2)
|
245
|
+
}.not_to raise_error
|
246
|
+
end
|
247
|
+
|
248
|
+
context "descriptive at_most_ matcher" do
|
249
|
+
context "at_most_once" do
|
250
|
+
it "succeeds if no request was executed" do
|
251
|
+
expect {
|
252
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_once
|
253
|
+
}.not_to raise_error
|
254
|
+
end
|
255
|
+
|
256
|
+
it "satisfies expectation if request was executed with the same uri and method once" do
|
257
|
+
expect {
|
258
|
+
http_request(:get, "http://www.example.com/")
|
259
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_once
|
260
|
+
}.not_to raise_error
|
261
|
+
end
|
262
|
+
|
263
|
+
it "fails if request was executed with the same uri and method twice" do
|
264
|
+
expect {
|
265
|
+
http_request(:get, "http://www.example.com/")
|
266
|
+
http_request(:get, "http://www.example.com/")
|
267
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_once
|
268
|
+
}.to fail
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
context "at_most_twice" do
|
273
|
+
it "succeeds if no request was executed" do
|
274
|
+
expect {
|
275
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_twice
|
276
|
+
}.not_to raise_error
|
277
|
+
end
|
278
|
+
|
279
|
+
it "succeeds if too few requests were executed" do
|
280
|
+
expect {
|
281
|
+
http_request(:get, "http://www.example.com/")
|
282
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_twice
|
283
|
+
}.not_to raise_error
|
284
|
+
end
|
285
|
+
|
286
|
+
it "satisfies expectation if request was executed with the same uri and method twice" do
|
287
|
+
expect {
|
288
|
+
http_request(:get, "http://www.example.com/")
|
289
|
+
http_request(:get, "http://www.example.com/")
|
290
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_twice
|
291
|
+
}.not_to raise_error
|
292
|
+
end
|
293
|
+
|
294
|
+
it "fails if request was executed with the same uri and method three times" do
|
295
|
+
expect {
|
296
|
+
http_request(:get, "http://www.example.com/")
|
297
|
+
http_request(:get, "http://www.example.com/")
|
298
|
+
http_request(:get, "http://www.example.com/")
|
299
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_most_twice
|
300
|
+
}.to fail
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
context "descriptive at_least_ matcher" do
|
306
|
+
context "at_least_once" do
|
307
|
+
it "fails if no request was executed" do
|
308
|
+
expect {
|
309
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_once
|
310
|
+
}.to fail
|
311
|
+
end
|
312
|
+
|
313
|
+
it "satisfies expectation if request was executed with the same uri and method once" do
|
314
|
+
expect {
|
315
|
+
http_request(:get, "http://www.example.com/")
|
316
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_once
|
317
|
+
}.not_to raise_error
|
318
|
+
end
|
319
|
+
|
320
|
+
it "satisfies expectation if request was executed with the same uri and method twice" do
|
321
|
+
expect {
|
322
|
+
http_request(:get, "http://www.example.com/")
|
323
|
+
http_request(:get, "http://www.example.com/")
|
324
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_once
|
325
|
+
}.not_to raise_error
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
context "at_least_twice" do
|
330
|
+
it "fails if no request was executed" do
|
331
|
+
expect {
|
332
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_twice
|
333
|
+
}.to fail
|
334
|
+
end
|
335
|
+
|
336
|
+
it "fails if too few requests were executed" do
|
337
|
+
expect {
|
338
|
+
http_request(:get, "http://www.example.com/")
|
339
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_twice
|
340
|
+
}.to fail
|
341
|
+
end
|
342
|
+
|
343
|
+
it "satisfies expectation if request was executed with the same uri and method twice" do
|
344
|
+
expect {
|
345
|
+
http_request(:get, "http://www.example.com/")
|
346
|
+
http_request(:get, "http://www.example.com/")
|
347
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_twice
|
348
|
+
}.not_to raise_error
|
349
|
+
end
|
350
|
+
|
351
|
+
it "satisfies expectation if request was executed with the same uri and method three times" do
|
352
|
+
expect {
|
353
|
+
http_request(:get, "http://www.example.com/")
|
354
|
+
http_request(:get, "http://www.example.com/")
|
355
|
+
http_request(:get, "http://www.example.com/")
|
356
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.at_least_twice
|
357
|
+
}.not_to raise_error
|
358
|
+
end
|
359
|
+
end
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
it "should fail if request was made more times than expected" do
|
364
|
+
expect {
|
365
|
+
http_request(:get, "http://www.example.com/")
|
366
|
+
http_request(:get, "http://www.example.com/")
|
367
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made
|
368
|
+
}.to fail_with(%r(The request GET http://www.example.com/ was expected to execute 1 time but it executed 2 times))
|
369
|
+
end
|
370
|
+
|
371
|
+
it "should fail if request was made less times than expected" do
|
372
|
+
expect {
|
373
|
+
http_request(:get, "http://www.example.com/")
|
374
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.twice
|
375
|
+
}.to fail_with(%r(The request GET http://www.example.com/ was expected to execute 2 times but it executed 1 time))
|
376
|
+
end
|
377
|
+
|
378
|
+
it "should fail if request was made less times than expected when 3 times expected" do
|
379
|
+
expect {
|
380
|
+
http_request(:get, "http://www.example.com/")
|
381
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.times(3)
|
382
|
+
}.to fail_with(%r(The request GET http://www.example.com/ was expected to execute 3 times but it executed 1 time))
|
383
|
+
end
|
384
|
+
|
385
|
+
it "should satisfy expectation if request was executed with the same body" do
|
386
|
+
expect {
|
387
|
+
http_request(:post, "http://www.example.com/", body: "abc")
|
388
|
+
expect(a_request(:post, "www.example.com").with(body: "abc")).to have_been_made
|
389
|
+
}.not_to raise_error
|
390
|
+
end
|
391
|
+
|
392
|
+
it "should fail if request was executed with different body" do
|
393
|
+
expect {
|
394
|
+
http_request(:post, "http://www.example.com/", body: "abc")
|
395
|
+
expect(a_request(:post, "www.example.com").
|
396
|
+
with(body: "def")).to have_been_made
|
397
|
+
}.to fail_with(%r(The request POST http://www.example.com/ with body "def" was expected to execute 1 time but it executed 0 times))
|
398
|
+
end
|
399
|
+
|
400
|
+
describe "when expected request body is declared as a regexp" do
|
401
|
+
it "should satisfy expectation if request was executed with body matching regexp" do
|
402
|
+
expect {
|
403
|
+
http_request(:post, "http://www.example.com/", body: "abc")
|
404
|
+
expect(a_request(:post, "www.example.com").with(body: /^abc$/)).to have_been_made
|
405
|
+
}.not_to raise_error
|
406
|
+
end
|
407
|
+
|
408
|
+
it "should fail if request was executed with body not matching regexp" do
|
409
|
+
expect {
|
410
|
+
http_request(:post, "http://www.example.com/", body: "abc")
|
411
|
+
expect(a_request(:post, "www.example.com").
|
412
|
+
with(body: /^xabc/)).to have_been_made
|
413
|
+
}.to fail_with(%r(The request POST http://www.example.com/ with body /\^xabc/ was expected to execute 1 time but it executed 0 times))
|
414
|
+
end
|
415
|
+
|
416
|
+
end
|
417
|
+
|
418
|
+
describe "when expected reqest body is declared as a hash" do
|
419
|
+
let(:body_hash) { {:a => '1', :b => 'five', 'c' => {'d' => ['e', 'f']}} }
|
420
|
+
let(:fail_message) {%r(The request POST http://www.example.com/ with body .+ was expected to execute 1 time but it executed 0 times)}
|
421
|
+
|
422
|
+
describe "when request is made with url encoded body matching hash" do
|
423
|
+
it "should satisfy expectation" do
|
424
|
+
expect {
|
425
|
+
http_request(:post, "http://www.example.com/", body: 'a=1&c[d][]=e&c[d][]=f&b=five')
|
426
|
+
expect(a_request(:post, "www.example.com").with(body: body_hash)).to have_been_made
|
427
|
+
}.not_to raise_error
|
428
|
+
end
|
429
|
+
|
430
|
+
it "should satisfy expectation even if url encoded params have different order" do
|
431
|
+
expect {
|
432
|
+
http_request(:post, "http://www.example.com/", body: 'a=1&c[d][]=e&b=five&c[d][]=f')
|
433
|
+
expect(a_request(:post, "www.example.com").with(body: body_hash)).to have_been_made
|
434
|
+
}.not_to raise_error
|
435
|
+
end
|
436
|
+
|
437
|
+
it "should fail if request is executed with url encoded body not matching hash" do
|
438
|
+
expect {
|
439
|
+
http_request(:post, "http://www.example.com/", body: 'c[d][]=f&a=1&c[d][]=e')
|
440
|
+
expect(a_request(:post, "www.example.com").with(body: body_hash)).to have_been_made
|
441
|
+
}.to fail_with(fail_message)
|
442
|
+
end
|
443
|
+
end
|
444
|
+
|
445
|
+
describe "when request is executed with json body matching hash and Content-Type is set to json" do
|
446
|
+
it "should satisfy expectation" do
|
447
|
+
expect {
|
448
|
+
http_request(:post, "http://www.example.com/", headers: {'Content-Type' => 'application/json'},
|
449
|
+
body: "{\"a\":\"1\",\"c\":{\"d\":[\"e\",\"f\"]},\"b\":\"five\"}")
|
450
|
+
expect(a_request(:post, "www.example.com").with(body: body_hash)).to have_been_made
|
451
|
+
}.not_to raise_error
|
452
|
+
end
|
453
|
+
|
454
|
+
it "should satisfy expectation even if json body is in different form" do
|
455
|
+
expect {
|
456
|
+
http_request(:post, "http://www.example.com/", headers: {'Content-Type' => 'application/json'},
|
457
|
+
body: "{\"a\":\"1\",\"b\":\"five\",\"c\":{\"d\":[\"e\",\"f\"]}}")
|
458
|
+
expect(a_request(:post, "www.example.com").with(body: body_hash)).to have_been_made
|
459
|
+
}.not_to raise_error
|
460
|
+
end
|
461
|
+
|
462
|
+
it "should satisfy expectation even if json body contains date string" do
|
463
|
+
expect {
|
464
|
+
http_request(:post, "http://www.example.com/", headers: {'Content-Type' => 'application/json'},
|
465
|
+
body: "{\"foo\":\"2010-01-01\"}")
|
466
|
+
expect(a_request(:post, "www.example.com").with(body: {"foo" => "2010-01-01"})).to have_been_made
|
467
|
+
}.not_to raise_error
|
468
|
+
end
|
469
|
+
end
|
470
|
+
|
471
|
+
|
472
|
+
describe "when request is executed with xml body matching hash and content type is set to xml" do
|
473
|
+
let(:body_hash) { { "opt" => {:a => "1", :b => 'five', 'c' => {'d' => ['e', 'f']}} }}
|
474
|
+
|
475
|
+
it "should satisfy expectation" do
|
476
|
+
expect {
|
477
|
+
http_request(:post, "http://www.example.com/", headers: {'Content-Type' => 'application/xml'},
|
478
|
+
body: "<opt a=\"1\" b=\"five\">\n <c>\n <d>e</d>\n <d>f</d>\n </c>\n</opt>\n")
|
479
|
+
expect(a_request(:post, "www.example.com").with(body: body_hash)).to have_been_made
|
480
|
+
}.not_to raise_error
|
481
|
+
end
|
482
|
+
|
483
|
+
it "should satisfy expectation even if xml body is in different form" do
|
484
|
+
expect {
|
485
|
+
http_request(:post, "http://www.example.com/", headers: {'Content-Type' => 'application/xml'},
|
486
|
+
body: "<opt b=\"five\" a=\"1\">\n <c>\n <d>e</d>\n <d>f</d>\n </c>\n</opt>\n")
|
487
|
+
expect(a_request(:post, "www.example.com").with(body: body_hash)).to have_been_made
|
488
|
+
}.not_to raise_error
|
489
|
+
end
|
490
|
+
|
491
|
+
it "should satisfy expectation even if xml body contains date string" do
|
492
|
+
expect {
|
493
|
+
http_request(:post, "http://www.example.com/", headers: {'Content-Type' => 'application/xml'},
|
494
|
+
body: "<opt foo=\"2010-01-01\">\n</opt>\n")
|
495
|
+
expect(a_request(:post, "www.example.com").with(body: {"opt" => {"foo" => "2010-01-01"}})).to have_been_made
|
496
|
+
}.not_to raise_error
|
497
|
+
end
|
498
|
+
end
|
499
|
+
end
|
500
|
+
|
501
|
+
describe "when expected reqest body is declared as a partial hash matcher" do
|
502
|
+
let(:body_hash) { hash_including({:a => '1', 'c' => {'d' => ['e', 'f']}}) }
|
503
|
+
let(:fail_message) {%r(The request POST http://www.example.com/ with body hash_including(.+) was expected to execute 1 time but it executed 0 times)}
|
504
|
+
|
505
|
+
describe "when request is made with url encoded body matching hash" do
|
506
|
+
it "should satisfy expectation" do
|
507
|
+
expect {
|
508
|
+
http_request(:post, "http://www.example.com/", body: 'a=1&c[d][]=e&c[d][]=f&b=five')
|
509
|
+
expect(a_request(:post, "www.example.com").with(body: body_hash)).to have_been_made
|
510
|
+
}.not_to raise_error
|
511
|
+
end
|
512
|
+
|
513
|
+
it "should fail if request is executed with url encoded body not matching hash" do
|
514
|
+
expect {
|
515
|
+
http_request(:post, "http://www.example.com/", body: 'c[d][]=f&a=1&c[d][]=e')
|
516
|
+
expect(a_request(:post, "www.example.com").with(body: body_hash)).to have_been_made
|
517
|
+
}.to fail_with(fail_message)
|
518
|
+
end
|
519
|
+
end
|
520
|
+
end
|
521
|
+
|
522
|
+
describe "when request with headers is expected" do
|
523
|
+
it "should satisfy expectation if request was executed with the same headers" do
|
524
|
+
expect {
|
525
|
+
http_request(:get, "http://www.example.com/", headers: SAMPLE_HEADERS)
|
526
|
+
expect(a_request(:get, "www.example.com").
|
527
|
+
with(headers: SAMPLE_HEADERS)).to have_been_made
|
528
|
+
}.not_to raise_error
|
529
|
+
end
|
530
|
+
|
531
|
+
it "should satisfy expectation if request was executed with the same headers but with header value declared as array" do
|
532
|
+
expect {
|
533
|
+
http_request(:get, "http://www.example.com/", headers: {"a" => "b"})
|
534
|
+
expect(a_request(:get, "www.example.com").
|
535
|
+
with(headers: {"a" => ["b"]})).to have_been_made
|
536
|
+
}.not_to raise_error
|
537
|
+
end
|
538
|
+
|
539
|
+
describe "when multiple headers with the same key are passed" do
|
540
|
+
it "should satisfy expectation" do
|
541
|
+
expect {
|
542
|
+
http_request(:get, "http://www.example.com/", headers: {"a" => ["b", "c"]})
|
543
|
+
expect(a_request(:get, "www.example.com").
|
544
|
+
with(headers: {"a" => ["b", "c"]})).to have_been_made
|
545
|
+
}.not_to raise_error
|
546
|
+
end
|
547
|
+
|
548
|
+
it "should satisfy expectation even if request was executed with the same headers but different order" do
|
549
|
+
expect {
|
550
|
+
http_request(:get, "http://www.example.com/", headers: {"a" => ["b", "c"]})
|
551
|
+
expect(a_request(:get, "www.example.com").
|
552
|
+
with(headers: {"a" => ["c", "b"]})).to have_been_made
|
553
|
+
}.not_to raise_error
|
554
|
+
end
|
555
|
+
|
556
|
+
it "should fail if request was executed with different headers" do
|
557
|
+
expect {
|
558
|
+
http_request(:get, "http://www.example.com/", headers: {"a" => ["b", "c"]})
|
559
|
+
expect(a_request(:get, "www.example.com").
|
560
|
+
with(headers: {"a" => ["b", "d"]})).to have_been_made
|
561
|
+
}.to fail_with(%r(The request GET http://www.example.com/ with headers \{'A'=>\['b', 'd'\]\} was expected to execute 1 time but it executed 0 times))
|
562
|
+
end
|
563
|
+
end
|
564
|
+
|
565
|
+
it "should fail if request was executed with different headers" do
|
566
|
+
expect {
|
567
|
+
http_request(:get, "http://www.example.com/", headers: SAMPLE_HEADERS)
|
568
|
+
expect(a_request(:get, "www.example.com").
|
569
|
+
with(headers: { 'Content-Length' => '9999'})).to have_been_made
|
570
|
+
}.to fail_with(%r(The request GET http://www.example.com/ with headers \{'Content-Length'=>'9999'\} was expected to execute 1 time but it executed 0 times))
|
571
|
+
end
|
572
|
+
|
573
|
+
it "should fail if request was executed with less headers" do
|
574
|
+
expect {
|
575
|
+
http_request(:get, "http://www.example.com/", headers: {'A' => 'a'})
|
576
|
+
expect(a_request(:get, "www.example.com").
|
577
|
+
with(headers: {'A' => 'a', 'B' => 'b'})).to have_been_made
|
578
|
+
}.to fail_with(%r(The request GET http://www.example.com/ with headers \{'A'=>'a', 'B'=>'b'\} was expected to execute 1 time but it executed 0 times))
|
579
|
+
end
|
580
|
+
|
581
|
+
it "should satisfy expectation if request was executed with more headers" do
|
582
|
+
expect {
|
583
|
+
http_request(:get, "http://www.example.com/",
|
584
|
+
headers: {'A' => 'a', 'B' => 'b'}
|
585
|
+
)
|
586
|
+
expect(a_request(:get, "www.example.com").
|
587
|
+
with(headers: {'A' => 'a'})).to have_been_made
|
588
|
+
}.not_to raise_error
|
589
|
+
end
|
590
|
+
|
591
|
+
it "should satisfy expectation if request was executed with body and headers but they were not specified in expectantion" do
|
592
|
+
expect {
|
593
|
+
http_request(:post, "http://www.example.com/",
|
594
|
+
body: "abc",
|
595
|
+
headers: SAMPLE_HEADERS
|
596
|
+
)
|
597
|
+
expect(a_request(:post, "www.example.com")).to have_been_made
|
598
|
+
}.not_to raise_error
|
599
|
+
end
|
600
|
+
|
601
|
+
it "should satisfy expectation if request was executed with headers matching regular expressions" do
|
602
|
+
expect {
|
603
|
+
http_request(:get, "http://www.example.com/", headers: { 'some-header' => 'MyAppName' })
|
604
|
+
expect(a_request(:get, "www.example.com").
|
605
|
+
with(headers: { some_header: /^MyAppName$/ })).to have_been_made
|
606
|
+
}.not_to raise_error
|
607
|
+
end
|
608
|
+
|
609
|
+
it "should fail if request was executed with headers not matching regular expression" do
|
610
|
+
expect {
|
611
|
+
http_request(:get, "http://www.example.com/", headers: { 'some-header' => 'xMyAppName' })
|
612
|
+
expect(a_request(:get, "www.example.com").
|
613
|
+
with(headers: { some_header: /^MyAppName$/ })).to have_been_made
|
614
|
+
}.to fail_with(%r(The request GET http://www.example.com/ with headers \{'Some-Header'=>/\^MyAppName\$/\} was expected to execute 1 time but it executed 0 times))
|
615
|
+
end
|
616
|
+
end
|
617
|
+
|
618
|
+
describe "when expectation contains a request matching block" do
|
619
|
+
it "should satisfy expectation if request was executed and block evaluated to true" do
|
620
|
+
expect {
|
621
|
+
http_request(:post, "http://www.example.com/", body: "wadus")
|
622
|
+
expect(a_request(:post, "www.example.com").with { |req| req.body == "wadus" }).to have_been_made
|
623
|
+
}.not_to raise_error
|
624
|
+
end
|
625
|
+
|
626
|
+
it "should fail if request was executed and block evaluated to false" do
|
627
|
+
expect {
|
628
|
+
http_request(:post, "http://www.example.com/", body: "abc")
|
629
|
+
expect(a_request(:post, "www.example.com").with { |req| req.body == "wadus" }).to have_been_made
|
630
|
+
}.to fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 1 time but it executed 0 times))
|
631
|
+
end
|
632
|
+
|
633
|
+
it "should fail if request was not expected but it executed and block matched request" do
|
634
|
+
expect {
|
635
|
+
http_request(:post, "http://www.example.com/", body: "wadus")
|
636
|
+
expect(a_request(:post, "www.example.com").with { |req| req.body == "wadus" }).not_to have_been_made
|
637
|
+
}.to fail_with(%r(The request POST http://www.example.com/ with given block was not expected to execute but it executed 1 time))
|
638
|
+
end
|
639
|
+
end
|
640
|
+
|
641
|
+
describe "with userinfo", unless: (adapter_info.include?(:no_url_auth)) do
|
642
|
+
before(:each) do
|
643
|
+
stub_request(:any, "http://user:pass@www.example.com")
|
644
|
+
stub_request(:any, "http://user:pazz@www.example.com")
|
645
|
+
end
|
646
|
+
|
647
|
+
it "should satisfy expectation if request was executed with expected credentials" do
|
648
|
+
expect {
|
649
|
+
http_request(:get, "http://user:pass@www.example.com/")
|
650
|
+
expect(a_request(:get, "http://user:pass@www.example.com")).to have_been_made.once
|
651
|
+
}.not_to raise_error
|
652
|
+
end
|
653
|
+
|
654
|
+
it "should fail if request was executed with different credentials than expected" do
|
655
|
+
expect {
|
656
|
+
http_request(:get, "http://user:pass@www.example.com/")
|
657
|
+
expect(a_request(:get, "http://user:pazz@www.example.com")).to have_been_made.once
|
658
|
+
}.to fail_with(%r(The request GET http://user:pazz@www.example.com/ was expected to execute 1 time but it executed 0 times))
|
659
|
+
end
|
660
|
+
|
661
|
+
it "should fail if request was executed without credentials and credentials were expected" do
|
662
|
+
expect {
|
663
|
+
http_request(:get, "http://www.example.com/")
|
664
|
+
expect(a_request(:get, "http://user:pass@www.example.com")).to have_been_made.once
|
665
|
+
}.to fail_with(%r(The request GET http://user:pass@www.example.com/ was expected to execute 1 time but it executed 0 times))
|
666
|
+
end
|
667
|
+
|
668
|
+
it "should fail if request was executed with credentials but expected without credentials" do
|
669
|
+
expect {
|
670
|
+
http_request(:get, "http://user:pass@www.example.com/")
|
671
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.once
|
672
|
+
}.to fail_with(%r(The request GET http://www.example.com/ was expected to execute 1 time but it executed 0 times))
|
673
|
+
end
|
674
|
+
|
675
|
+
it "should fail if request was executed with basic auth header but expected with credentials in userinfo" do
|
676
|
+
expect {
|
677
|
+
http_request(:get, "http://www.example.com/", basic_auth: ['user', 'pass'])
|
678
|
+
expect(a_request(:get, "http://user:pass@www.example.com")).to have_been_made.once
|
679
|
+
}.to fail_with(%r(The request GET http://user:pass@www.example.com/ was expected to execute 1 time but it executed 0 times))
|
680
|
+
end
|
681
|
+
end
|
682
|
+
|
683
|
+
describe "with basic authentication header" do
|
684
|
+
before(:each) do
|
685
|
+
stub_request(:any, "http://www.example.com").with(basic_auth: ['user', 'pass'])
|
686
|
+
stub_request(:any, "http://www.example.com").with(basic_auth: ['user', 'pazz'])
|
687
|
+
end
|
688
|
+
|
689
|
+
it "should satisfy expectation if request was executed with expected credentials" do
|
690
|
+
expect {
|
691
|
+
http_request(:get, "http://www.example.com/", basic_auth: ['user', 'pass'])
|
692
|
+
expect(a_request(:get, "http://www.example.com").with(basic_auth: ['user', 'pass'])).to have_been_made.once
|
693
|
+
}.not_to raise_error
|
694
|
+
end
|
695
|
+
|
696
|
+
it "should satisfy expectation if request was executed with expected credentials passed directly as header" do
|
697
|
+
expect {
|
698
|
+
http_request(:get, "http://www.example.com/", headers: {'Authorization'=>'Basic dXNlcjpwYXNz'})
|
699
|
+
expect(a_request(:get, "http://www.example.com").with(basic_auth: ['user', 'pass'])).to have_been_made.once
|
700
|
+
}.not_to raise_error
|
701
|
+
end
|
702
|
+
|
703
|
+
it "should fail if request was executed with different credentials than expected" do
|
704
|
+
expect {
|
705
|
+
http_request(:get, "http://www.example.com/", basic_auth: ['user', 'pass'])
|
706
|
+
expect(a_request(:get, "http://www.example.com").with(basic_auth: ['user', 'pazz'])).to have_been_made.once
|
707
|
+
}.to fail_with(%r(The request GET http://www.example.com/ with headers {'Authorization'=>'Basic dXNlcjpwYXp6'} was expected to execute 1 time but it executed 0 times))
|
708
|
+
end
|
709
|
+
|
710
|
+
it "should fail if request was executed without credentials and credentials were expected" do
|
711
|
+
expect {
|
712
|
+
http_request(:get, "http://www.example.com/")
|
713
|
+
expect(a_request(:get, "http://www.example.com").with(basic_auth: ['user', 'pass'])).to have_been_made.once
|
714
|
+
}.to fail_with(%r(The request GET http://www.example.com/ with headers {'Authorization'=>'Basic dXNlcjpwYXNz'} was expected to execute 1 time but it executed 0 times))
|
715
|
+
end
|
716
|
+
|
717
|
+
it "should not fail if request was executed with credentials but expected despite credentials" do
|
718
|
+
expect {
|
719
|
+
http_request(:get, "http://www.example.com/", basic_auth: ['user', 'pass'])
|
720
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made.once
|
721
|
+
}.not_to raise_error
|
722
|
+
end
|
723
|
+
|
724
|
+
it "should fail if request was executed with basic auth header and credentials were provided in url", unless: (adapter_info.include?(:no_url_auth)) do
|
725
|
+
expect {
|
726
|
+
stub_request(:any, "http://user:pass@www.example.com")
|
727
|
+
http_request(:get, "http://user:pass@www.example.com/")
|
728
|
+
expect(a_request(:get, "http://www.example.com").with(basic_auth: ['user', 'pass'])).to have_been_made.once
|
729
|
+
}.to fail_with(%r(The request GET http://www.example.com/ with headers {'Authorization'=>'Basic dXNlcjpwYXNz'} was expected to execute 1 time but it executed 0 times))
|
730
|
+
end
|
731
|
+
end
|
732
|
+
|
733
|
+
describe "when expectations were set on WebMock object" do
|
734
|
+
it "should satisfy expectation if expected request was made" do
|
735
|
+
expect {
|
736
|
+
http_request(:get, "http://www.example.com/")
|
737
|
+
expect(WebMock).to have_requested(:get, "http://www.example.com").once
|
738
|
+
}.not_to raise_error
|
739
|
+
end
|
740
|
+
|
741
|
+
it "should satisfy expectation if request with body and headers was expected and request was made" do
|
742
|
+
expect {
|
743
|
+
http_request(:post, "http://www.example.com/", body: "abc", headers: {'A' => 'a'})
|
744
|
+
expect(WebMock).to have_requested(:post, "http://www.example.com").with(body: "abc", headers: {'A' => 'a'}).once
|
745
|
+
}.not_to raise_error
|
746
|
+
end
|
747
|
+
|
748
|
+
it "should fail if request expected not to be made was made" do
|
749
|
+
expect {
|
750
|
+
http_request(:get, "http://www.example.com/")
|
751
|
+
expect(WebMock).not_to have_requested(:get, "http://www.example.com")
|
752
|
+
}.to fail_with(%r(The request GET http://www.example.com/ was not expected to execute but it executed 1 time))
|
753
|
+
end
|
754
|
+
|
755
|
+
it "should satisfy expectation if request was executed and expectation had block which evaluated to true" do
|
756
|
+
expect {
|
757
|
+
http_request(:post, "http://www.example.com/", body: "wadus")
|
758
|
+
expect(WebMock).to have_requested(:post, "www.example.com").with { |req| req.body == "wadus" }
|
759
|
+
}.not_to raise_error
|
760
|
+
end
|
761
|
+
|
762
|
+
it "should fail if request was executed and expectation had block which evaluated to false" do
|
763
|
+
expect {
|
764
|
+
http_request(:post, "http://www.example.com/", body: "abc")
|
765
|
+
expect(WebMock).to have_requested(:post, "www.example.com").with { |req| req.body == "wadus" }
|
766
|
+
}.to fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 1 time but it executed 0 times))
|
767
|
+
end
|
768
|
+
|
769
|
+
it "should fail if request was expected not to be made but was made and block matched request" do
|
770
|
+
expect {
|
771
|
+
http_request(:post, "http://www.example.com/", body: "wadus")
|
772
|
+
expect(WebMock).not_to have_requested(:post, "www.example.com").with { |req| req.body == "wadus" }
|
773
|
+
}.to fail_with(%r(The request POST http://www.example.com/ with given block was not expected to execute but it executed 1 time))
|
774
|
+
end
|
775
|
+
end
|
776
|
+
|
777
|
+
describe "when expectation is declared using assert_requested" do
|
778
|
+
it "should satisfy expectation if requests was made" do
|
779
|
+
expect {
|
780
|
+
http_request(:get, "http://www.example.com/")
|
781
|
+
assert_requested(:get, "http://www.example.com", times: 1)
|
782
|
+
assert_requested(:get, "http://www.example.com")
|
783
|
+
}.not_to raise_error
|
784
|
+
end
|
785
|
+
|
786
|
+
it "should satisfy expectation if request was made with body and headers" do
|
787
|
+
expect {
|
788
|
+
http_request(:post, "http://www.example.com/", body: "abc", headers: {'A' => 'a'})
|
789
|
+
assert_requested(:post, "http://www.example.com", body: "abc", headers: {'A' => 'a'})
|
790
|
+
}.not_to raise_error
|
791
|
+
end
|
792
|
+
|
793
|
+
it "should fail if request expected not to be made was not wade" do
|
794
|
+
expect {
|
795
|
+
http_request(:get, "http://www.example.com/")
|
796
|
+
assert_not_requested(:get, "http://www.example.com")
|
797
|
+
}.to fail_with(%r(The request GET http://www.example.com/ was not expected to execute but it executed 1 time))
|
798
|
+
end
|
799
|
+
|
800
|
+
it "should fail if request expected not to be made was made and expectation block evaluated to true" do
|
801
|
+
expect {
|
802
|
+
http_request(:post, "http://www.example.com/", body: "wadus")
|
803
|
+
assert_not_requested(:post, "www.example.com") { |req| req.body == "wadus" }
|
804
|
+
}.to fail_with(%r(The request POST http://www.example.com/ with given block was not expected to execute but it executed 1 time))
|
805
|
+
end
|
806
|
+
|
807
|
+
it "should satisfy expectation if request was made and expectation block evaluated to true" do
|
808
|
+
expect {
|
809
|
+
http_request(:post, "http://www.example.com/", body: "wadus")
|
810
|
+
assert_requested(:post, "www.example.com") { |req| req.body == "wadus" }
|
811
|
+
}.not_to raise_error
|
812
|
+
end
|
813
|
+
|
814
|
+
it "should fail if request was made and expectation block evaluated to false" do
|
815
|
+
expect {
|
816
|
+
http_request(:post, "http://www.example.com/", body: "abc")
|
817
|
+
assert_requested(:post, "www.example.com") { |req| req.body == "wadus" }
|
818
|
+
}.to fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 1 time but it executed 0 times))
|
819
|
+
end
|
820
|
+
end
|
821
|
+
|
822
|
+
describe "when expectation is declared using assert_requested" do
|
823
|
+
it "should satisfy expectation if requests was made" do
|
824
|
+
stub_http = stub_http_request(:get, "http://www.example.com")
|
825
|
+
expect {
|
826
|
+
http_request(:get, "http://www.example.com/")
|
827
|
+
assert_requested(stub_http, times: 1)
|
828
|
+
assert_requested(stub_http)
|
829
|
+
}.not_to raise_error
|
830
|
+
end
|
831
|
+
|
832
|
+
it "should fail if request expected not to be made was not wade" do
|
833
|
+
stub_http = stub_http_request(:get, "http://www.example.com")
|
834
|
+
expect {
|
835
|
+
http_request(:get, "http://www.example.com/")
|
836
|
+
assert_not_requested(stub_http)
|
837
|
+
}.to fail_with(%r(The request GET http://www.example.com/ was not expected to execute but it executed 1 time))
|
838
|
+
end
|
839
|
+
end
|
840
|
+
end
|
841
|
+
|
842
|
+
|
843
|
+
describe "expectation is set on the request stub" do
|
844
|
+
it "should satisfy expectation if expected request was made" do
|
845
|
+
stub = stub_request(:get, "http://www.example.com/")
|
846
|
+
http_request(:get, "http://www.example.com/")
|
847
|
+
expect(stub).to have_been_requested.once
|
848
|
+
end
|
849
|
+
|
850
|
+
it "should satisfy expectations if subsequent requests were made" do
|
851
|
+
stub = stub_request(:get, "http://www.example.com/")
|
852
|
+
http_request(:get, "http://www.example.com/")
|
853
|
+
expect(stub).to have_been_requested.once
|
854
|
+
http_request(:get, "http://www.example.com/")
|
855
|
+
expect(stub).to have_been_requested.twice
|
856
|
+
end
|
857
|
+
|
858
|
+
it "should satisfy expectation if expected request with body and headers was made" do
|
859
|
+
stub = stub_request(:post, "http://www.example.com").with(body: "abc", headers: {'A' => 'a'})
|
860
|
+
http_request(:post, "http://www.example.com/", body: "abc", headers: {'A' => 'a'})
|
861
|
+
expect(stub).to have_been_requested.once
|
862
|
+
end
|
863
|
+
|
864
|
+
it "should fail if request not expected to be made was made" do
|
865
|
+
expect {
|
866
|
+
stub = stub_request(:get, "http://www.example.com")
|
867
|
+
http_request(:get, "http://www.example.com/")
|
868
|
+
expect(stub).not_to have_been_requested
|
869
|
+
}.to fail_with(%r(The request GET http://www.example.com/ was not expected to execute but it executed 1 time))
|
870
|
+
end
|
871
|
+
|
872
|
+
it "should fail request not expected to be made was made and expectation block evaluated to true" do
|
873
|
+
expect {
|
874
|
+
stub = stub_request(:post, "www.example.com").with { |req| req.body == "wadus" }
|
875
|
+
http_request(:post, "http://www.example.com/", body: "wadus")
|
876
|
+
expect(stub).not_to have_been_requested
|
877
|
+
}.to fail_with(%r(The request POST http://www.example.com/ with given block was not expected to execute but it executed 1 time))
|
878
|
+
end
|
879
|
+
|
880
|
+
it "should satisfy expectation if request was made and expectation block evaluated to true" do
|
881
|
+
stub = stub_request(:post, "www.example.com").with { |req| req.body == "wadus" }
|
882
|
+
http_request(:post, "http://www.example.com/", body: "wadus")
|
883
|
+
expect(stub).to have_been_requested
|
884
|
+
end
|
885
|
+
|
886
|
+
it "should satisfy expectation if request was made and expectation block evaluated to false" do
|
887
|
+
expect {
|
888
|
+
stub_request(:any, /.+/) #stub any request
|
889
|
+
stub = stub_request(:post, "www.example.com").with { |req| req.body == "wadus" }
|
890
|
+
http_request(:post, "http://www.example.com/", body: "abc")
|
891
|
+
expect(stub).to have_been_requested
|
892
|
+
}.to fail_with(%r(The request POST http://www.example.com/ with given block was expected to execute 1 time but it executed 0 times))
|
893
|
+
end
|
894
|
+
end
|
895
|
+
|
896
|
+
describe "when net connect is allowed", net_connect: true do
|
897
|
+
before(:each) do
|
898
|
+
WebMock.allow_net_connect!
|
899
|
+
end
|
900
|
+
|
901
|
+
it "should satisfy expectation if expected requests was made" do
|
902
|
+
expect {
|
903
|
+
http_request(:get, "http://www.example.com/")
|
904
|
+
expect(a_request(:get, "http://www.example.com")).to have_been_made
|
905
|
+
}.not_to raise_error
|
906
|
+
end
|
907
|
+
|
908
|
+
it "should fail request expected not to be made, was made" do
|
909
|
+
expect {
|
910
|
+
http_request(:get, "http://www.example.com/")
|
911
|
+
expect(a_request(:get, "http://www.example.com")).not_to have_been_made
|
912
|
+
}.to fail_with(%r(The request GET http://www.example.com/ was not expected to execute but it executed 1 time))
|
913
|
+
end
|
914
|
+
end
|
915
|
+
end
|
916
|
+
end
|