From 2979d314c1e2c660c866201086cf3b58fec800c2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 20 Nov 2026 18:59:24 +0000 Subject: [PATCH 1/3] deps: update dependency flagsmith/sdk-spec to v0.10.0 --- .github/workflows/sdk-spec.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sdk-spec.yml b/.github/workflows/sdk-spec.yml index b0176d8..99f9981 100644 --- a/.github/workflows/sdk-spec.yml +++ b/.github/workflows/sdk-spec.yml @@ -11,8 +11,8 @@ permissions: jobs: sdk-spec: # Keep the ref in `uses:` and `spec-ref` in sync. - uses: Flagsmith/sdk-spec/.github/workflows/run-spec.yml@v0.9.0 + uses: Flagsmith/sdk-spec/.github/workflows/run-spec.yml@v0.10.0 with: - spec-ref: v0.9.0 + spec-ref: v0.10.0 tags: core events local-evaluation language: ruby From 5d7f1c54ec70a525bd49e007b4e59b91b41c4dee Mon Sep 17 00:00:00 2001 From: "flagsmithsmith[bot]" <346993984+flagsmithsmith[bot]@users.noreply.github.com> Date: Fri, 20 Nov 2026 20:10:26 +0000 Subject: [PATCH 2/3] feat: Return each flag's reason under remote evaluation Flagsmith returns each flag's `reason` from /flags/ and /identities/, so read it into `Flag#reason` as local evaluation already does, and expose it from the spec steps (sdk-spec v0.10.0). Co-Authored-By: Claude Opus 5.5 --- lib/flagsmith/sdk/models/flags.rb | 1 + sdk-spec/steps.rb | 2 +- spec/sdk/fixtures/flags.json | 12 ++++++++---- spec/sdk/fixtures/identities.json | 9 ++++++--- spec/sdk/flagsmith_spec.rb | 19 +++++++++++++++++++ 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/lib/flagsmith/sdk/models/flags.rb b/lib/flagsmith/sdk/models/flags.rb index 2177e61..a93d0f8 100644 --- a/lib/flagsmith/sdk/models/flags.rb +++ b/lib/flagsmith/sdk/models/flags.rb @@ -92,6 +92,7 @@ def from_api(json_flag_data) value: json_flag_data.fetch(:feature_state_value) { json_flag_data[:value] }, feature_name: json_flag_data.dig(:feature, :name), feature_id: json_flag_data.dig(:feature, :id), + reason: json_flag_data[:reason], variant: json_flag_data[:variant], experiment: Experiment.from_api(json_flag_data[:metadata]) ) diff --git a/sdk-spec/steps.rb b/sdk-spec/steps.rb index a38be88..faca7e1 100644 --- a/sdk-spec/steps.rb +++ b/sdk-spec/steps.rb @@ -7,7 +7,7 @@ require 'flagsmith' def as_spec_flag(flag) - { feature: flag.feature_name, enabled: flag.enabled, value: flag.value } + { feature: flag.feature_name, enabled: flag.enabled, value: flag.value, reason: flag.reason } end def as_spec_flags(flags) diff --git a/spec/sdk/fixtures/flags.json b/spec/sdk/fixtures/flags.json index 633b24f..33cce9f 100644 --- a/spec/sdk/fixtures/flags.json +++ b/spec/sdk/fixtures/flags.json @@ -15,7 +15,8 @@ "enabled": false, "environment": 2310, "identity": null, - "feature_segment": null + "feature_segment": null, + "reason": "STATIC" }, { "id": 8712, @@ -33,7 +34,8 @@ "enabled": true, "environment": 2310, "identity": null, - "feature_segment": null + "feature_segment": null, + "reason": "STATIC" }, { "id": 8724, @@ -51,7 +53,8 @@ "enabled": false, "environment": 2310, "identity": null, - "feature_segment": null + "feature_segment": null, + "reason": "STATIC" }, { "id": 8766, @@ -69,6 +72,7 @@ "enabled": true, "environment": 2310, "identity": null, - "feature_segment": 335 + "feature_segment": 335, + "reason": "STATIC" } ] diff --git a/spec/sdk/fixtures/identities.json b/spec/sdk/fixtures/identities.json index 7f18f47..967c307 100644 --- a/spec/sdk/fixtures/identities.json +++ b/spec/sdk/fixtures/identities.json @@ -16,7 +16,8 @@ "enabled": false, "environment": 2310, "identity": null, - "feature_segment": null + "feature_segment": null, + "reason": "STATIC" }, { "id": 8712, @@ -34,7 +35,8 @@ "enabled": true, "environment": 2310, "identity": null, - "feature_segment": null + "feature_segment": null, + "reason": "STATIC" }, { "id": 8766, @@ -52,7 +54,8 @@ "enabled": true, "environment": 2310, "identity": null, - "feature_segment": 335 + "feature_segment": 335, + "reason": "TARGETING_MATCH; segment=admins" } ], "traits": [ diff --git a/spec/sdk/flagsmith_spec.rb b/spec/sdk/flagsmith_spec.rb index d65b793..8b05c83 100644 --- a/spec/sdk/flagsmith_spec.rb +++ b/spec/sdk/flagsmith_spec.rb @@ -26,6 +26,25 @@ end end + describe 'flag reasons' do + it 'returns the reason Flagsmith evaluated each environment flag to' do + flags = subject.get_environment_flags + expect(flags.get_flag(:feature_one).reason).to eq('STATIC') + expect(flags.get_flag(:feature_two).reason).to eq('STATIC') + end + + it 'returns the reason Flagsmith evaluated each identity flag to' do + flags = subject.get_identity_flags(user_id) + expect(flags.get_flag(:feature_two).reason).to eq('STATIC') + expect(flags.get_flag(:feature_three).reason).to eq('TARGETING_MATCH; segment=admins') + end + + it 'returns a nil reason when Flagsmith does not send one' do + flag = Flagsmith::Flags::Flag.from_api({ feature: { id: 1, name: 'banner' }, feature_state_value: 'hello', enabled: true }) + expect(flag.reason).to be_nil + end + end + describe '#feature_enabled?' do it 'checks a specific feature' do flags = subject.get_environment_flags From 8565223d05d871decd9824f9023d6fe52e78ee87 Mon Sep 17 00:00:00 2001 From: "flagsmithsmith[bot]" <346993984+flagsmithsmith[bot]@users.noreply.github.com> Date: Sat, 21 Nov 2026 19:44:03 +0000 Subject: [PATCH 3/3] test: Mark Given / When / Then in flag reason examples Co-Authored-By: Claude Opus 5.5 --- spec/sdk/flagsmith_spec.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/spec/sdk/flagsmith_spec.rb b/spec/sdk/flagsmith_spec.rb index 8b05c83..fb46389 100644 --- a/spec/sdk/flagsmith_spec.rb +++ b/spec/sdk/flagsmith_spec.rb @@ -28,19 +28,31 @@ describe 'flag reasons' do it 'returns the reason Flagsmith evaluated each environment flag to' do + # Given / When flags = subject.get_environment_flags + + # Then expect(flags.get_flag(:feature_one).reason).to eq('STATIC') expect(flags.get_flag(:feature_two).reason).to eq('STATIC') end it 'returns the reason Flagsmith evaluated each identity flag to' do + # Given / When flags = subject.get_identity_flags(user_id) + + # Then expect(flags.get_flag(:feature_two).reason).to eq('STATIC') expect(flags.get_flag(:feature_three).reason).to eq('TARGETING_MATCH; segment=admins') end it 'returns a nil reason when Flagsmith does not send one' do - flag = Flagsmith::Flags::Flag.from_api({ feature: { id: 1, name: 'banner' }, feature_state_value: 'hello', enabled: true }) + # Given + json_flag_data = { feature: { id: 1, name: 'banner' }, feature_state_value: 'hello', enabled: true } + + # When + flag = Flagsmith::Flags::Flag.from_api(json_flag_data) + + # Then expect(flag.reason).to be_nil end end