Sha256: 10a86fcbe564b3d121b42aea02a080dd4bb5158fb601ad47e8d45d933c517f32

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

describe Slacken::Filters::ElimInvalidLinks, dsl: true do
  describe '#valid?' do
    subject { described_class.new.valid?(component) }

    context 'when a http link is given' do
      let(:component) do
        c(:a, { href: 'http://example.com' })
      end

      it { is_expected.to be_truthy }
    end

    context 'when a https link is given' do
      let(:component) do
        c(:a, { href: 'https://example.com' })
      end

      it { is_expected.to be_truthy }
    end

    context "when a disallowed link containing 'http://' is given" do
      let(:component) do
        c(:a, { href: '#hogefugahttp://' })
      end

      it { is_expected.to be_falsey }
    end

    context 'when a disallowed link is given' do
      let(:component) do
        c(:a, { href: '#hogehoge' })
      end

      it { is_expected.to be_falsey }
    end

    context 'when a disallowed link occurs as a component\'s component.derive' do
      let(:component) do
        c(:div, c(:span, c(:a, { href: '#hogehoge' })))
      end

      it { is_expected.to be_falsey }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
slacken-0.1.6 spec/slacken/filters/elim_invalid_links_spec.rb
slacken-0.1.5 spec/slacken/filters/elim_invalid_links_spec.rb
slacken-0.1.4 spec/slacken/filters/elim_invalid_links_spec.rb
slacken-0.1.3 spec/slacken/filters/elim_invalid_links_spec.rb
slacken-0.1.2 spec/slacken/filters/elim_invalid_links_spec.rb
slacken-0.1.1 spec/slacken/filters/elim_invalid_links_spec.rb