Sha256: ade71a71eca530eab3946368ee4c0afaa2862556e1539c970ceb5cf903d54a41

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

describe Uploadcare::Rails do
  it 'includes widget from cdn' do
    tag = helper.include_uploadcare_widget_from_cdn

    expect(tag).to eq(
      [
        "<script src=\"https://ucarecdn.com/widget/",
        UPLOADCARE_SETTINGS.widget_version,
        '/uploadcare/uploadcare.min.js"></script>'
      ].join
    )
  end

  describe 'for specifyed version' do
    let(:version) { '0.13.3' }

    it 'uses widget version' do
      tag = helper.include_uploadcare_widget_from_cdn(version: version)

      expect(tag).to eq(
        "<script src=\"https://ucarecdn.com/widget/#{ version }/"\
        'uploadcare/uploadcare.min.js"></script>'
      )
    end

    it 'loads not minified version' do
      tag =
        helper.include_uploadcare_widget_from_cdn(version: version, min: false)

      expect(tag).to eq(
        "<script src=\"https://ucarecdn.com/widget/#{ version }/"\
        'uploadcare/uploadcare.js"></script>'
      )
    end
  end

  describe 'uploadcare settings' do
    let(:subject) { helper.uploadcare_settings }

    it { is_expected.to be_a(String) }
    it { is_expected.not_to be_empty }
    %w(
      UPLOADCARE_LOCALE UPLOADCARE_PREVIEW_STEP
      UPLOADCARE_PUBLIC_KEY UPLOADCARE_CLEARABLE
      UPLOADCARE_TABS UPLOADCARE_AUTOSTORE
      UPLOADCARE_MANUAL_START UPLOADCARE_PATH_VALUE).each do |content|
      it 'contains expected selector' do
        is_expected.to have_selector('script', content: content)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
uploadcare-rails-1.1.0 spec/helpers/include_tags_spec.rb