Sha256: f8354eb60fc879c3ea20807f1eb3f6b7d89e5746432fed3eb410aa7448bb5516

Contents?: true

Size: 955 Bytes

Versions: 47

Compression:

Stored size: 955 Bytes

Contents

require File.expand_path('../helper', __FILE__)

class AppModuleTest < Test::Unit::TestCase
  module MyModule
    include Sinatra::AppModule

    module MyHelpers
      def apple(); "Apple"; end
    end

    helpers MyHelpers

    helpers do
      def banana(); "Banana"; end
    end

    get('/') { "Hello" }
    get('/apple') { apple }
    get('/banana') { banana }

    configure do
      set :skittles, "rainbow"
    end

    set :saturn, 'big'
  end

  class App < Sinatra::Base
    include MyModule
  end

  include Rack::Test::Methods
  def app() App; end

  test "hello" do
    get '/'
    assert last_response.body == "Hello"
  end

  test "helpers in a module" do
    get '/apple'
    assert last_response.body == 'Apple'
  end

  test "helpers" do
    get '/banana'
    assert last_response.body == 'Banana'
  end

  test "configure block" do
    assert App.skittles == 'rainbow'
  end

  test "set" do
    assert App.saturn == 'big'
  end
end

Version data entries

47 entries across 47 versions & 2 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb
classiccms-0.7.4 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb
classiccms-0.7.3 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb
classiccms-0.7.2 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb
classiccms-0.7.1 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb
classiccms-0.7.0 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb
classiccms-0.6.9 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb
classiccms-0.6.8 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb
classiccms-0.6.7 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb
classiccms-0.6.6 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb
classiccms-0.6.5 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb
classiccms-0.6.4 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb
classiccms-0.6.3 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb
classiccms-0.6.2 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb
classiccms-0.6.1 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb
classiccms-0.6.0 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb
classiccms-0.5.17 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb
classiccms-0.5.16 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb
classiccms-0.5.15 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb
classiccms-0.5.14 vendor/bundle/gems/sinatra-support-1.2.2/test/test_appmodule.rb