Sha256: 15851a3299abe5df966c21dacff81773194cb148015db2bcfd2c329e3af90660

Contents?: true

Size: 655 Bytes

Versions: 7

Compression:

Stored size: 655 Bytes

Contents

require 'json'
require 'flipper/adapters/memory'
require 'rack/test'

module SpecHelpers
  def self.included(base)
    base.let(:flipper) { build_flipper }
    base.let(:app) { build_app(flipper) }
  end

  def build_app(flipper)
    Flipper::UI.app(flipper) { |builder|
      builder.use Rack::Session::Cookie, secret: "test"
    }
  end

  def build_flipper(adapter = build_memory_adapter)
    Flipper.new(adapter)
  end

  def build_memory_adapter
    Flipper::Adapters::Memory.new
  end

  def json_response
    JSON.load(last_response.body)
  end
end

RSpec.configure do |config|
  config.include Rack::Test::Methods
  config.include SpecHelpers
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
flipper-0.7.5 spec/support/spec_helpers.rb
flipper-0.7.4 spec/support/spec_helpers.rb
flipper-0.7.3 spec/support/spec_helpers.rb
flipper-0.7.2 spec/support/spec_helpers.rb
flipper-0.7.1 spec/support/spec_helpers.rb
flipper-0.7.0 spec/support/spec_helpers.rb
flipper-0.7.0.beta6 spec/support/spec_helpers.rb