docbrown/spec/lib/rails_env_constraint_spec.rb
Michael Kohl a1eb6358db
Easier feature flag handling for Cypress (#16379)
* Add RailsEnvConstraint for routes

* Add feature flags API

* Add Cypress commands

* Add show action, update commands, add e2e test

* Update cypress/integration/seededFlows/toggleFeatureFlags.spec.js

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Move helper from command to test file

* Update documentation

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-02-03 10:42:13 -05:00

13 lines
431 B
Ruby

require "rails_helper"
RSpec.describe RailsEnvConstraint, type: :lib do
it "matches only in the correct environments", :aggregate_failures do
constraint = described_class.new(allowed_envs: %w[development])
allow(Rails).to receive(:env).and_return("development")
expect(constraint.matches?).to be true
allow(Rails).to receive(:env).and_return("production")
expect(constraint.matches?).to be false
end
end