Sha256: 152a538d376c1d95c90679cfc31baf3cfba8b6857fde415e9de36317b4416565

Contents?: true

Size: 630 Bytes

Versions: 7

Compression:

Stored size: 630 Bytes

Contents

require "spec_helper"

describe Rack::API, "Helpers" do
  before do
    Rack::API.app do
      version :v1 do
        helper Module.new {
          def helper_from_module
            "module"
          end
        }

        helper do
          def helper_from_block
            "block"
          end
        end

        get("/") do
          [helper_from_block, helper_from_module]
        end
      end
    end
  end

  it "adds module helper" do
    get "/v1"
    json(last_response.body).should include("module")
  end

  it "adds block helper" do
    get "/v1"
    json(last_response.body).should include("block")
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rack-api-1.1.0 spec/rack-api/helpers_spec.rb
rack-api-1.0.2 spec/rack-api/helpers_spec.rb
rack-api-1.0.1 spec/rack-api/helpers_spec.rb
rack-api-1.0.0 spec/rack-api/helpers_spec.rb
rack-api-0.3.1 spec/rack-api/helpers_spec.rb
rack-api-0.3.0 spec/rack-api/helpers_spec.rb
rack-api-0.2.2 spec/rack-api/helpers_spec.rb