Sha256: 1b8398550b6ccda04652916d9d03691bd2043aa142d5e6e91f8623153faaf300

Contents?: true

Size: 1.38 KB

Versions: 24

Compression:

Stored size: 1.38 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.new("blogs")] }

    context "with extra resource" do
      before { routes_hash << {:action=>"index", :controller=>"brightcontent/articles", :path_spec => '/articles' } }
      its(:resources) { should eq [Resource.new("blogs"), Resource.new("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.new("blogs")] }
    end

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

      its(:resources) { should eq [Resource.new("blogs")] }
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
brightcontent-core-2.6.0 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.5.1 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.5.0 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.4.6 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.4.5 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.4.4 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.4.3 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.4.2 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.4.1 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.4.0 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.3.4 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.3.3 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.3.2 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.3.1 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.3.0 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.2.2 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.2.1 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.2.0 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.1.5 spec/lib/brightcontent/routes_parser_spec.rb
brightcontent-core-2.1.4 spec/lib/brightcontent/routes_parser_spec.rb