Sha256: ba88ad0d5a389399404999d55bb7a46a89b41284097a219916ad39a66d70a5e4

Contents?: true

Size: 1.55 KB

Versions: 4

Compression:

Stored size: 1.55 KB

Contents

shared_examples 'WordPress::CustomDirectories' do
  let(:fixtures) { File.join(super(), 'custom_directories') }

  describe '#content_dir' do
    {
      default: 'wp-content', https: 'wp-content', custom_w_spaces: 'custom content spaces'
    }.each do |file, expected|
      it "returns #{expected} for #{file}.html" do
        fixture = File.join(fixtures, "#{file}.html")

        stub_request(:get, target.url).to_return(body: File.read(fixture))

        expect(target.content_dir).to eql expected
      end
    end
  end

  describe '#content_dir=, #plugins_dir=' do
    ['wp-content' 'wp-custom'].each do |dir|
      context "when content_dir = #{dir} and no plugins_dir" do
        before { target.content_dir = dir }

        its(:content_dir) { should eq dir.chomp('/') }
        its(:plugins_dir) { should eq dir.chomp('/') + '/plugins' }
      end

      context "when content_dir = #{dir} and plugins_dir = #{dir}" do
        before do
          target.content_dir = dir
          target.plugins_dir = dir
        end

        its(:content_dir) { should eq dir.chomp('/') }
        its(:plugins_dir) { should eq dir.chomp('/') }
      end
    end
  end

  describe '#content_uri, #content_url, #plugins_uri, #plugins_url' do
    before { target.content_dir = 'wp-content' }

    its(:content_uri) { should eq Addressable::URI.parse("#{url}/wp-content/") }
    its(:content_url) { should eq "#{url}/wp-content/" }

    its(:plugins_uri) { should eq Addressable::URI.parse("#{url}/wp-content/plugins/") }
    its(:plugins_url) { should eq "#{url}/wp-content/plugins/" }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cms_scanner-0.0.9 spec/shared_examples/target/platform/wordpress/custom_directories.rb
cms_scanner-0.0.8 spec/shared_examples/target/platform/wordpress/custom_directories.rb
cms_scanner-0.0.7 spec/shared_examples/target/platform/wordpress/custom_directories.rb
cms_scanner-0.0.6 spec/shared_examples/target/platform/wordpress/custom_directories.rb