Sha256: 21f9dfbb73dd3a8608eff9243e06a19d74af2bb667d734fa709c7f4c7c9b2851

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe 'with input class finder' do
  include_context 'form builder'

  before {
    allow(Formtastic::FormBuilder)
    .to receive(:input_class_finder).and_return(Formtastic::InputClassFinder)
  }
  it_behaves_like 'Input Helper' # from spec/support/shared_examples.rb


  describe 'instantiating an input class' do
    describe 'when instantiated multiple times with the same input type' do

      it "should be cached (not calling the internal methods)" do
        # TODO this is really tied to the underlying implementation
        concat(semantic_form_for(@new_post) do |builder|
          Formtastic::InputClassFinder.should_receive(:new).once.and_call_original
          builder.input(:title, :as => :string)
          builder.input(:title, :as => :string)
        end)
      end
    end

    it "should delegate to InputClassFinder" do
      concat(semantic_form_for(@new_post) do |builder|
        Formtastic::InputClassFinder.any_instance.should_receive(:find).
            with(:string).and_call_original

        builder.input(:title, :as => :string)
      end)
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
formtastic-3.1.5 spec/helpers/namespaced_input_helper_spec.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/formtastic-3.1.4/spec/helpers/namespaced_input_helper_spec.rb
formtastic-3.1.4 spec/helpers/namespaced_input_helper_spec.rb
formtastic-3.1.3 spec/helpers/namespaced_input_helper_spec.rb
formtastic-3.1.2 spec/helpers/namespaced_input_helper_spec.rb
formtastic-3.1.1 spec/helpers/namespaced_input_helper_spec.rb
formtastic-3.1.0 spec/helpers/namespaced_input_helper_spec.rb
formtastic-3.1.0.rc2 spec/helpers/namespaced_input_helper_spec.rb
formtastic-3.1.0.rc1 spec/helpers/namespaced_input_helper_spec.rb