Skip to content

Commit

Permalink
test: restructure some specs to make requirements the top level conte… (
Browse files Browse the repository at this point in the history
#43)

Signed-off-by: Josh Nichols <[email protected]>
Co-authored-by: Jose Miguel Colella <[email protected]>
  • Loading branch information
technicalpickles and josecolella authored Dec 15, 2022
1 parent 1cd12ca commit d75dde2
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 42 deletions.
8 changes: 8 additions & 0 deletions spec/openfeature/sdk/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
RSpec.describe OpenFeature::SDK::API do
subject(:api) { described_class.instance }

context "with Requirement 1.1.1" do
pending
end

context "with Requirement 1.1.2" do
before do
api.configure do |config|
Expand Down Expand Up @@ -90,4 +94,8 @@
expect(api).is_a?(OpenFeature::SDK::Client)
end
end

context "with Requirement 1.1.6" do
pending
end
end
148 changes: 106 additions & 42 deletions spec/openfeature/sdk/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,34 +93,48 @@
end
end

context "Requirement 1.4.1" do
context "MUST provide methods for detailed flag value evaluation with parameters flag key (string, required), default value (boolean | number | string | structure, required), evaluation context (optional), and evaluation options (optional), which returns an evaluation details structure." do
let(:flag_key) { "my-awesome-feature-flag-key" }
context "Requirement 1.3.3" do
pending
end

context "boolean value" do
context "Detailed Feature Evaluation" do
let(:flag_key) { "my-awesome-feature-flag-key" }

context "boolean value" do
context "Requirement 1.4.1" do
it do
expect(client).to respond_to(:fetch_boolean_details)
end

it do
expect(client.fetch_boolean_details(flag_key: flag_key, default_value: false)).is_a?(OpenFeature::SDK::Provider::NoOpProvider::ResolutionDetails)
end
end

context "Requirement 1.4.2" do
it "The evaluation details structure's value field MUST contain the evaluated flag value" do
expect(client.fetch_boolean_details(flag_key: flag_key, default_value: true).value).is_a?(TrueClass)
expect(client.fetch_boolean_details(flag_key: flag_key, default_value: false).value).is_a?(FalseClass)
end
context "Requirement 1.4.2" do
it "The evaluation details structure's value field MUST contain the evaluated flag value" do
expect(client.fetch_boolean_details(flag_key: flag_key, default_value: true).value).is_a?(TrueClass)
expect(client.fetch_boolean_details(flag_key: flag_key, default_value: false).value).is_a?(FalseClass)
end
end

context "Requirement 1.4.4" do
it "The evaluation details structure's flag key field MUST contain the flag key argument passed to the detailed flag evaluation method." do
expect(client).to respond_to(:fetch_boolean_details)
end
context "Requirement 1.4.3" do
pending
end

context "Requirement 1.4.4" do
it "The evaluation details structure's flag key field MUST contain the flag key argument passed to the detailed flag evaluation method." do
expect(client).to respond_to(:fetch_boolean_details)
end
end

context "number value" do
context "Requirement 1.4.5" do
pending
end
end

context "number value" do
context "Requirement 1.4.1" do
it do
expect(client).to respond_to(:fetch_number_details)
end
Expand All @@ -129,44 +143,56 @@
expect(client.fetch_number_details(flag_key: flag_key, default_value: 1.2)).is_a?(OpenFeature::SDK::Provider::NoOpProvider::ResolutionDetails)
expect(client.fetch_number_details(flag_key: flag_key, default_value: 1)).is_a?(OpenFeature::SDK::Provider::NoOpProvider::ResolutionDetails)
end
end

context "Requirement 1.4.2" do
it "The evaluation details structure's value field MUST contain the evaluated flag value" do
expect(client.fetch_number_details(flag_key: flag_key, default_value: 1.0).value).is_a?(Float)
expect(client.fetch_number_details(flag_key: flag_key, default_value: 1).value).is_a?(Integer)
end
context "Requirement 1.4.2" do
it "The evaluation details structure's value field MUST contain the evaluated flag value" do
expect(client.fetch_number_details(flag_key: flag_key, default_value: 1.0).value).is_a?(Float)
expect(client.fetch_number_details(flag_key: flag_key, default_value: 1).value).is_a?(Integer)
end
end

context "Requirement 1.4.4" do
it "The evaluation details structure's flag key field MUST contain the flag key argument passed to the detailed flag evaluation method." do
expect(client).to respond_to(:fetch_number_details)
end
context "Requirement 1.4.3" do
pending
end

context "Requirement 1.4.4" do
it "The evaluation details structure's flag key field MUST contain the flag key argument passed to the detailed flag evaluation method." do
expect(client).to respond_to(:fetch_number_details)
end
end
end

context "string value" do
context "string value" do
context "Requirement 1.4.1" do
it do
expect(client).to respond_to(:fetch_string_details)
end

it do
expect(client.fetch_string_details(flag_key: flag_key, default_value: "some-string")).is_a?(OpenFeature::SDK::Provider::NoOpProvider::ResolutionDetails)
end
end

context "Requirement 1.4.2" do
it "The evaluation details structure's value field MUST contain the evaluated flag value" do
expect(client.fetch_string_details(flag_key: flag_key, default_value: "some-string").value).is_a?(String)
end
context "Requirement 1.4.2" do
it "The evaluation details structure's value field MUST contain the evaluated flag value" do
expect(client.fetch_string_details(flag_key: flag_key, default_value: "some-string").value).is_a?(String)
end
end

context "Requirement 1.4.4" do
it "The evaluation details structure's flag key field MUST contain the flag key argument passed to the detailed flag evaluation method." do
expect(client).to respond_to(:fetch_string_details)
end
context "Requirement 1.4.3" do
pending
end

context "Requirement 1.4.4" do
it "The evaluation details structure's flag key field MUST contain the flag key argument passed to the detailed flag evaluation method." do
expect(client).to respond_to(:fetch_string_details)
end
end
end

context "object value" do
context "object value" do
context "Requirement 1.4.1" do
it do
expect(client).to respond_to(:fetch_object_details)
end
Expand All @@ -175,21 +201,59 @@
expect(client.fetch_object_details(flag_key: flag_key,
default_value: { name: "some-name" })).is_a?(OpenFeature::SDK::Provider::NoOpProvider::ResolutionDetails)
end
end

context "Requirement 1.4.2" do
it "The evaluation details structure's value field MUST contain the evaluated flag value" do
expect(client.fetch_object_details(flag_key: flag_key,
default_value: { name: "some-name" }).value).is_a?(String)
end
context "Requirement 1.4.2" do
it "The evaluation details structure's value field MUST contain the evaluated flag value" do
expect(client.fetch_object_details(flag_key: flag_key,
default_value: { name: "some-name" }).value).is_a?(String)
end
end

context "Requirement 1.4.4" do
it "The evaluation details structure's flag key field MUST contain the flag key argument passed to the detailed flag evaluation method." do
expect(client).to respond_to(:fetch_object_details)
end
context "Requirement 1.4.4" do
it "The evaluation details structure's flag key field MUST contain the flag key argument passed to the detailed flag evaluation method." do
expect(client).to respond_to(:fetch_object_details)
end
end
end

context "Requirement 1.4.5" do
pending
end

context "Requirement 1.4.6" do
pending
end

context "Requirement 1.4.7" do
pending
end

context "Requirement 1.4.8" do
pending
end

context "Requirement 1.4.9" do
pending
end

context "Requirement 1.4.10" do
pending
end

context "Requirement 1.4.11" do
pending
end

context "Requirement 1.4.12" do
pending
end
end

context "Evaluation Options" do
context "Requirement 1.5.1" do
pending
end
end
end
end

0 comments on commit d75dde2

Please sign in to comment.