Sha256: 2cc02fea5008333fc577065c90d0cea09fbc7f4b93e155195c8eadd08c5f6874

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

# encoding: utf-8
require 'spec_helper'

# TODO extract out
module TestInputs

  def input_args
    @template = self
    @object = ::Post.new
    @object_name = 'post'
    @method = :title
    @options = {}
    @proc = Proc.new {}
    @builder = Formtastic::FormBuilder.new(@object_name, @object, @template, @options)
    [@builder, @template, @object, @object_name, @method, @options]
  end
  
  class ::UnimplementedInput
    include Formtastic::Inputs::Base
  end

  class ::ImplementedInput < UnimplementedInput
    def to_html
      "some HTML output"
    end
  end
  
end

RSpec.describe 'AnyCustomInput' do
  
  include TestInputs
  
  describe "#to_html" do

    describe 'without an implementation' do
      it "should raise a NotImplementedError exception" do
        expect { ::UnimplementedInput.new(*input_args).to_html }.to raise_error(NotImplementedError)
      end
    end    

    describe 'with an implementation' do
      it "should raise a NotImplementedError exception" do
        expect { ::ImplementedInput.new(*input_args).to_html }.to_not raise_error
      end
    end
    
  end
    
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/formtastic-4.0.0/spec/inputs/custom_input_spec.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/formtastic-4.0.0/spec/inputs/custom_input_spec.rb
formtastic-4.0.0 spec/inputs/custom_input_spec.rb
formtastic-4.0.0.rc1 spec/inputs/custom_input_spec.rb