Sha256: 46a72ca7f3e48d09f5ee7889a2401c345a63ba3325184f672703c8fac5d5f5f6

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

$:.unshift File.expand_path('../../lib', __FILE__)
require 'stackprof'
require 'stackprof/middleware'
require 'test/unit'
require 'mocha/setup'

class StackProf::MiddlewareTest < Test::Unit::TestCase

  def test_path_default
    StackProf::Middleware.new(Object.new)

    assert_equal 'tmp', StackProf::Middleware.path
  end

  def test_path_custom
    StackProf::Middleware.new(Object.new, { path: '/foo' })

    assert_equal '/foo', StackProf::Middleware.path
  end

  def test_save_default
    StackProf::Middleware.new(Object.new)

    StackProf.stubs(:results).returns({ mode: 'foo' })
    FileUtils.expects(:mkdir_p).with('tmp')
    File.expects(:open).with(regexp_matches(/^tmp\/stackprof-foo/), 'wb')

    StackProf::Middleware.save
  end

  def test_save_custom
    StackProf::Middleware.new(Object.new, { path: '/foo' })

    StackProf.stubs(:results).returns({ mode: 'foo' })
    FileUtils.expects(:mkdir_p).with('/foo')
    File.expects(:open).with(regexp_matches(/^\/foo\/stackprof-foo/), 'wb')

    StackProf::Middleware.save
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
stackprof-0.2.6 test/test_middleware.rb
stackprof-0.2.5 test/test_middleware.rb
stackprof-0.2.4 test/test_middleware.rb
stackprof-0.2.3 test/test_middleware.rb
stackprof-0.2.2 test/test_middleware.rb