Sha256: bf5ca0ccd4085fc21b636b1bec42b29150942c384e4d93e5edc6f66da97e7926

Contents?: true

Size: 1.55 KB

Versions: 7

Compression:

Stored size: 1.55 KB

Contents

require 'rack/test'
require 'rspec'
require 'capybara/rspec'
require 'w3c_validators'

require 'neurohmmerapp'

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

    let 'root' do
      NeuroHmmerApp.root
    end

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

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

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

      nps      = %w(all)
      sequence = 'AGCTAGCTAGCT'

      @params   = {
        'neuropeptides' => nps,
        'seq'           => sequence,
      }
    end

    let 'app' do
      NeuroHmmerApp
    end

    it 'should start the app' do
      get '/'
      last_response.ok?.should == true
    end

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

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

    it 'validate the html' do
      get '/'
      html = last_response.body

      validator = MarkupValidator.new
      results = validator.validate_text(html)

      results.errors.each { |err| puts err.to_s } if results.errors.length > 0
      results.errors.length.should == 0
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
neurohmmerapp-0.0.7 spec/route_spec.rb
neurohmmerapp-0.0.6 spec/route_spec.rb
neurohmmerapp-0.0.5 spec/route_spec.rb
neurohmmerapp-0.0.4 spec/route_spec.rb
neurohmmerapp-0.0.3 spec/route_spec.rb
neurohmmerapp-0.0.2 spec/route_spec.rb
neurohmmerapp-0.0.1 spec/route_spec.rb