Sha256: 84385f0286848d559cdb0ce1d42e6f4cc173c49f8e4252ff1a4b17e1e457413a

Contents?: true

Size: 1.74 KB

Versions: 7

Compression:

Stored size: 1.74 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/helper')

class TestCore < Test::Unit::TestCase
  def teardown
    Padrino.clear_middleware!
  end

  context 'for core functionality' do

    should 'check some global methods' do
      assert_respond_to Padrino, :root
      assert_respond_to Padrino, :env
      assert_respond_to Padrino, :application
      assert_respond_to Padrino, :set_encoding
      assert_respond_to Padrino, :load!
      assert_respond_to Padrino, :reload!
      assert_respond_to Padrino, :version
      assert_respond_to Padrino, :bundle
    end

    should 'validate global helpers' do
      assert_equal :test, Padrino.env
      assert_match /\/test/, Padrino.root
      assert_equal nil, Padrino.bundle
      assert_not_nil Padrino.version
    end

    should 'set correct utf-8 encoding' do
      Padrino.set_encoding
      if RUBY_VERSION <'1.9'
        assert_equal 'UTF8', $KCODE
      end
    end

    should 'have load paths' do
      assert_equal [Padrino.root('lib'), Padrino.root('models'), Padrino.root('shared')], Padrino.load_paths
    end

    should 'raise application error if I instantiate a new padrino application without mounted apps' do
      Padrino.mounted_apps.clear
      assert_raise(Padrino::ApplicationLoadError) { Padrino.application.new }
    end

    should "add middlewares in front if specified" do
      test = Class.new {
        def initialize(app)
          @app = app
        end

        def call(env)
          status, headers, body = @app.call(env)
          headers["Middleware-Called"] = "yes"
          return status, headers, body
        end
      }

      Padrino.use(test)

      res = Rack::MockRequest.new(Padrino.application).get("/")
      assert_equal "yes", res["Middleware-Called"]
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
padrino-core-0.9.26 test/test_core.rb
padrino-core-0.9.24 test/test_core.rb
padrino-core-0.9.25 test/test_core.rb
padrino-core-0.9.23 test/test_core.rb
padrino-core-0.9.22 test/test_core.rb
padrino-core-0.9.21 test/test_core.rb
padrino-core-0.9.20 test/test_core.rb