Sha256: 0cdf8625116cf90a7dd7445b5d3293514663c55aed2c467813d4f77e199cd87f

Contents?: true

Size: 1.14 KB

Versions: 26

Compression:

Stored size: 1.14 KB

Contents

require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))

describe "environments plugin" do 
  before do
    app
    app.plugin :environments, :development
  end

  it "adds environment accessor for getting/setting the environment" do
    app.environment.must_equal :development
    app.environment = :test
    app.environment.must_equal :test
    
    app.plugin :environments, :production
    app.environment.must_equal :production
  end

  it "adds predicates for testing the environment" do
    app.development?.must_equal true
    app.test?.must_equal false
    app.production?.must_equal false
  end

  it "adds configure method which yields if no arguments are given or an environment matches" do
    a = []
    app.configure{a << 1}
    app.configure(:development){|ap| a << ap}
    app.configure(:test, :production){a << 2}
    a.must_equal [1, app]
  end

  it "defaults environment to RACK_ENV" do
    with_rack_env('test') do
      app(:environments){}
    end
    app.test?.must_equal true
    app.development?.must_equal false
    app(:environments){}
    app.test?.must_equal false
    app.development?.must_equal true
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
roda-2.29.0 spec/plugin/environments_spec.rb
roda-2.28.0 spec/plugin/environments_spec.rb
roda-2.27.0 spec/plugin/environments_spec.rb
roda-2.26.0 spec/plugin/environments_spec.rb
roda-2.25.0 spec/plugin/environments_spec.rb
roda-2.24.0 spec/plugin/environments_spec.rb
roda-2.23.0 spec/plugin/environments_spec.rb
roda-2.22.0 spec/plugin/environments_spec.rb
roda-2.21.0 spec/plugin/environments_spec.rb
roda-2.20.0 spec/plugin/environments_spec.rb
roda-2.19.0 spec/plugin/environments_spec.rb
roda-2.18.0 spec/plugin/environments_spec.rb
roda-2.17.0 spec/plugin/environments_spec.rb
roda-2.16.0 spec/plugin/environments_spec.rb
roda-2.15.0 spec/plugin/environments_spec.rb
roda-2.14.0 spec/plugin/environments_spec.rb
roda-2.13.0 spec/plugin/environments_spec.rb
roda-2.12.0 spec/plugin/environments_spec.rb
roda-2.11.0 spec/plugin/environments_spec.rb
roda-2.10.0 spec/plugin/environments_spec.rb