Sha256: 98e8061a02c096423e77894ba435d139c3b2ee11cf3acc243106acd824013d6f

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

Stored size: 1.43 KB

Contents

require "brightcontent/routes_parser"

module Brightcontent
  describe RoutesParser do
    let(:engine_resources) { %w{sessions admin_users} }
    let(:routes_hash) do
      [ {}, nil, {:action=>"admin"},
      {:action=>"index", :controller=>"brightcontent/blogs", :path_spec => '/blogs(.:format)'},
      {:action=>"create", :controller=>"brightcontent/blogs", :path_spec => '/blogs(.:format)'},
      {:controller=>"brightcontent/comments", :action=>"show", :path_spec=>"/blogs/:blog_id/comments/:id(.:format)"}]
    end

    subject(:parser) { RoutesParser.new(routes_hash, engine_resources) }

    its(:resources) { should eq [resource("blogs")] }

    context "with extra resource" do
      before { routes_hash << {:action=>"index", :controller=>"brightcontent/articles", :path_spec => '/articles' } }
      its(:resources) { should eq [resource("blogs"), resource("articles")] }
    end

    context "with engine resources" do
      before do
        engine_resources.each do |resource_name|
          routes_hash << {:action=>"index", :controller=>"brightcontent/#{resource_name}"}
        end
      end
      its(:resources) { should eq [resource("blogs")] }
    end

    context "duplicate resources" do
      before do
        routes_hash << {action: "index", controller: "brightcontent/blogs" }
      end

      its(:resources) { should eq [resource("blogs")] }
    end

    def resource(path)
      RoutesParser::Resource.new(path)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
brightcontent-core-2.0.33 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.0.31 spec/lib/brightcontent/routes_parser_spec.rb