Sha256: 92095aa83a08e5ef6d3c81f8a16340bb4fb77dc949be2d58c2a84808f866692a

Contents?: true

Size: 1.56 KB

Versions: 5

Compression:

Stored size: 1.56 KB

Contents

module Erb::Formtastic
  module ContentMatchers
    def have_semantic_form_for name
      have_form_call :semantic_form_for, :args => name
    end

    def have_inputs name 
      have_form_call :inputs, :args => ":name => #{name}"
    end
    alias_method :have_input_field_set, :have_inputs

    def have_buttons name 
      have_form_call :buttons
    end
    alias_method :have_button_field_set, :have_buttons

    def have_label name 
      have_form_call :label, :args => ":#{name}"
    end

    def self.inputs_list
      [ :radio, :date, :text, :select, :checkboxes, :time_zone, :password, :date, :datetime, :time, :boolean, :string, :numeric, :country, :hidden ]
    end

    inputs_list.each do |name|
      class_eval %{
        def have_#{name} name
          have_form_call :input, :args => ":\#{name}, :as => :#{name}"
        end

        def have_required_#{name} name
          have_form_call :input, :args => ":\#{name}, :required => true, :as => :#{name}"
        end
      }
    end

    def have_input name 
      have_form_call :input, :args => ":#{name}"
    end

    def have_required_input name 
      have_form_call :input, :args => ":#{name}, :required => true"
    end

    def have_errors_for name
      have_form_call :input, :args => ":#{name}"
    end
    alias_method :have_inline_errors_for, :have_errors_for

    def have_semantic_errors
      have_form_call :semantic_errors
    end

    def have_semantic_fields_for
      have_form_call :semantic_fields_for
    end            

    def have_commit_button 
      have_form_call :commit_button
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
forms-spec-0.1.2 lib/forms-spec/erb/matchers/formtastic/have_formtastic.rb
forms-spec-0.1.1 lib/forms-spec/erb/matchers/formtastic/have_formtastic.rb
forms-spec-0.1.0 lib/forms-spec/erb/matchers/formtastic/have_formtastic.rb
code-spec-0.1.3 lib/code_spec/erb/matchers/formtastic/have_formtastic.rb
code-spec-0.1.2 lib/code_spec/erb/matchers/formtastic/have_formtastic.rb