Sha256: 447d4156df8de518d261b36420cc18359a6e619e2eb71664720bf8d347f458d1

Contents?: true

Size: 1.03 KB

Versions: 18

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

describe AngularSprinkles::FormBinder::Base do
  let(:method) { ->(name, value, *opts) {} }
  let(:args) { [:attribute, {}] }
  let(:attribute_binding) { double }
  let(:object) { double(bind: attribute_binding) }
  let(:params) { { method: method, args: args, object: object } }

  subject { described_class.new(params) }

  it 'raises NotImplementedError for augment_args' do
    expect { subject.call }.to raise_error(NotImplementedError)
  end

  context "when not enough arguments are given" do
    let(:args) { [:attribute] }

    it "returns the args so that the original method will raise an exception" do
      expect(subject.call).to eq(args)
    end
  end

  context "when augment_args is implemented by a subclass" do
    let!(:duped_args) { args.dup }

    before do
      subject.define_singleton_method(:augment_args, -> {})
    end

    it 'does not modify the original params' do
      augmented_args = subject.call

      expect(args).to eq(duped_args)
      expect(args).not_to eq(augmented_args)
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
angular_sprinkles-0.3.3 spec/angular_sprinkles/form_binder/base_spec.rb
angular_sprinkles-0.3.2 spec/angular_sprinkles/form_binder/base_spec.rb
angular_sprinkles-0.3.1 spec/angular_sprinkles/form_binder/base_spec.rb
angular_sprinkles-0.3.0 spec/angular_sprinkles/form_binder/base_spec.rb
angular_sprinkles-0.2.14 spec/angular_sprinkles/form_binder/base_spec.rb
angular_sprinkles-0.2.13 spec/angular_sprinkles/form_binder/base_spec.rb
angular_sprinkles-0.2.12 spec/angular_sprinkles/form_binder/base_spec.rb
angular_sprinkles-0.2.11 spec/angular_sprinkles/form_binder/base_spec.rb
angular_sprinkles-0.2.10 spec/angular_sprinkles/form_binder/base_spec.rb
angular_sprinkles-0.2.9 spec/angular_sprinkles/form_binder/base_spec.rb
angular_sprinkles-0.2.8 spec/angular_sprinkles/form_binder/base_spec.rb
angular_sprinkles-0.2.7 spec/angular_sprinkles/form_binder/base_spec.rb
angular_sprinkles-0.2.6 spec/angular_sprinkles/form_binder/base_spec.rb
angular_sprinkles-0.2.5 spec/angular_sprinkles/form_binder/base_spec.rb
angular_sprinkles-0.2.4 spec/angular_sprinkles/form_binder/base_spec.rb
angular_sprinkles-0.2.3 spec/angular_sprinkles/form_binder/base_spec.rb
angular_sprinkles-0.2.2 spec/angular_sprinkles/form_binder/base_spec.rb
angular_sprinkles-0.2.1 spec/angular_sprinkles/form_binder/base_spec.rb