Sha256: c8a9852fcac4bcfd0d5f6f138e38315b66d1711fa52732f0b6221b48d7c63e3c

Contents?: true

Size: 1.64 KB

Versions: 4

Compression:

Stored size: 1.64 KB

Contents

require 'helper'

module Coupler
  class TestBase < Coupler::Test::UnitTest
    def test_subclasses_sinatra_base
      assert_equal Sinatra::Base, Coupler::Base.superclass
    end

    def test_index_when_no_projects
      get "/"
      assert last_response.ok?
      assert_match /Getting Started/, last_response.body
    end

    def test_redirect_when_projects_exist
      project = Factory(:project)
      get "/"
      assert last_response.redirect?
      assert_equal "http://example.org/projects", last_response['location']
    end

    def test_db_path
      env = Base.settings.environment
      begin
        Base.set :environment, :production
        expected = File.join(Base.settings.data_path, 'db', 'production', 'ponies')
        assert_equal expected, Base.db_path("ponies")
      ensure
        Base.set :environment, env
      end
    end

    def test_connection_string
      env = Base.settings.environment
      begin
        Base.set :environment, :production
        expected = "jdbc:h2:#{File.join(Base.settings.data_path, 'db', 'production', 'ponies')};IGNORECASE=TRUE"
        assert_equal expected, Base.connection_string("ponies")
      ensure
        Base.set :environment, env
      end
    end

    def test_upload_path
      env = Base.settings.environment
      begin
        Base.set :environment, :production
        expected = File.join(Base.settings.data_path, 'uploads', 'production')
        assert_equal expected, Base.upload_path
      ensure
        Base.set :environment, env
      end
    end

    def test_log_path
      expected = File.join(Base.settings.data_path, 'log')
      assert_equal expected, Base.log_path
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
coupler-0.0.4-java test/unit/test_base.rb
coupler-0.0.3-java test/unit/test_base.rb
coupler-0.0.2-java test/unit/test_base.rb
coupler-0.0.1-java test/unit/test_base.rb