Sha256: 5c808de3528e20a6cc45063e35fccb9457ce7cff1963030a2dab114cb8fc0496

Contents?: true

Size: 1023 Bytes

Versions: 8

Compression:

Stored size: 1023 Bytes

Contents

require File.dirname(__FILE__) + '/../../../spec_helper'

require 'rack/test'
require 'useless/doc/ui/godel'
require 'useless/doc/core/api'
require 'useless/doc/proxy/html'

describe Useless::Doc::Proxy::HTML do
  include Rack::Test::Methods

  before(:all) do
    @ui = Useless::Doc::UI::Godel.new(nil)
    @subject = Useless::Doc::Core::API.new
  end

  def app
    @app ||= lambda do |env|
      env['useless.doc.ui'] = @ui
      env['useless.doc.subject'] = @subject

      Useless::Doc::Proxy::HTML.call(env)
    end
  end

  it 'should transform the subject to HTML via the specified UI' do
    @ui.should_receive(:html).with(@subject).and_return('html')

    get 'http://some-api.doc.useless.io/some/resource'
    last_response.should be_ok
    last_response.body.should == 'html'
  end

  it 'should return a 404 if the UI cannot render the HTML' do
    @ui.should_receive(:html).with(@subject).and_return(nil)

    get 'http://some-api.doc.useless.io/some/resource'
    last_response.should be_not_found
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
useless-doc-0.7.0 spec/useless/doc/proxy/html_spec.rb
useless-doc-0.6.5 spec/useless/doc/proxy/html_spec.rb
useless-doc-0.6.4 spec/useless/doc/proxy/html_spec.rb
useless-doc-0.6.3 spec/useless/doc/proxy/html_spec.rb
useless-doc-0.6.2 spec/useless/doc/proxy/html_spec.rb
useless-doc-0.6.1 spec/useless/doc/proxy/html_spec.rb
useless-doc-0.6.0 spec/useless/doc/proxy/html_spec.rb
useless-doc-0.5.0 spec/useless/doc/proxy/html_spec.rb