Giter Club home page Giter Club logo

Comments (1)

danielmorrison avatar danielmorrison commented on June 1, 2024

@bkeepers got working on a failing spec for you:

ENV["RAILS_ENV"] = "test"
require 'rubygems'
require 'bundler/setup'
require 'rails'
require 'rails/test_help'

# Not worth trying to test on old Rails versions
return unless Rails::VERSION::MAJOR >= 7

require "capybara/cuprite"
require "flipper"
require "flipper/test_help"

require 'action_dispatch/system_testing/server'
ActionDispatch::SystemTesting::Server.silence_puma = true

class TestApp < Rails::Application
  config.load_defaults "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}"
  config.eager_load = false
  config.logger = ActiveSupport::Logger.new(StringIO.new)
  routes.append do
    root to: "features#index"
  end
end

TestApp.initialize!
require "rspec/rails"

class FeaturesController < ActionController::Base
  def index
    render json: Flipper.enabled?(:test) ? "Enabled" : "Disabled"
  end
end

RSpec.describe "TestHelpTest", type: :system do

  before do 
    # Any driver that runs the app in a separate thread will test what we want here.
    driven_by :cuprite

    # Ensure this test uses this app instance
    Rails.application = TestApp.instance
  end
  
  it "configures a shared adapter between tests and app" do
    Flipper.disable(:test)
    visit "/"
    expect(page).to have_text("Disabled")

    Flipper.enable(:test)
    visit "/"
    expect(page).to have_text("Enabled")
  end
end

Looks like you're already thinking about this in #822 a bit.prepend doesn't fix it for me.

from flipper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.