Sha256: 19bb3e04fbaadce6bb2c3b52e5fedf229df1b1fcb66792af99830edd09cb7896

Contents?: true

Size: 1.46 KB

Versions: 12

Compression:

Stored size: 1.46 KB

Contents

require "rack/test"

describe Metrics::Integration::Rack::Endpoint do
  include Rack::Test::Methods
  
  def app(options = {})
    @app ||= Metrics::Integration::Rack::Endpoint.new(options)
  end
  def agent
    app.agent
  end
  
  it "should show stats" do
    get "/"
    last_response.should be_ok
    last_response.body.should == agent.to_json
  end
  
  context "configuring" do
    
    context "agent" do
      it "should create an agent by default" do
        app(:agent => nil)
        agent.should be_a(Metrics::Agent)
      end
      
      it "should use an agent if provided" do
        @agent = Metrics::Agent.new
        app(:agent => @agent)
        agent.should be_a(Metrics::Agent)
        agent.should == @agent
      end
    end
    
    context "show" do
      it "should match a string to the PATH_INFO exactly" do
        app(:show => "/foo")
        get '/foo'
        last_response.should be_ok
        last_response.body.should == agent.to_json
      end
      
      it "should match a regular expression to the PATH_INFO" do
        app(:show => /bar/)
        get '/foobarbaz'
        last_response.should be_ok
        last_response.body.should == agent.to_json
      end
      
      it "should call `call` on the show option if it responds to it" do
        app(:show => lambda{ |env| env['PATH_INFO'] == "/bing" })
        get '/bing'
        last_response.should be_ok
        last_response.body.should == agent.to_json
      end
    end
    
  end
  
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
ruby-metrics-0.9.4 spec/integration/rack_endpoint_spec.rb
ruby-metrics-0.9.3 spec/integration/rack_endpoint_spec.rb
ruby-metrics-0.9.2 spec/integration/rack_endpoint_spec.rb
ruby-metrics-0.9.1 spec/integration/rack_endpoint_spec.rb
ruby-metrics-0.9.0 spec/integration/rack_endpoint_spec.rb
yam-ruby-metrics-0.8.9 spec/integration/rack_endpoint_spec.rb
yam-ruby-metrics-0.8.8 spec/integration/rack_endpoint_spec.rb
yam-ruby-metrics-0.8.7 spec/integration/rack_endpoint_spec.rb
yam-ruby-metrics-0.8.6 spec/integration/rack_endpoint_spec.rb
ruby-metrics-0.8.6 spec/integration/rack_endpoint_spec.rb
ruby-metrics-0.8.5 spec/integration/rack_endpoint_spec.rb
ruby-metrics-0.8.0 spec/integration/rack_endpoint_spec.rb