Sha256: 474dbbae01643d74f738fbe0824076fa21d5448f3b5f303bf2b1889f5c5212fa

Contents?: true

Size: 933 Bytes

Versions: 5

Compression:

Stored size: 933 Bytes

Contents

require 'spec_helper'
require 'action_controller'

describe Fozzie::Rails::Middleware do

  subject do
    RailsApp = Class.new do
      def call(env)
        env
      end
    end unless defined?(RailsApp)
    Fozzie::Rails::Middleware.new RailsApp.new
  end

  describe "subject" do
    it "returns env on call for testing" do
      subject.call({}).should == {}
    end
  end

  it "#generate_key" do
    s = '/somewhere/railsy'
    fake_env = { 'PATH_INFO' => s }
    ActionController::Routing::Routes.expects(:recognize_path).with(s).returns({:controller => 'somewhere', :action => 'railsy'})
    subject.generate_key(fake_env).should == 'somewhere.railsy.render'
  end
  
  it "returns nil on routing error" do
    s = '/somewhere/railsy'
    fake_env = { 'PATH_INFO' => s }
    ActionController::Routing::Routes.expects(:recognize_path).with(s).raises(ArgumentError)
    subject.generate_key(fake_env).should == nil
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fozzie-0.0.11 spec/lib/fozzie/rails/middleware_spec.rb
fozzie-0.0.10 spec/lib/fozzie/rails/middleware_spec.rb
fozzie-0.0.9 spec/lib/fozzie/rails/middleware_spec.rb
fozzie-0.0.8 spec/lib/fozzie/rails/middleware_spec.rb
fozzie-0.0.7 spec/lib/fozzie/rails/middleware_spec.rb