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,388 @@
|
|
1
|
+
class MyException < StandardError; end;
|
2
|
+
|
3
|
+
class Responder
|
4
|
+
def call(request)
|
5
|
+
{body: request.body}
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
shared_context "declared responses" do |*adapter_info|
|
10
|
+
describe "when request stub declares that request should raise exception" do
|
11
|
+
it "should raise exception" do
|
12
|
+
stub_request(:get, "www.example.com").to_raise(MyException)
|
13
|
+
expect {
|
14
|
+
http_request(:get, "http://www.example.com/")
|
15
|
+
}.to raise_error(MyException, "Exception from WebMock")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should raise exception if declared as and exception instance" do
|
19
|
+
stub_request(:get, "www.example.com").to_raise(MyException.new("hello world"))
|
20
|
+
expect {
|
21
|
+
http_request(:get, "http://www.example.com/")
|
22
|
+
}.to raise_error(MyException, "hello world")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should raise exception if declared as an exception instance" do
|
26
|
+
stub_request(:get, "www.example.com").to_raise("hello world")
|
27
|
+
expect {
|
28
|
+
http_request(:get, "http://www.example.com/")
|
29
|
+
}.to raise_error("hello world")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should raise exception after returning declared successful response first" do
|
33
|
+
stub_request(:get, "www.example.com").to_return(body: "abc").then.to_raise(MyException)
|
34
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("abc")
|
35
|
+
expect {
|
36
|
+
http_request(:get, "http://www.example.com/")
|
37
|
+
}.to raise_error(MyException, "Exception from WebMock")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "when request stub declares that request should timeout" do
|
42
|
+
it "should timeout" do
|
43
|
+
stub_request(:get, "www.example.com").to_timeout
|
44
|
+
expect {
|
45
|
+
http_request(:get, "http://www.example.com/")
|
46
|
+
}.to raise_error(client_timeout_exception_class)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should timeout after returning declared successful response" do
|
50
|
+
stub_request(:get, "www.example.com").to_return(body: "abc").then.to_timeout
|
51
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("abc")
|
52
|
+
expect {
|
53
|
+
http_request(:get, "http://www.example.com/")
|
54
|
+
}.to raise_error(client_timeout_exception_class)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "when request stub declares that request should return a response" do
|
59
|
+
it "should return response with declared body" do
|
60
|
+
stub_request(:get, "www.example.com").to_return(body: "abc")
|
61
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("abc")
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should return response with declared headers" do
|
65
|
+
stub_request(:get, "www.example.com").to_return(headers: SAMPLE_HEADERS)
|
66
|
+
response = http_request(:get, "http://www.example.com/")
|
67
|
+
expect(response.headers["Content-Length"]).to eq("8888")
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should return response with declared headers even if there are multiple headers with the same key" do
|
71
|
+
stub_request(:get, "www.example.com").to_return(headers: {"a" => ["b", "c"]})
|
72
|
+
response = http_request(:get, "http://www.example.com/")
|
73
|
+
expect(response.headers["A"]).to eq("b, c")
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should return response with declared status code" do
|
77
|
+
stub_request(:get, "www.example.com").to_return(status: 500)
|
78
|
+
expect(http_request(:get, "http://www.example.com/").status).to eq("500")
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should return response with declared status message", unless: (adapter_info.include?(:no_status_message)) do
|
82
|
+
stub_request(:get, "www.example.com").to_return(status: [500, "Internal Server Error"])
|
83
|
+
response = http_request(:get, "http://www.example.com/")
|
84
|
+
expect(response.message).to eq("Internal Server Error")
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should return response with a default status code" do
|
88
|
+
stub_request(:get, "www.example.com")
|
89
|
+
expect(http_request(:get, "http://www.example.com/").status).to eq("200")
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should return default response with empty message if response was not declared", unless: (adapter_info.include?(:no_status_message)) do
|
93
|
+
stub_request(:get, "www.example.com")
|
94
|
+
response = http_request(:get, "http://www.example.com/")
|
95
|
+
expect(response.message).to eq("")
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "when response body was declared as IO" do
|
99
|
+
it "should return response body" do
|
100
|
+
stub_request(:get, "www.example.com").to_return(body: File.new(__FILE__))
|
101
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq(File.read(__FILE__))
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should return response body if requested many times" do
|
105
|
+
stub_request(:get, "www.example.com").to_return(body: File.new(__FILE__))
|
106
|
+
2.times do
|
107
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq(File.read(__FILE__))
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should close IO after request" do
|
112
|
+
stub_request(:get, "www.example.com").to_return(body: @file = File.new(__FILE__))
|
113
|
+
expect(@file).to be_closed
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "when response parts were declared as lambdas" do
|
118
|
+
it "should return evaluated response body" do
|
119
|
+
stub_request(:post, "www.example.com").to_return(body: lambda { |request| request.body })
|
120
|
+
expect(http_request(:post, "http://www.example.com/", body: "echo").body).to eq("echo")
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should return evaluated response headers" do
|
124
|
+
stub_request(:post, "www.example.com").to_return(headers: lambda { |request| request.headers })
|
125
|
+
expect(http_request(:post, "http://www.example.com/", body: "abc", headers: {'A' => 'B'}).headers['A']).to eq('B')
|
126
|
+
expect(http_request(:post, "http://www.example.com/", body: "abc", headers: {'A' => 'C'}).headers['A']).to eq('C')
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should evaluate response body for each request" do
|
130
|
+
stub_request(:post, "www.example.com").to_return(body: lambda { |request| request.body })
|
131
|
+
expect(http_request(:post, "http://www.example.com/", body: "echo").body).to eq("echo")
|
132
|
+
expect(http_request(:post, "http://www.example.com/", body: "foxtrot").body).to eq("foxtrot")
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "when response was declared as lambda" do
|
137
|
+
it "should return evaluated response body" do
|
138
|
+
stub_request(:post, "www.example.com").to_return(lambda {|request|
|
139
|
+
{body: request.body}
|
140
|
+
})
|
141
|
+
expect(http_request(:post, "http://www.example.com/", body: "echo").body).to eq("echo")
|
142
|
+
expect(http_request(:post, "http://www.example.com/", body: "foxtrot").body).to eq("foxtrot")
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should return evaluated response headers" do
|
146
|
+
stub_request(:get, "www.example.com").to_return(lambda { |request|
|
147
|
+
{headers: request.headers}
|
148
|
+
})
|
149
|
+
expect(http_request(:get, "http://www.example.com/", headers: {'A' => 'B'}).headers['A']).to eq('B')
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should return dynamic response declared as a block" do
|
153
|
+
stub_request(:post, "www.example.com").to_return do |request|
|
154
|
+
{body: request.body}
|
155
|
+
end
|
156
|
+
expect(http_request(:post, "http://www.example.com/", body: "echo").body).to eq("echo")
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should return dynamic response declared as an object responding to call" do
|
160
|
+
stub_request(:post, "www.example.com").to_return(Responder.new)
|
161
|
+
expect(http_request(:post, "http://www.example.com/", body: "echo").body).to eq("echo")
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
describe "when response was declared as a file with a raw response" do
|
167
|
+
before(:each) do
|
168
|
+
@file = File.new(CURL_EXAMPLE_OUTPUT_PATH)
|
169
|
+
stub_request(:get, "www.example.com").to_return(@file)
|
170
|
+
@response = http_request(:get, "http://www.example.com/")
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should return recorded headers" do
|
174
|
+
expect(@response.headers).to eq({
|
175
|
+
"Date"=>"Sat, 23 Jan 2010 01:01:05 GMT",
|
176
|
+
"Content-Type"=>"text/html; charset=UTF-8",
|
177
|
+
"Content-Length"=>"419",
|
178
|
+
"Connection"=>"Keep-Alive",
|
179
|
+
"Accept"=>"image/jpeg, image/png"
|
180
|
+
})
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should return recorded body" do
|
184
|
+
expect(@response.body.size).to eq(419)
|
185
|
+
end
|
186
|
+
|
187
|
+
it "should return recorded status" do
|
188
|
+
expect(@response.status).to eq("202")
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should return recorded status message", unless: (adapter_info.include?(:no_status_message)) do
|
192
|
+
expect(@response.message).to eq("OK")
|
193
|
+
end
|
194
|
+
|
195
|
+
it "should ensure file is closed" do
|
196
|
+
expect(@file).to be_closed
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
describe "when response was declared as a string with a raw response" do
|
201
|
+
before(:each) do
|
202
|
+
@input = File.read(CURL_EXAMPLE_OUTPUT_PATH)
|
203
|
+
stub_request(:get, "www.example.com").to_return(@input)
|
204
|
+
@response = http_request(:get, "http://www.example.com/")
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should return recorded headers" do
|
208
|
+
expect(@response.headers).to eq({
|
209
|
+
"Date"=>"Sat, 23 Jan 2010 01:01:05 GMT",
|
210
|
+
"Content-Type"=>"text/html; charset=UTF-8",
|
211
|
+
"Content-Length"=>"419",
|
212
|
+
"Connection"=>"Keep-Alive",
|
213
|
+
"Accept"=>"image/jpeg, image/png"
|
214
|
+
})
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should return recorded body" do
|
218
|
+
expect(@response.body.size).to eq(419)
|
219
|
+
end
|
220
|
+
|
221
|
+
it "should return recorded status" do
|
222
|
+
expect(@response.status).to eq("202")
|
223
|
+
end
|
224
|
+
|
225
|
+
it "should return recorded status message", unless: (adapter_info.include?(:no_status_message)) do
|
226
|
+
expect(@response.message).to eq("OK")
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
describe "when response was declared as lambda evaluating to a string with a raw response" do
|
231
|
+
before(:each) do
|
232
|
+
@files = {
|
233
|
+
"www.example.com" => File.new(CURL_EXAMPLE_OUTPUT_PATH)
|
234
|
+
}
|
235
|
+
end
|
236
|
+
|
237
|
+
it "should return response from evaluated file" do
|
238
|
+
stub_request(:get, "www.example.com").to_return(lambda {|request| @files[request.uri.host.to_s] })
|
239
|
+
expect(http_request(:get, "http://www.example.com/").body.size).to eq(419)
|
240
|
+
end
|
241
|
+
|
242
|
+
it "should return response from evaluated string" do
|
243
|
+
stub_request(:get, "www.example.com").to_return(lambda {|request| @files[request.uri.host.to_s].read })
|
244
|
+
expect(http_request(:get, "http://www.example.com/").body.size).to eq(419)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
describe "when response is declared as an Rack app" do
|
249
|
+
it "should return response returned by the rack app" do
|
250
|
+
stub_request(:any, "http://www.example.com/greet").to_rack(MyRackApp)
|
251
|
+
expect(http_request(:post, 'http://www.example.com/greet', body: 'name=Jimmy').body).to eq('Good to meet you, Jimmy!')
|
252
|
+
end
|
253
|
+
|
254
|
+
it "should pass along the port number to the rack app" do
|
255
|
+
stub_request(:get, "http://www.example.com/compute").to_rack(MyRackApp)
|
256
|
+
expect(http_request(:get, "http://www.example.com/compute").status).to eq("200")
|
257
|
+
end
|
258
|
+
|
259
|
+
it "preserves content-type header when proxying to a rack app" do
|
260
|
+
stub_request(:any, //).to_rack(lambda {|req| [200, {}, ["OK"]] })
|
261
|
+
|
262
|
+
url = "https://google.com/hi/there"
|
263
|
+
headers = {
|
264
|
+
"Accept" => "application/json",
|
265
|
+
"Content-Type" => "application/json"
|
266
|
+
}
|
267
|
+
|
268
|
+
http_request(:get, url, headers: headers)
|
269
|
+
expect(WebMock).to have_requested(:get, url).with(headers: headers)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
describe "when sequences of responses are declared" do
|
274
|
+
it "should return responses one by one if declared in array" do
|
275
|
+
stub_request(:get, "www.example.com").to_return([ {body: "1"}, {body: "2"}, {body: "3"} ])
|
276
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
277
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("2")
|
278
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("3")
|
279
|
+
end
|
280
|
+
|
281
|
+
it "should repeat returning last declared response from a sequence after all responses were returned" do
|
282
|
+
stub_request(:get, "www.example.com").to_return([ {body: "1"}, {body: "2"} ])
|
283
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
284
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("2")
|
285
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("2")
|
286
|
+
end
|
287
|
+
|
288
|
+
it "should return responses one by one if declared as comma separated params" do
|
289
|
+
stub_request(:get, "www.example.com").to_return({body: "1"}, {body: "2"}, {body: "3"})
|
290
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
291
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("2")
|
292
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("3")
|
293
|
+
end
|
294
|
+
|
295
|
+
it "should return responses one by one if declared with several to_return invokations" do
|
296
|
+
stub_request(:get, "www.example.com").
|
297
|
+
to_return({body: "1"}).
|
298
|
+
to_return({body: "2"}).
|
299
|
+
to_return({body: "3"})
|
300
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
301
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("2")
|
302
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("3")
|
303
|
+
end
|
304
|
+
|
305
|
+
it "should return responses one by one if declared with to_return invocations separated with then syntactic sugar" do
|
306
|
+
stub_request(:get, "www.example.com").to_return({body: "1"}).then.
|
307
|
+
to_return({body: "2"}).then.to_return({body: "3"})
|
308
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
309
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("2")
|
310
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("3")
|
311
|
+
end
|
312
|
+
|
313
|
+
end
|
314
|
+
|
315
|
+
describe "when responses are declared to return more than once" do
|
316
|
+
it "should repeat one response declared number of times" do
|
317
|
+
stub_request(:get, "www.example.com").
|
318
|
+
to_return({body: "1"}).times(2).
|
319
|
+
to_return({body: "2"})
|
320
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
321
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
322
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("2")
|
323
|
+
end
|
324
|
+
|
325
|
+
|
326
|
+
it "should repeat sequence of response declared number of times" do
|
327
|
+
stub_request(:get, "www.example.com").
|
328
|
+
to_return({body: "1"}, {body: "2"}).times(2).
|
329
|
+
to_return({body: "3"})
|
330
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
331
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("2")
|
332
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
333
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("2")
|
334
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("3")
|
335
|
+
end
|
336
|
+
|
337
|
+
|
338
|
+
it "should repeat infinitely last response even if number of declared times is lower" do
|
339
|
+
stub_request(:get, "www.example.com").
|
340
|
+
to_return({body: "1"}).times(2)
|
341
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
342
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
343
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("1")
|
344
|
+
end
|
345
|
+
|
346
|
+
it "should give error if times is declared without specifying response" do
|
347
|
+
expect {
|
348
|
+
stub_request(:get, "www.example.com").times(3)
|
349
|
+
}.to raise_error("Invalid WebMock stub declaration. times(N) can be declared only after response declaration.")
|
350
|
+
end
|
351
|
+
|
352
|
+
end
|
353
|
+
|
354
|
+
describe "when exception is declared to be raised more than once" do
|
355
|
+
it "should repeat raising exception declared number of times" do
|
356
|
+
stub_request(:get, "www.example.com").
|
357
|
+
to_raise(MyException).times(2).
|
358
|
+
to_return({body: "2"})
|
359
|
+
expect {
|
360
|
+
http_request(:get, "http://www.example.com/")
|
361
|
+
}.to raise_error(MyException, "Exception from WebMock")
|
362
|
+
expect {
|
363
|
+
http_request(:get, "http://www.example.com/")
|
364
|
+
}.to raise_error(MyException, "Exception from WebMock")
|
365
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("2")
|
366
|
+
end
|
367
|
+
|
368
|
+
it "should repeat raising sequence of exceptions declared number of times" do
|
369
|
+
stub_request(:get, "www.example.com").
|
370
|
+
to_raise(MyException, ArgumentError).times(2).
|
371
|
+
to_return({body: "2"})
|
372
|
+
expect {
|
373
|
+
http_request(:get, "http://www.example.com/")
|
374
|
+
}.to raise_error(MyException, "Exception from WebMock")
|
375
|
+
expect {
|
376
|
+
http_request(:get, "http://www.example.com/")
|
377
|
+
}.to raise_error(ArgumentError)
|
378
|
+
expect {
|
379
|
+
http_request(:get, "http://www.example.com/")
|
380
|
+
}.to raise_error(MyException, "Exception from WebMock")
|
381
|
+
expect {
|
382
|
+
http_request(:get, "http://www.example.com/")
|
383
|
+
}.to raise_error(ArgumentError)
|
384
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("2")
|
385
|
+
end
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
@@ -0,0 +1,583 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
shared_examples_for "stubbing requests" do |*adapter_info|
|
4
|
+
describe "when requests are stubbed" do
|
5
|
+
describe "based on uri" do
|
6
|
+
it "should return stubbed response even if request have escaped parameters" do
|
7
|
+
stub_request(:get, "www.example.com/hello+/?#{NOT_ESCAPED_PARAMS}").to_return(body: "abc")
|
8
|
+
expect(http_request(:get, "http://www.example.com/hello%2B/?#{ESCAPED_PARAMS}").body).to eq("abc")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should return stubbed response even if query params have integer values" do
|
12
|
+
stub_request(:get, "www.example.com").with(query: {"a" => 1}).to_return(body: "abc")
|
13
|
+
expect(http_request(:get, "http://www.example.com/?a=1").body).to eq("abc")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return stubbed response even if request has non escaped params" do
|
17
|
+
stub_request(:get, "www.example.com/hello%2B/?#{ESCAPED_PARAMS}").to_return(body: "abc")
|
18
|
+
expect(http_request(:get, "http://www.example.com/hello+/?#{NOT_ESCAPED_PARAMS}").body).to eq("abc")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return stubbed response for url with non utf query params", "ruby>1.9" => true do
|
22
|
+
param = 'aäoöuü'.encode('iso-8859-1')
|
23
|
+
param = CGI.escape(param)
|
24
|
+
stub_request(:get, "www.example.com/?#{param}").to_return(body: "abc")
|
25
|
+
expect(http_request(:get, "http://www.example.com/?#{param}").body).to eq("abc")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should return stubbed response even if stub uri is declared as regexp and request params are escaped" do
|
29
|
+
stub_request(:get, /.*x=ab c.*/).to_return(body: "abc")
|
30
|
+
expect(http_request(:get, "http://www.example.com/hello/?#{ESCAPED_PARAMS}").body).to eq("abc")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should raise error specifying stubbing instructions with escaped characters in params if there is no matching stub" do
|
34
|
+
begin
|
35
|
+
http_request(:get, "http://www.example.com/hello+/?#{NOT_ESCAPED_PARAMS}")
|
36
|
+
rescue WebMock::NetConnectNotAllowedError => e
|
37
|
+
expect(e.message).to match(/Unregistered request: GET http:\/\/www\.example\.com\/hello\+\/\?x=ab%20c&z='Stop!'%20said%20Fred%20m/m)
|
38
|
+
expect(e.message).to match(/stub_request\(:get, "http:\/\/www\.example\.com\/hello\+\/\?x=ab%20c&z='Stop!'%20said%20Fred%20m"\)/m)
|
39
|
+
end
|
40
|
+
|
41
|
+
stub_request(:get, "http://www.example.com/hello+/?x=ab%20c&z='Stop!'%20said%20Fred%20m")
|
42
|
+
http_request(:get, "http://www.example.com/hello+/?#{NOT_ESCAPED_PARAMS}")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "based on query params" do
|
47
|
+
it "should return stubbed response when stub declares query params as a hash" do
|
48
|
+
stub_request(:get, "www.example.com").with(query: {"a" => ["b x", "c d"]}).to_return(body: "abc")
|
49
|
+
expect(http_request(:get, "http://www.example.com/?a[]=b+x&a[]=c%20d").body).to eq("abc")
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should return stubbed response when stub declares query params as a hash" do
|
53
|
+
stub_request(:get, "www.example.com").with(query: "a[]=b&a[]=c").to_return(body: "abc")
|
54
|
+
expect(http_request(:get, "http://www.example.com/?a[]=b&a[]=c").body).to eq("abc")
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should return stubbed response when stub declares query params both in uri and as a hash" do
|
58
|
+
stub_request(:get, "www.example.com/?x=3").with(query: {"a" => ["b", "c"]}).to_return(body: "abc")
|
59
|
+
expect(http_request(:get, "http://www.example.com/?x=3&a[]=b&a[]=c").body).to eq("abc")
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should return stubbed response when stub expects only part of query params" do
|
63
|
+
stub_request(:get, "www.example.com").with(query: hash_including({"a" => ["b", "c"]})).to_return(body: "abc")
|
64
|
+
expect(http_request(:get, "http://www.example.com/?a[]=b&a[]=c&b=1").body).to eq("abc")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "based on method" do
|
69
|
+
it "should return stubbed response" do
|
70
|
+
stub_request(:get, "www.example.com")
|
71
|
+
expect(http_request(:get, "http://www.example.com/").status).to eq("200")
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should match stubbed request when http request was made with method given as string" do
|
75
|
+
stub_request(:get, "www.example.com")
|
76
|
+
expect(http_request('get', "http://www.example.com/").status).to eq("200")
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should raise error if stubbed request has different method" do
|
80
|
+
stub_request(:get, "www.example.com")
|
81
|
+
expect(http_request(:get, "http://www.example.com/").status).to eq("200")
|
82
|
+
expect {
|
83
|
+
http_request(:delete, "http://www.example.com/")
|
84
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: DELETE http://www.example.com/)
|
85
|
+
)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "based on body" do
|
90
|
+
it "should match requests if body is the same" do
|
91
|
+
stub_request(:post, "www.example.com").with(body: "abc")
|
92
|
+
expect(http_request(
|
93
|
+
:post, "http://www.example.com/",
|
94
|
+
body: "abc").status).to eq("200")
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should match requests if body is not set in the stub" do
|
98
|
+
stub_request(:post, "www.example.com")
|
99
|
+
expect(http_request(
|
100
|
+
:post, "http://www.example.com/",
|
101
|
+
body: "abc").status).to eq("200")
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should not match requests if body is different" do
|
105
|
+
stub_request(:post, "www.example.com").with(body: "abc")
|
106
|
+
expect {
|
107
|
+
http_request(:post, "http://www.example.com/", body: "def")
|
108
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: POST http://www.example.com/ with body 'def'))
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "with regular expressions" do
|
112
|
+
it "should match requests if body matches regexp" do
|
113
|
+
stub_request(:post, "www.example.com").with(body: /\d+abc$/)
|
114
|
+
expect(http_request(
|
115
|
+
:post, "http://www.example.com/",
|
116
|
+
body: "123abc").status).to eq("200")
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should not match requests if body doesn't match regexp" do
|
120
|
+
stub_request(:post, "www.example.com").with(body: /^abc/)
|
121
|
+
expect {
|
122
|
+
http_request(:post, "http://www.example.com/", body: "xabc")
|
123
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: POST http://www.example.com/ with body 'xabc'))
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe "when body is declared as a hash" do
|
128
|
+
before(:each) do
|
129
|
+
stub_request(:post, "www.example.com").
|
130
|
+
with(body: {:a => '1', :b => 'five x', 'c' => {'d' => ['e', 'f']} })
|
131
|
+
end
|
132
|
+
|
133
|
+
describe "for request with url encoded body" do
|
134
|
+
it "should match request if hash matches body" do
|
135
|
+
expect(http_request(
|
136
|
+
:post, "http://www.example.com/",
|
137
|
+
body: 'a=1&c[d][]=e&c[d][]=f&b=five+x').status).to eq("200")
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should match request if hash matches body in different order of params" do
|
141
|
+
expect(http_request(
|
142
|
+
:post, "http://www.example.com/",
|
143
|
+
body: 'a=1&c[d][]=e&b=five+x&c[d][]=f').status).to eq("200")
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should not match if hash doesn't match url encoded body" do
|
147
|
+
expect {
|
148
|
+
http_request(
|
149
|
+
:post, "http://www.example.com/",
|
150
|
+
body: 'c[d][]=f&a=1&c[d][]=e')
|
151
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: POST http://www.example.com/ with body 'c\[d\]\[\]=f&a=1&c\[d\]\[\]=e'))
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
describe "for request with json body and content type is set to json" do
|
157
|
+
it "should match if hash matches body" do
|
158
|
+
expect(http_request(
|
159
|
+
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/json'},
|
160
|
+
body: "{\"a\":\"1\",\"c\":{\"d\":[\"e\",\"f\"]},\"b\":\"five x\"}").status).to eq("200")
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should match if hash matches body in different form" do
|
164
|
+
expect(http_request(
|
165
|
+
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/json'},
|
166
|
+
body: "{\"a\":\"1\",\"b\":\"five x\",\"c\":{\"d\":[\"e\",\"f\"]}}").status).to eq("200")
|
167
|
+
end
|
168
|
+
|
169
|
+
it "should match if hash contains date string" do #Crack creates date object
|
170
|
+
WebMock.reset!
|
171
|
+
stub_request(:post, "www.example.com").
|
172
|
+
with(body: {"foo" => "2010-01-01"})
|
173
|
+
expect(http_request(
|
174
|
+
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/json'},
|
175
|
+
body: "{\"foo\":\"2010-01-01\"}").status).to eq("200")
|
176
|
+
end
|
177
|
+
|
178
|
+
it "should match if any of the strings have spaces" do
|
179
|
+
WebMock.reset!
|
180
|
+
stub_request(:post, "www.example.com").with(body: {"foo" => "a b c"})
|
181
|
+
expect(http_request(
|
182
|
+
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/json'},
|
183
|
+
body: "{\"foo\":\"a b c\"}").status).to eq("200")
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
describe "for request with xml body and content type is set to xml" do
|
188
|
+
before(:each) do
|
189
|
+
WebMock.reset!
|
190
|
+
stub_request(:post, "www.example.com").
|
191
|
+
with(body: { "opt" => {:a => '1', :b => 'five', 'c' => {'d' => ['e', 'f']} }})
|
192
|
+
end
|
193
|
+
|
194
|
+
it "should match if hash matches body" do
|
195
|
+
expect(http_request(
|
196
|
+
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/xml'},
|
197
|
+
body: "<opt a=\"1\" b=\"five\">\n <c>\n <d>e</d>\n <d>f</d>\n </c>\n</opt>\n").status).to eq("200")
|
198
|
+
end
|
199
|
+
|
200
|
+
it "should match if hash matches body in different form" do
|
201
|
+
expect(http_request(
|
202
|
+
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/xml'},
|
203
|
+
body: "<opt b=\"five\" a=\"1\">\n <c>\n <d>e</d>\n <d>f</d>\n </c>\n</opt>\n").status).to eq("200")
|
204
|
+
end
|
205
|
+
|
206
|
+
it "should match if hash contains date string" do #Crack creates date object
|
207
|
+
WebMock.reset!
|
208
|
+
stub_request(:post, "www.example.com").
|
209
|
+
with(body: {"opt" => {"foo" => "2010-01-01"}})
|
210
|
+
expect(http_request(
|
211
|
+
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/xml'},
|
212
|
+
body: "<opt foo=\"2010-01-01\">\n</opt>\n").status).to eq("200")
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
describe "when body is declared as partial hash matcher" do
|
218
|
+
subject(:request) { http_request( :post, "http://www.example.com/",
|
219
|
+
body: 'a=1&c[d][]=e&c[d][]=f&b=five') }
|
220
|
+
|
221
|
+
subject(:wrong_request) { http_request(:post, "http://www.example.com/",
|
222
|
+
body: 'c[d][]=f&a=1&c[d][]=e').status }
|
223
|
+
|
224
|
+
describe "when using 'RSpec:Mocks::ArgumentMatchers#hash_including'" do
|
225
|
+
before(:each) do
|
226
|
+
stub_request(:post, "www.example.com").
|
227
|
+
with(body: hash_including(:a, c: {'d' => ['e', 'f']} ))
|
228
|
+
end
|
229
|
+
|
230
|
+
describe "for request with url encoded body" do
|
231
|
+
it "should match request if hash matches body" do
|
232
|
+
expect(request.status).to eq("200")
|
233
|
+
end
|
234
|
+
|
235
|
+
it "should not match if hash doesn't match url encoded body" do
|
236
|
+
expect { wrong_request }.to raise_error(WebMock::NetConnectNotAllowedError)
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
describe "for request with json body and content type is set to json" do
|
241
|
+
it "should match if hash matches body" do
|
242
|
+
expect(http_request(
|
243
|
+
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/json'},
|
244
|
+
body: "{\"a\":\"1\",\"c\":{\"d\":[\"e\",\"f\"]},\"b\":\"five\"}").status).to eq("200")
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
describe "when using 'WebMock::API#hash_including'" do
|
250
|
+
before(:each) do
|
251
|
+
stub_request(:post, "www.example.com").
|
252
|
+
with(body: WebMock::API.hash_including(:a, c: {'d' => ['e', 'f']} ))
|
253
|
+
end
|
254
|
+
|
255
|
+
describe "for request with url encoded body" do
|
256
|
+
it "should match request if hash matches body" do
|
257
|
+
expect(request.status).to eq("200")
|
258
|
+
end
|
259
|
+
|
260
|
+
it "should not match if hash doesn't match url encoded body" do
|
261
|
+
expect { wrong_request }.to raise_error(WebMock::NetConnectNotAllowedError)
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
describe "for request with json body and content type is set to json" do
|
266
|
+
it "should match if hash matches body" do
|
267
|
+
expect(http_request(
|
268
|
+
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/json'},
|
269
|
+
body: "{\"a\":\"1\",\"c\":{\"d\":[\"e\",\"f\"]},\"b\":\"five\"}").status).to eq("200")
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
describe "based on headers" do
|
278
|
+
it "should match requests if headers are the same" do
|
279
|
+
stub_request(:get, "www.example.com").with(headers: SAMPLE_HEADERS )
|
280
|
+
expect(http_request(
|
281
|
+
:get, "http://www.example.com/",
|
282
|
+
headers: SAMPLE_HEADERS).status).to eq("200")
|
283
|
+
end
|
284
|
+
|
285
|
+
it "should match requests if headers are the same and declared as array" do
|
286
|
+
stub_request(:get, "www.example.com").with(headers: {"a" => ["b"]} )
|
287
|
+
expect(http_request(
|
288
|
+
:get, "http://www.example.com/",
|
289
|
+
headers: {"a" => "b"}).status).to eq("200")
|
290
|
+
end
|
291
|
+
|
292
|
+
describe "when multiple headers with the same key are used" do
|
293
|
+
it "should match requests if headers are the same" do
|
294
|
+
stub_request(:get, "www.example.com").with(headers: {"a" => ["b", "c"]} )
|
295
|
+
expect(http_request(
|
296
|
+
:get, "http://www.example.com/",
|
297
|
+
headers: {"a" => ["b", "c"]}).status).to eq("200")
|
298
|
+
end
|
299
|
+
|
300
|
+
it "should match requests if headers are the same but in different order" do
|
301
|
+
stub_request(:get, "www.example.com").with(headers: {"a" => ["b", "c"]} )
|
302
|
+
expect(http_request(
|
303
|
+
:get, "http://www.example.com/",
|
304
|
+
headers: {"a" => ["c", "b"]}).status).to eq("200")
|
305
|
+
end
|
306
|
+
|
307
|
+
it "should not match requests if headers are different" do
|
308
|
+
stub_request(:get, "www.example.com").with(headers: {"a" => ["b", "c"]})
|
309
|
+
|
310
|
+
expect {
|
311
|
+
http_request(
|
312
|
+
:get, "http://www.example.com/",
|
313
|
+
headers: {"a" => ["b", "d"]})
|
314
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/ with headers))
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
it "should match requests if request headers are not stubbed" do
|
319
|
+
stub_request(:get, "www.example.com")
|
320
|
+
expect(http_request(
|
321
|
+
:get, "http://www.example.com/",
|
322
|
+
headers: SAMPLE_HEADERS).status).to eq("200")
|
323
|
+
end
|
324
|
+
|
325
|
+
it "should not match requests if headers are different" do
|
326
|
+
stub_request(:get, "www.example.com").with(headers: SAMPLE_HEADERS)
|
327
|
+
|
328
|
+
expect {
|
329
|
+
http_request(
|
330
|
+
:get, "http://www.example.com/",
|
331
|
+
headers: { 'Content-Length' => '9999'})
|
332
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/ with headers))
|
333
|
+
end
|
334
|
+
|
335
|
+
it "should not match if accept header is different" do
|
336
|
+
stub_request(:get, "www.example.com").
|
337
|
+
with(headers: { 'Accept' => 'application/json'})
|
338
|
+
expect {
|
339
|
+
http_request(
|
340
|
+
:get, "http://www.example.com/",
|
341
|
+
headers: { 'Accept' => 'application/xml'})
|
342
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/ with headers))
|
343
|
+
end
|
344
|
+
|
345
|
+
describe "declared as regular expressions" do
|
346
|
+
it "should match requests if header values match regular expression" do
|
347
|
+
stub_request(:get, "www.example.com").with(headers: { some_header: /^MyAppName$/ })
|
348
|
+
expect(http_request(
|
349
|
+
:get, "http://www.example.com/",
|
350
|
+
headers: { 'some-header' => 'MyAppName' }).status).to eq("200")
|
351
|
+
end
|
352
|
+
|
353
|
+
it "should not match requests if headers values do not match regular expression" do
|
354
|
+
stub_request(:get, "www.example.com").with(headers: { some_header: /^MyAppName$/ })
|
355
|
+
|
356
|
+
expect {
|
357
|
+
http_request(
|
358
|
+
:get, "http://www.example.com/",
|
359
|
+
headers: { 'some-header' => 'xMyAppName' })
|
360
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/ with headers))
|
361
|
+
end
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
describe "when stubbing request with userinfo in url", unless: (adapter_info.include?(:no_url_auth)) do
|
366
|
+
it "should match if credentials are the same" do
|
367
|
+
stub_request(:get, "user:pass@www.example.com")
|
368
|
+
expect(http_request(:get, "http://user:pass@www.example.com/").status).to eq("200")
|
369
|
+
end
|
370
|
+
|
371
|
+
it "should not match if credentials are different" do
|
372
|
+
stub_request(:get, "user:pass@www.example.com")
|
373
|
+
expect {
|
374
|
+
expect(http_request(:get, "http://user:pazz@www.example.com/").status).to eq("200")
|
375
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://user:pazz@www.example.com/))
|
376
|
+
end
|
377
|
+
|
378
|
+
it "should not match if credentials are stubbed but not provided in the request" do
|
379
|
+
stub_request(:get, "user:pass@www.example.com")
|
380
|
+
expect {
|
381
|
+
expect(http_request(:get, "http://www.example.com/").status).to eq("200")
|
382
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/))
|
383
|
+
end
|
384
|
+
|
385
|
+
it "should not match if credentials are not stubbed but exist in the request" do
|
386
|
+
stub_request(:get, "www.example.com")
|
387
|
+
expect {
|
388
|
+
expect(http_request(:get, "http://user:pazz@www.example.com/").status).to eq("200")
|
389
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://user:pazz@www.example.com/))
|
390
|
+
end
|
391
|
+
|
392
|
+
it "should not match if request has credentials provided in basic authentication herader" do
|
393
|
+
stub_request(:get, "user:pass@www.example.com")
|
394
|
+
expect {
|
395
|
+
expect(http_request(:get, "http://www.example.com/", basic_auth: ['user', 'pass']).status).to eq("200")
|
396
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/ with headers))
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
describe "when stubbing request with basic authentication header" do
|
401
|
+
it "should match if credentials are the same" do
|
402
|
+
stub_request(:get, "www.example.com").with(basic_auth: ['user', 'pass'])
|
403
|
+
expect(http_request(:get, "http://www.example.com/", basic_auth: ['user', 'pass']).status).to eq("200")
|
404
|
+
end
|
405
|
+
|
406
|
+
it "should match if credentials are the same and encode to more than one line" do
|
407
|
+
stub_request(:get, "www.example.com").with(basic_auth: ['user' * 5, 'pass' * 5])
|
408
|
+
expect(http_request(:get, "http://www.example.com/", basic_auth: ['user' * 5, 'pass' * 5]).status).to eq("200")
|
409
|
+
end
|
410
|
+
|
411
|
+
it "should match if credentials are the same and were provided directly as authentication headers in request" do
|
412
|
+
stub_request(:get, "www.example.com").with(basic_auth: ['user', 'pass'])
|
413
|
+
expect(http_request(:get, "http://www.example.com/", headers: {'Authorization'=>'Basic dXNlcjpwYXNz'}).status).to eq("200")
|
414
|
+
end
|
415
|
+
|
416
|
+
it "should match if credentials are the same and have been declared in the stub as encoded header" do
|
417
|
+
stub_request(:get, "www.example.com").with(headers: {'Authorization'=>'Basic dXNlcjpwYXNz'})
|
418
|
+
expect(http_request(:get, "http://www.example.com/", basic_auth: ['user', 'pass']).status).to eq("200")
|
419
|
+
end
|
420
|
+
|
421
|
+
it "should not match if credentials are different" do
|
422
|
+
stub_request(:get, "www.example.com").with(basic_auth: ['user', 'pass'])
|
423
|
+
expect {
|
424
|
+
expect(http_request(:get, "http://www.example.com/", basic_auth: ['user', 'pazz']).status).to eq("200")
|
425
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/ with headers))
|
426
|
+
end
|
427
|
+
|
428
|
+
it "should not match if credentials are stubbed but not provided in the request" do
|
429
|
+
stub_request(:get, "www.example.com").with(basic_auth: ['user', 'pass'])
|
430
|
+
expect {
|
431
|
+
expect(http_request(:get, "http://www.example.com/").status).to eq("200")
|
432
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/))
|
433
|
+
end
|
434
|
+
|
435
|
+
it "should match if credentials are not stubbed but exist in the request" do
|
436
|
+
stub_request(:get, "www.example.com")
|
437
|
+
expect(http_request(:get, "http://www.example.com/", basic_auth: ['user', 'pass']).status).to eq("200")
|
438
|
+
end
|
439
|
+
|
440
|
+
it "should not match if request has credentials provides in userinfo", unless: (adapter_info.include?(:no_url_auth)) do
|
441
|
+
stub_request(:get, "www.example.com").with(basic_auth: ['user', 'pass'])
|
442
|
+
expect {
|
443
|
+
expect(http_request(:get, "http://user:pass@www.example.com/").status).to eq("200")
|
444
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://user:pass@www.example.com/))
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
448
|
+
describe "when stubbing request with a global hook" do
|
449
|
+
after(:each) do
|
450
|
+
WebMock::StubRegistry.instance.global_stubs.clear
|
451
|
+
end
|
452
|
+
|
453
|
+
it 'returns the response returned by the hook' do
|
454
|
+
WebMock.globally_stub_request do |request|
|
455
|
+
{ body: "global stub body" }
|
456
|
+
end
|
457
|
+
|
458
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("global stub body")
|
459
|
+
end
|
460
|
+
|
461
|
+
it 'does not get cleared when a user calls WebMock.reset!' do
|
462
|
+
WebMock.globally_stub_request do |request|
|
463
|
+
{ body: "global stub body" }
|
464
|
+
end
|
465
|
+
WebMock.reset!
|
466
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("global stub body")
|
467
|
+
end
|
468
|
+
|
469
|
+
it "does not stub the request if the hook does not return anything" do
|
470
|
+
WebMock.globally_stub_request { |r| }
|
471
|
+
expect {
|
472
|
+
http_request(:get, "http://www.example.com/")
|
473
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/))
|
474
|
+
end
|
475
|
+
|
476
|
+
it "passes the request to the block" do
|
477
|
+
passed_request = nil
|
478
|
+
WebMock.globally_stub_request do |request|
|
479
|
+
passed_request = request
|
480
|
+
{ body: "global stub body" }
|
481
|
+
end
|
482
|
+
|
483
|
+
http_request(:get, "http://www.example.com:456/bar")
|
484
|
+
expect(passed_request.uri.to_s).to eq("http://www.example.com:456/bar")
|
485
|
+
end
|
486
|
+
|
487
|
+
it "should call the block only once per request" do
|
488
|
+
call_count = 0
|
489
|
+
WebMock.globally_stub_request do |request|
|
490
|
+
call_count += 1
|
491
|
+
{ body: "global stub body" }
|
492
|
+
end
|
493
|
+
http_request(:get, "http://www.example.com/")
|
494
|
+
expect(call_count).to eq(1)
|
495
|
+
end
|
496
|
+
|
497
|
+
it 'supports multiple global stubs; the first registered one that returns a non-nil value determines the stub' do
|
498
|
+
stub_invocation_order = []
|
499
|
+
WebMock.globally_stub_request do |request|
|
500
|
+
stub_invocation_order << :nil_stub
|
501
|
+
nil
|
502
|
+
end
|
503
|
+
|
504
|
+
WebMock.globally_stub_request do |request|
|
505
|
+
stub_invocation_order << :hash_stub
|
506
|
+
{ body: "global stub body" }
|
507
|
+
end
|
508
|
+
|
509
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("global stub body")
|
510
|
+
expect(stub_invocation_order).to eq([:nil_stub, :hash_stub])
|
511
|
+
end
|
512
|
+
|
513
|
+
[:before, :after].each do |before_or_after|
|
514
|
+
context "when there is also a non-global registered stub #{before_or_after} the global stub" do
|
515
|
+
def stub_non_globally
|
516
|
+
stub_request(:get, "www.example.com").to_return(body: 'non-global stub body')
|
517
|
+
end
|
518
|
+
|
519
|
+
define_method :register_stubs do |block|
|
520
|
+
stub_non_globally if before_or_after == :before
|
521
|
+
WebMock.globally_stub_request(&block)
|
522
|
+
stub_non_globally if before_or_after == :after
|
523
|
+
end
|
524
|
+
|
525
|
+
it 'uses the response from the global stub if the block returns a non-nil value' do
|
526
|
+
register_stubs(lambda { |req| { body: 'global stub body' } })
|
527
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("global stub body")
|
528
|
+
end
|
529
|
+
|
530
|
+
it 'uses the response from the non-global stub if the block returns a nil value' do
|
531
|
+
register_stubs(lambda { |req| nil })
|
532
|
+
expect(http_request(:get, "http://www.example.com/").body).to eq("non-global stub body")
|
533
|
+
end
|
534
|
+
end
|
535
|
+
end
|
536
|
+
end
|
537
|
+
|
538
|
+
describe "when stubbing request with a block evaluated on request" do
|
539
|
+
it "should match if block returns true" do
|
540
|
+
stub_request(:get, "www.example.com").with { |request| true }
|
541
|
+
expect(http_request(:get, "http://www.example.com/").status).to eq("200")
|
542
|
+
end
|
543
|
+
|
544
|
+
it "should not match if block returns false" do
|
545
|
+
stub_request(:get, "www.example.com").with { |request| false }
|
546
|
+
expect {
|
547
|
+
http_request(:get, "http://www.example.com/")
|
548
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/))
|
549
|
+
end
|
550
|
+
|
551
|
+
it "should pass the request to the block" do
|
552
|
+
stub_request(:post, "www.example.com").with { |request| request.body == "wadus" }
|
553
|
+
expect(http_request(
|
554
|
+
:post, "http://www.example.com/",
|
555
|
+
body: "wadus").status).to eq("200")
|
556
|
+
expect {
|
557
|
+
http_request(:post, "http://www.example.com/", body: "jander")
|
558
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: POST http://www.example.com/ with body 'jander'))
|
559
|
+
end
|
560
|
+
|
561
|
+
it "should call the block only once per request" do
|
562
|
+
call_count = 0
|
563
|
+
stub_request(:get, "www.example.com").with { |request| call_count += 1; true }
|
564
|
+
expect(http_request(:get, "http://www.example.com/").status).to eq("200")
|
565
|
+
expect(call_count).to eq(1)
|
566
|
+
end
|
567
|
+
end
|
568
|
+
end
|
569
|
+
|
570
|
+
describe "when request stub was removed" do
|
571
|
+
it "should raise an error on request" do
|
572
|
+
stub = stub_request(:get, "www.example.com")
|
573
|
+
|
574
|
+
http_request(:get, "http://www.example.com/")
|
575
|
+
|
576
|
+
remove_request_stub(stub)
|
577
|
+
|
578
|
+
expect {
|
579
|
+
http_request(:get, "http://www.example.com/")
|
580
|
+
}.to raise_error(WebMock::NetConnectNotAllowedError, %r(Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/))
|
581
|
+
end
|
582
|
+
end
|
583
|
+
end
|