Sha256: cc662ba32f6d8a001cba0bfb3d26e4bd16288a47ed4e58dd7a97f80e2d5aceea

Contents?: true

Size: 1.71 KB

Versions: 5

Compression:

Stored size: 1.71 KB

Contents

require 'spec_helper'

describe "A controller routed as an AssetsController", :shared => true do
  attr_reader :prefix, :format

  describe "routing" do
    attr_reader :path, :route

    context "given a simple path" do
      before do
        @path  = "/#{prefix}/asset.#{format}"
        @route = { :controller => "engine_assets/#{prefix}", :action => 'show', :path => 'asset', :format => format }
      end

      it "recognizes the path" do
        params_from(:get, path).should == route
      end

      it "generates the path from a URL helper" do
        send("#{prefix}_path", :asset, :format => format).should == path
      end
    end

    context "given a complex path of nested directories" do
      before do
        @path = "/#{prefix}/path/to/asset.#{format}"
        @route = { :controller => "engine_assets/#{prefix}", :action => 'show', :path => 'path/to/asset', :format => format }
      end

      it "recognizes the path" do
        params_from(:get, path).should == route
      end

      it "generates the path from a URL helper" do
        CGI.unescape(send("#{prefix}_path", 'path/to/asset', :format => format)).should == CGI.unescape(path)
      end
    end

    context "given a complex path of dotted components" do
      before do
        @path = "/#{prefix}/path.to/asset.one.#{format}"
        @route = { :controller => "engine_assets/#{prefix}", :action => 'show', :path => 'path.to/asset.one', :format => format }
      end

      it "recognizes the path" do
        params_from(:get, path).should == route
      end

      it "generates the path from a URL helper" do
        CGI.unescape(send("#{prefix}_path", 'path.to/asset.one', :format => format)).should == CGI.unescape(path)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
engine-assets-0.3.3 spec/support/shared/assets_routing_spec.rb
engine-assets-0.3.2 spec/support/shared/assets_routing_spec.rb
engine-assets-0.3.1 spec/support/shared/assets_routing_spec.rb
engine-assets-0.3.0 spec/support/shared/assets_routing_spec.rb
engine-assets-0.2.1 spec/support/shared/assets_routing_spec.rb