Sha256: 5cff69058612029ebe9e02de440045c718ff6768f54136ece3866110845362c4

Contents?: true

Size: 830 Bytes

Versions: 27

Compression:

Stored size: 830 Bytes

Contents

require_relative "helper"

scope do
  module Helper
    def clean(str)
      str.strip
    end
  end

  test do
    Cuba.plugin Helper

    Cuba.define do
      on default do
        res.write clean " foo "
      end
    end

    _, _, body = Cuba.call({})

    assert_response body, ["foo"]
  end
end

scope do
  module Number
    def num
      1
    end
  end

  module Plugin
    def self.setup(app)
      app.plugin Number
    end

    def bar
      "baz"
    end

    module ClassMethods
      def foo
        "bar"
      end
    end
  end

  setup do
    Cuba.plugin Plugin

    Cuba.define do
      on default do
        res.write bar
        res.write num
      end
    end
  end

  test do
    assert_equal "bar", Cuba.foo
  end

  test do
    _, _, body = Cuba.call({})

    assert_response body, ["baz", "1"]
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
cuba-4.0.3 test/plugin.rb
cuba-4.0.1 test/plugin.rb
cuba-4.0.0 test/plugin.rb
cuba-3.9.3 test/plugin.rb
cuba-3.9.2 test/plugin.rb
cuba-3.9.1 test/plugin.rb
cuba-3.9.0 test/plugin.rb
cuba-3.8.1 test/plugin.rb
cuba-3.8.0 test/plugin.rb
cuba-3.7.0 test/plugin.rb
cuba-3.6.0 test/plugin.rb
cuba-3.5.0 test/plugin.rb
cuba-3.4.0 test/plugin.rb
cuba-3.3.0 test/plugin.rb
cuba-3.2.0 test/plugin.rb
cuba-3.1.1 test/plugin.rb
cuba-3.1.0 test/plugin.rb
cuba-3.1.0.rc2 test/plugin.rb
cuba-3.1.0.rc1 test/plugin.rb
cuba-3.0.1.rc2 test/plugin.rb