Sha256: 0dadec28e14a3410ac83b14482b8b844259a2423f3bbe55508c4decd110fee4d

Contents?: true

Size: 1.23 KB

Versions: 16

Compression:

Stored size: 1.23 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 {}
    if Rails::VERSION::MAJOR == 4
      @builder = Formtastic::FormBuilder.new(@object_name, @object, @template, @options)
    else
      @builder = Formtastic::FormBuilder.new(@object_name, @object, @template, @options, @proc)
    end
    [@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

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

16 entries across 16 versions & 2 rubygems

Version Path
formtastic-3.1.5 spec/inputs/custom_input_spec.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/formtastic-3.1.4/spec/inputs/custom_input_spec.rb
formtastic-3.1.4 spec/inputs/custom_input_spec.rb
formtastic-3.1.3 spec/inputs/custom_input_spec.rb
formtastic-3.1.2 spec/inputs/custom_input_spec.rb
formtastic-3.1.1 spec/inputs/custom_input_spec.rb
formtastic-3.1.0 spec/inputs/custom_input_spec.rb
formtastic-3.1.0.rc2 spec/inputs/custom_input_spec.rb
formtastic-3.1.0.rc1 spec/inputs/custom_input_spec.rb
formtastic-3.0.0 spec/inputs/custom_input_spec.rb
formtastic-3.0.0.rc2 spec/inputs/custom_input_spec.rb
formtastic-2.3.1 spec/inputs/custom_input_spec.rb
formtastic-2.3.0 spec/inputs/custom_input_spec.rb
formtastic-3.0.0.rc spec/inputs/custom_input_spec.rb
formtastic-2.3.0.rc4 spec/inputs/custom_input_spec.rb
formtastic-2.3.0.rc3 spec/inputs/custom_input_spec.rb