Sha256: 3257afa95a20f577548975d3d66ee301f4c4bb0e654ff082c6d9953cbe65ee63

Contents?: true

Size: 1.33 KB

Versions: 7

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

describe Lookout::Rack::Utils::Subroute, :type => :route do
  describe '#subroute' do
    let(:route) { '/test_route' }
    let(:original) { get route }

    subject(:subrouted) { get "/subrouted" }

    before :each do
      class RouteHelpers::Server
        include Lookout::Rack::Utils::Subroute
        get '/subrouted' do
          subroute!('/test_route')
        end
      end
    end

    it 'should return the status code and body of the route' do
      expect([subrouted.status, subrouted.body]).to eql [original.status, original.body]
    end
  end

  describe '#succeeded?' do
    subject { SubrouteTestHelper.new.succeeded?(status) }
    context 'with status 200' do
      let(:status) { 200 }
      it { should be_true }
    end

    context 'with status 299' do
      let(:status) { 299 }
      it { should be_true }
    end

    context 'with a non-20x status' do
      let(:status) { 300 }
      it { should be_false }
    end
  end

  describe '#failed?' do
    subject { SubrouteTestHelper.new.failed?(status) }
    context 'with status 200' do
      let(:status) { 200 }
      it { should be_false }
    end

    context 'with status 299' do
      let(:status) { 299 }
      it { should be_false }
    end

    context 'with a non-20x status' do
      let(:status) { 300 }
      it { should be_true }
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lookout-rack-utils-1.4.0 spec/subroute_spec.rb
lookout-rack-utils-1.3.0 spec/subroute_spec.rb
lookout-rack-utils-1.2.4 spec/subroute_spec.rb
lookout-rack-utils-1.2.3 spec/subroute_spec.rb
lookout-rack-utils-1.2.2 spec/subroute_spec.rb
lookout-rack-utils-1.2.1 spec/subroute_spec.rb
lookout-rack-utils-1.2.0 spec/subroute_spec.rb