summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-07-27 17:01:47 -0700
committerGitHub <noreply@github.com>2020-07-27 17:01:47 -0700
commit37c018a6d44a999ed17e21c2f0e3b3c0cf2030fe (patch)
tree082cf5563589730aa48f2aad09d9d390b81a1949
parent755ffdd8f0157343701f3847286aad7987d9be16 (diff)
parent3149ff136e832bfa27cd73200365d986870a9d59 (diff)
downloadchef-37c018a6d44a999ed17e21c2f0e3b3c0cf2030fe.tar.gz
Merge pull request #10214 from chef/fix-spec-load-order-bug
Define local test variables to avoid test load order bug.
-rw-r--r--spec/unit/http/api_versions_spec.rb20
-rw-r--r--spec/unit/server_api_spec.rb32
2 files changed, 36 insertions, 16 deletions
diff --git a/spec/unit/http/api_versions_spec.rb b/spec/unit/http/api_versions_spec.rb
index 774e435c41..d856668af8 100644
--- a/spec/unit/http/api_versions_spec.rb
+++ b/spec/unit/http/api_versions_spec.rb
@@ -53,8 +53,26 @@ describe Chef::HTTP::APIVersions do
m
end
+ let(:version_class) do
+ Class.new do
+ extend Chef::Mixin::VersionedAPIFactory
+
+ version_class_v0 = Class.new do
+ extend Chef::Mixin::VersionedAPI
+ minimum_api_version 0
+ end
+ add_versioned_api_class version_class_v0
+
+ version_class_v2 = Class.new do
+ extend Chef::Mixin::VersionedAPI
+ minimum_api_version 2
+ end
+ add_versioned_api_class version_class_v2
+ end
+ end
+
let(:client) do
- TestVersionClient.new(url, { version_class: VersionedClassVersions })
+ TestVersionClient.new(url, { version_class: version_class })
end
let(:middleware) do
diff --git a/spec/unit/server_api_spec.rb b/spec/unit/server_api_spec.rb
index 3f1d9b0e90..bda6003487 100644
--- a/spec/unit/server_api_spec.rb
+++ b/spec/unit/server_api_spec.rb
@@ -59,20 +59,22 @@ describe Chef::ServerAPI do
end
context "versioned apis" do
- class VersionedClassV0
- extend Chef::Mixin::VersionedAPI
- minimum_api_version 0
- end
-
- class VersionedClassV2
- extend Chef::Mixin::VersionedAPI
- minimum_api_version 2
- end
-
- class VersionedClassVersions
- extend Chef::Mixin::VersionedAPIFactory
- add_versioned_api_class VersionedClassV0
- add_versioned_api_class VersionedClassV2
+ let(:version_class) do
+ Class.new do
+ extend Chef::Mixin::VersionedAPIFactory
+
+ version_class_v0 = Class.new do
+ extend Chef::Mixin::VersionedAPI
+ minimum_api_version 0
+ end
+ add_versioned_api_class version_class_v0
+
+ version_class_v2 = Class.new do
+ extend Chef::Mixin::VersionedAPI
+ minimum_api_version 2
+ end
+ add_versioned_api_class version_class_v2
+ end
end
before do
@@ -80,7 +82,7 @@ describe Chef::ServerAPI do
end
let(:versioned_client) do
- Chef::ServerAPI.new(url, version_class: VersionedClassVersions)
+ Chef::ServerAPI.new(url, version_class: version_class)
end
it "on protocol negotiation it posts the same message body without doubly-encoding the json string" do