Sha256: c131f39ea72f33cf62b73c427abc3d081755ebf4a48c398925195ece7aa5e652

Contents?: true

Size: 1.25 KB

Versions: 15

Compression:

Stored size: 1.25 KB

Contents

class TestModel
  include Formotion::Formable

  attr_accessor :my_name, :my_number

  form_property :my_name, :string, title: "My Name"
  form_property :my_number, :number, title: "My Number", :transform => lambda { |value| value.to_i + 10 }
end

class AdditionalTestModel
  include Formotion::Formable

  attr_accessor :my_other_name, :my_other_number

  form_property :my_other_name, :string
  form_property :my_other_number, :number
end

describe "FormableController" do
  tests Formotion::FormableController

  def controller
    @model ||= TestModel.new

    @controller ||= Formotion::FormableController.alloc.initWithModel(@model)
  end

  def string_row
    @controller.form.sections.first.rows.first
  end

  def number_row
    @controller.form.sections.first.rows.last
  end

  after do
    (@active_row || string_row).text_field.resignFirstResponder
    wait 1 do
      @active_row = nil
    end
  end

  it "should have new my_value after typing" do
    @active_row = string_row
    tap("My Name")
    string_row.text_field.setText("Hello")
    @model.my_name.should == "Hello"
  end

  it "should have new my_number after typing" do
    @active_row = number_row
    tap("My Number")
    number_row.text_field.setText("10")
    @model.my_number.should == 20
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
formotion-1.8 spec/functional/formable_controller_spec.rb
formotion-1.7 spec/functional/formable_controller_spec.rb
formotion-1.6 spec/functional/formable_controller_spec.rb
formotion-1.5.1 spec/functional/formable_controller_spec.rb
formotion-1.5.0 spec/functional/formable_controller_spec.rb
formotion-1.4.0 spec/functional/formable_controller_spec.rb
formotion-1.3.1 spec/functional/formable_controller_spec.rb
formotion-1.3 spec/functional/formable_controller_spec.rb
formotion-1.2 spec/functional/formable_controller_spec.rb
formotion-1.1.5 spec/functional/formable_controller_spec.rb
formotion-1.1.4 spec/functional/formable_controller_spec.rb
formotion-1.1.3 spec/functional/formable_controller_spec.rb
formotion-1.1.2 spec/functional/formable_controller_spec.rb
formotion-1.1.1 spec/functional/formable_controller_spec.rb
formotion-1.1 spec/functional/formable_controller_spec.rb