-
-
Notifications
You must be signed in to change notification settings - Fork 422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RSpec/Rails Issues with 1.2.1 #821
Comments
@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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Still having issues under 1.2.1 with RSpec/Rails. Not sure I have time tonight to get a PR, so I'm posting some quick notes.
What I think is happening is:
rspec-rails
usesActiveSupport::TestCase
, so both of these blocks are running and clobbering each other:flipper/lib/flipper/test_help.rb
Lines 19 to 37 in 2c9386d
In fact, if I comment out the RSpec chunk, my tests go back to passing.
The text was updated successfully, but these errors were encountered: