Sha256: a0805315785899c76ced8b2dbcc42a6840c910502ee1309aaf76c5be9248f89a

Contents?: true

Size: 926 Bytes

Versions: 3

Compression:

Stored size: 926 Bytes

Contents

require "test_helper"
require "web-facter"

class SearchTest < Test::Unit::TestCase
  include Rack::Test::Methods

  def app
    WebFacter::App.new
  end

  def test_view_renders_successfully
    get "/"
    assert last_response.ok?
  end

  def test_view_returns_json
    get "/"
    json = JSON.load(last_response.body)
    assert json.keys.include?("architecture")
  end

end

class AuthenticationTest < Test::Unit::TestCase
  include Rack::Test::Methods

  def app
    conf = mock()
    conf.expects(:get_value).with('username').returns("admin")
    conf.expects(:get_value).with('password').returns("password")
    WebFacter::App.new().add_auth(conf)
  end

  def test_view_requires_authentication
    authorize 'evil', 'password'
    get "/"
    assert_equal 401, last_response.status
  end

  def test_view_renders_with_auth_details
    authorize 'admin', 'password'
    get "/"
    assert last_response.ok?
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
web-facter-0.1.2 test/integration_test.rb
web-facter-0.1.1 test/integration_test.rb
web-facter-0.1.0 test/integration_test.rb