Sha256: 5bd7e4de8afb8b4bafbf9382c466da7dff60e1ba6e51306958ba86d8109a1c3d

Contents?: true

Size: 1.39 KB

Versions: 31

Compression:

Stored size: 1.39 KB

Contents

require "rails_helper"

describe Releaf::Builders::FormBuilder::NumberFields, type: :class do
  class FormBuilderTestHelper < ActionView::Base
    include Releaf::ApplicationHelper
    include Releaf::ButtonHelper
    include FontAwesome::Rails::IconHelper
  end

  let(:template){ FormBuilderTestHelper.new }
  let(:object){ Book.new }
  let(:subject){ Releaf::Builders::FormBuilder.new(:book, object, template, {}) }

  describe "#releaf_number_field" do
    it "returns input with type 'number'" do
      expect(subject).to receive(:number_field).with("title", { value: nil, step: "any", class: "text" }).and_return("x")
      expect(subject).to receive(:input_wrapper_with_label).with("title", "x", { label: {}, field: {}, options: { field: { type: "number" }}}).and_return("y")
      expect(subject.releaf_number_field("title")).to eq("y")
    end

    context "aliases" do
      let(:releaf_number_field_method) { subject.method(:releaf_number_field) }

      it "is aliased by #releaf_integer_field" do
        expect(subject.method(:releaf_integer_field)).to eq(releaf_number_field_method)
      end

      it "is aliased by #releaf_float_field" do
        expect(subject.method(:releaf_float_field)).to eq(releaf_number_field_method)
      end

      it "is aliased by #releaf_decimal_field" do
        expect(subject.method(:releaf_decimal_field)).to eq(releaf_number_field_method)
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
releaf-core-1.1.22 spec/builders/releaf/builders/form_builder/number_fields_spec.rb
releaf-core-1.1.21 spec/builders/releaf/builders/form_builder/number_fields_spec.rb
releaf-core-1.1.20 spec/builders/releaf/builders/form_builder/number_fields_spec.rb
releaf-core-1.1.19 spec/builders/releaf/builders/form_builder/number_fields_spec.rb
releaf-core-1.1.18 spec/builders/releaf/builders/form_builder/number_fields_spec.rb
releaf-core-1.1.17 spec/builders/releaf/builders/form_builder/number_fields_spec.rb
releaf-core-1.1.16 spec/builders/releaf/builders/form_builder/number_fields_spec.rb
releaf-core-1.1.15 spec/builders/releaf/builders/form_builder/number_fields_spec.rb
releaf-core-1.1.14 spec/builders/releaf/builders/form_builder/number_fields_spec.rb
releaf-core-1.1.13 spec/builders/releaf/builders/form_builder/number_fields_spec.rb
releaf-core-1.1.12 spec/builders/releaf/builders/form_builder/number_fields_spec.rb
releaf-core-1.1.11 spec/builders/releaf/builders/form_builder/number_fields_spec.rb
releaf-core-1.1.10 spec/builders/releaf/builders/form_builder/number_fields_spec.rb
releaf-core-1.1.9 spec/builders/releaf/builders/form_builder/number_fields_spec.rb
releaf-core-1.1.8 spec/builders/releaf/builders/form_builder/number_fields_spec.rb
releaf-core-1.1.7 spec/builders/releaf/builders/form_builder/number_fields_spec.rb
releaf-core-1.1.6 spec/builders/releaf/builders/form_builder/number_fields_spec.rb
releaf-core-1.1.5 spec/builders/releaf/builders/form_builder/number_fields_spec.rb
releaf-core-1.1.4 spec/builders/releaf/builders/form_builder/number_fields_spec.rb
releaf-core-1.1.3 spec/builders/releaf/builders/form_builder/number_fields_spec.rb