Sha256: 81a68f4f307512bdc9fa5de4a88cad34e63134f1cf5b6c697ba840aaaa195c8c

Contents?: true

Size: 1.57 KB

Versions: 29

Compression:

Stored size: 1.57 KB

Contents

require 'awestruct/rack/app'
require 'rack/test'

describe Awestruct::Rack::App do
  include Rack::Test::Methods

  def app
    Awestruct::Rack::App.new(Pathname.new( test_data_dir '')) 
  end

  describe "HTML media type" do
    it "should return text/html" do
      get('/index.html')
      last_response.headers['Content-Type'].should == 'text/html'
    end
  end

  describe "Directory redirect" do
    it "should redirect to /" do
      get('/subdir')
      last_response.headers['location'].should == '/subdir/'
      last_response.instance_variable_get('@body').should == ['Redirecting to: /subdir']
      last_response.body.should == 'Redirecting to: /subdir'
    end
  end

  describe "CSS media type" do
    it "should return text/css" do
      get('/stylesheets/screen.css')
      last_response.headers['Content-Type'].should == 'text/css'
    end
  end

  describe "PNG media type" do
    it "should return image/png" do
      get('/images/logo.png')
      last_response.headers['Content-Type'].should == 'image/png'
    end
  end

  describe "JavaScript media type" do
    it "should return application/javascript" do
      get('/javascript/bootstrap-dropdown.js')
      last_response.headers['Content-Type'].should == 'application/javascript'
    end
  end

  describe "File not found" do
    it "should return a 404 status code" do
      get('/b-is-for-beer.html')
      last_response.status.should == 404
    end
  end

  describe "Directory with no index file" do
    it "should return a 404 status code" do
      get('/images/')
      last_response.status.should == 404
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
awestruct-0.6.7 spec/awestruct/rack/app_spec.rb
awestruct-0.6.6 spec/awestruct/rack/app_spec.rb
awestruct-0.6.5 spec/awestruct/rack/app_spec.rb
awestruct-0.6.4 spec/awestruct/rack/app_spec.rb
awestruct-0.6.3 spec/awestruct/rack/app_spec.rb
awestruct-0.6.2 spec/awestruct/rack/app_spec.rb
awestruct-0.6.1 spec/awestruct/rack/app_spec.rb
awestruct-0.6.0 spec/awestruct/rack/app_spec.rb
awestruct-0.6.0.RC1 spec/awestruct/rack/app_spec.rb
awestruct-0.6.0.alpha4 spec/awestruct/rack/app_spec.rb
awestruct-0.6.0.alpha3 spec/awestruct/rack/app_spec.rb
awestruct-0.6.0.alpha1 spec/awestruct/rack/app_spec.rb
awestruct-0.5.7 spec/awestruct/rack/app_spec.rb
awestruct-0.5.7.RC2 spec/awestruct/rack/app_spec.rb
awestruct-0.5.7.RC1 spec/awestruct/rack/app_spec.rb
awestruct-0.5.6 spec/awestruct/rack/app_spec.rb
awestruct-0.5.6.beta9 spec/awestruct/rack/app_spec.rb
awestruct-0.5.6.beta8 spec/awestruct/rack/app_spec.rb
awestruct-0.5.6.beta7 spec/awestruct/rack/app_spec.rb
awestruct-0.5.6.beta6 spec/awestruct/rack/app_spec.rb