Sha256: cbaa99a2b0070a5909db6a92a890fb92f74aaff0256f681dd0ff5acdc3a6f0be

Contents?: true

Size: 893 Bytes

Versions: 4

Compression:

Stored size: 893 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Attachy::Viewer, '.button_label' do
  subject { described_class.new method, object, options }

  let!(:method)  { :avatar }
  let!(:object)  { create :user }
  let(:file)     { create :file, attachable: object }
  let!(:options) { { button: { html: { key: :value } } } }

  before { allow(Cloudinary::Uploader).to receive(:remove_tag) }

  describe 'default options' do
    it 'uses generic button options' do
      el = subject.button_label

      expect(el).to have_tag :span, with: { key: 'value' } do
        with_text '...'
      end
    end
  end

  context 'when :html is present' do
    let!(:html) { { key: 2, text: '---' } }

    it 'merges with default' do
      el = subject.button_label(html: html)

      expect(el).to have_tag :span, with: { key: '2' } do
        with_text '---'
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
attachy-0.4.1 spec/models/attachy/viewer/button_label_spec.rb
attachy-0.4.0 spec/models/attachy/viewer/button_label_spec.rb
attachy-0.3.0 spec/models/attachy/viewer/button_label_spec.rb
attachy-0.2.0 spec/models/attachy/viewer/button_label_spec.rb