Sha256: 2fe3e3874ec583e494712fd702deda573f6b24e5c097d2d90af4a93957d8abb8

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

describe NYNY::App do
  describe 'namespace' do
    let (:app) do
      mock_app do
        helpers do
          def le_helper
            :lulwut
          end
        end

        namespace '/foo' do
          get '/' do
            le_helper.should == :lulwut
            'bar'
          end
        end

        namespace '/nested' do
          namespace '/space' do
            get '/' do
              le_helper.should == :lulwut
              'caramba'
            end
          end
        end

        get '/' do
          'no namespace here'
        end
      end
    end

    it 'allows to use middlewares inside namespace' do
      kls = Class.new(NYNY::Base) do
        get '/' do
          'foo'
        end
      end

      app = mock_app do
        namespace '/foo' do
          use kls
        end
      end

      app.get('/foo')
    end

    it 'allows to specify stuff in namespaces' do
      app.get('/foo').body.should == 'bar'
    end

    it 'does not break the main app' do
      app.get('/').body.should == 'no namespace here'
    end

    it 'can be nested as well' do
      app.get('/nested/space/').body.should == 'caramba'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nyny-3.4.1 spec/namespace_spec.rb