Sha256: c7117a01404da18a0a835f170e9f201e4e32eab3873e2219cf25b4044bbf71a1

Contents?: true

Size: 1.96 KB

Versions: 7

Compression:

Stored size: 1.96 KB

Contents

require 'minitest/autorun'
require 'capybara/minitest'

require 'genevalidatorapp'

# Basic unit tests for HTTP / Rack interface.
module GeneValidatorApp
  # include W3CValidators
  describe 'Routes' do
    ENV['RACK_ENV'] = 'production'
    include Rack::Test::Methods

    let 'root' do
      GeneValidatorApp.root
    end

    let 'empty_config' do
      File.join(root, 'test', 'empty_config.yml')
    end

    let 'database_dir' do
      File.join(root, 'test', 'database')
    end

    before :each do
      GeneValidatorApp.init(config_file: empty_config,
                            database_dir: database_dir)

      validations = %w[lenc lenr dup merge align frame orf]
      sequence    = 'AGCTAGCTAGCT'
      database    = Database.first.name

      @params = {
        'validations' => validations,
        'seq'         => sequence,
        'database'    => database
      }
    end

    let 'app' do
      GeneValidatorApp
    end

    it 'should start the app' do
      get '/'
      assert_equal(true, last_response.ok?)
    end

    it 'returns Bad Request (400) if no sequence is provided' do
      @params.delete('seq')
      post '/', @params
      assert_equal(400, last_response.status)
    end

    it 'returns Bad Request (400) if no validations is provided' do
      @params.delete('validations')
      post '/', @params
      assert_equal(400, last_response.status)
    end

    it 'returns Bad Request (400) if no database is provided' do
      @params.delete('database')
      post '/', @params
      assert_equal(400, last_response.status)
    end

    # W3C_Validator Gem is broken - https://github.com/alexdunae/w3c_validators/issues/16
    # it 'validate the html' do
    # get '/'
    # html = last_response.body

    # validator = MarkupValidator.new
    # results = validator.validate_text(html.to_s)
    # results.errors.each { |err| puts err.to_s } if results.errors.length > 0
    # puts results.errors
    # results.errors.length.should == 0
    # end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
genevalidatorapp-2.1.8 test/test_route_spec.rb
genevalidatorapp-2.1.7 test/test_route_spec.rb
genevalidatorapp-2.1.6 test/test_route_spec.rb
genevalidatorapp-2.1.5 test/test_route_spec.rb
genevalidatorapp-2.1.4 test/test_route_spec.rb
genevalidatorapp-2.1.3 test/test_route_spec.rb
genevalidatorapp-2.1.2 test/test_route_spec.rb