Sha256: 201c327aef5ea9059018726024946ebb774c4439ec0587747f51de896397f160

Contents?: true

Size: 868 Bytes

Versions: 4

Compression:

Stored size: 868 Bytes

Contents

require "test_helper"

class Callable
  attr_accessor :configuration

  def to_proc
    callable = self

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

class RailsEnvTest < Minitest::Test
  test "runs block when env matches" do
    block = Callable.new
    Rails.env.on(:test, &block)

    assert_equal Rails.configuration, block.configuration
  end

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

    assert_equal Rails.configuration, block.configuration
  end

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

    assert_nil block.configuration
  end

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

    assert_equal Rails.configuration, block.configuration
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails-env-1.0.7 test/unit/rails_env_test.rb
rails-env-1.0.6 test/unit/rails_env_test.rb
rails-env-1.0.5 test/unit/rails_env_test.rb
rails-env-1.0.4 test/unit/rails_env_test.rb