Sha256: 305229149f47ca42feef18d95456d4481a6450872e9856e0e1d6ed792ea067bd

Contents?: true

Size: 1.02 KB

Versions: 16

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

module Landable
  describe Directory, '.listing' do
    def stub_contents
      ['/seo/foo', '/aff/bar', '/seo/baz', '/aff/deeply/nested', '/aff/deeply_nested', '/quux'].each do |path|
        create :page, path: path
      end
    end

    it 'knows its own path' do
      dir = Directory.listing '/'
      dir.path.should == '/'
    end

    it 'lists immediate children' do
      stub_contents

      dir = Directory.listing '/'
      dir.subdirectories.map(&:path).should == ['/aff', '/seo']
      dir.pages.map(&:path).should == ['/quux']

      dir = Directory.listing '/aff'
      dir.subdirectories.map(&:path).should == ['/aff/deeply']
      dir.pages.map(&:path).should == ['/aff/bar', '/aff/deeply_nested']

      dir = Directory.listing '/seo'
      dir.subdirectories.should be_empty
      dir.pages.map(&:path).should == ['/seo/baz', '/seo/foo']

      dir = Directory.listing '/aff/deeply'
      dir.subdirectories.should be_empty
      dir.pages.map(&:path).should == ['/aff/deeply/nested']
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
landable-1.13.1 spec/models/landable/directory_spec.rb
landable-1.12.3 spec/models/landable/directory_spec.rb
landable-1.12.2 spec/models/landable/directory_spec.rb
landable-1.12.1 spec/models/landable/directory_spec.rb
landable-1.11.1 spec/models/landable/directory_spec.rb
landable-1.11.0 spec/models/landable/directory_spec.rb
landable-1.10.0.rc2 spec/models/landable/directory_spec.rb
landable-1.10.0.rc1 spec/models/landable/directory_spec.rb
landable-1.9.2 spec/models/landable/directory_spec.rb
landable-1.9.1 spec/models/landable/directory_spec.rb
landable-1.9.0 spec/models/landable/directory_spec.rb
landable-1.9.0.rc2 spec/models/landable/directory_spec.rb
landable-1.9.0.rc1 spec/models/landable/directory_spec.rb
landable-1.8.0 spec/models/landable/directory_spec.rb
landable-1.7.1.rc1 spec/models/landable/directory_spec.rb
landable-1.7.0 spec/models/landable/directory_spec.rb