Sha256: 9f9a95237794f35e01db94587b99aca8eb59b5ecadc67e2c74cc2c5ef98059a2

Contents?: true

Size: 1.09 KB

Versions: 14

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Magicka::Input do
  let(:renderer) { instance_double('renderer') }
  let(:template) { 'templates/forms/input' }

  let(:model)       { :my_model }
  let(:field)       { :field }
  let(:label)       { 'Label' }
  let(:placeholder) { 'Value' }

  let(:locals) do
    {
      field: field,
      label: label,
      ng_errors: 'my_model.errors.field',
      ng_model: 'my_model.field',
      placeholder: placeholder
    }
  end

  describe '.render' do
    let(:arguments) do
      {
        renderer: renderer,
        field: field,
        label: label,
        placeholder: placeholder,
        model: model
      }
    end

    before do
      allow(renderer)
        .to receive(:render)
        .with(partial: template, locals: locals)
    end

    it do
      described_class.render(arguments)

      expect(renderer).to have_received(:render)
    end

    context 'when called with extra params' do
      it do
        described_class.render(name: 'Name', **arguments)

        expect(renderer).to have_received(:render)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
magicka-0.6.0 spec/lib/magicka/input_spec.rb
magicka-0.5.6 spec/lib/magicka/input_spec.rb
magicka-0.5.5 spec/lib/magicka/input_spec.rb
magicka-0.5.4 spec/lib/magicka/input_spec.rb
magicka-0.5.3 spec/lib/magicka/input_spec.rb
magicka-0.5.2 spec/lib/magicka/input_spec.rb
magicka-0.5.1 spec/lib/magicka/input_spec.rb
magicka-0.5.0 spec/lib/magicka/input_spec.rb
magicka-0.4.0 spec/lib/magicka/input_spec.rb
magicka-0.3.1 spec/lib/magicka/input_spec.rb
magicka-0.3.0 spec/lib/magicka/input_spec.rb
magicka-0.2.1 spec/lib/magicka/input_spec.rb
magicka-0.2.0 spec/lib/magicka/input_spec.rb
magicka-0.1.0 spec/lib/magicka/input_spec.rb