Sha256: 35d9c7aee0c68d0f2c68201ac50ae348c3f5b33780dfba4f9bde3797e201f623

Contents?: true

Size: 855 Bytes

Versions: 4

Compression:

Stored size: 855 Bytes

Contents

require 'spec_helper'

class Callable
  attr_accessor :configuration

  def to_proc
    callable = self

    lambda do |app|
      callable.configuration = config
    end
  end
end

describe RailsEnv do
  it 'runs block when env matches' do
    block = Callable.new
    Rails.env.on(:test, &block)

    expect(block.configuration).to eq(Rails.configuration)
  end

  it 'matches against multiple envs' do
    block = Callable.new
    Rails.env.on(:development, :test, &block)

    expect(block.configuration).to eq(Rails.configuration)
  end

  it 'skips block when env differs' do
    block = Callable.new
    Rails.env.on(:production, &block)

    expect(block.configuration).to be_nil
  end

  it 'runs on any environment' do
    block = Callable.new
    Rails.env.on(:any, &block)

    expect(block.configuration).to eq(Rails.configuration)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails-env-1.0.3 spec/rails-env_spec.rb
rails-env-1.0.2 spec/rails-env_spec.rb
rails-env-1.0.1 spec/rails-env_spec.rb
rails-env-1.0.0 spec/rails-env_spec.rb