Sha256: 377b3d7092522024599edb7c18950080f7a2ca3807ee61eb2f710d1420e9cd1b

Contents?: true

Size: 1.49 KB

Versions: 10

Compression:

Stored size: 1.49 KB

Contents

describe "Options Row" do
  tests_row title: "Options", key: :options, type: :options,
            items: ["First", "Second"]

  it "should initialize with correct settings" do
    @row.object.class.should == Formotion::RowType::OptionsRow
  end

  it "should build cell with segmented control" do
    cell = @row.make_cell
    cell.accessoryView.class.should == UISegmentedControl
  end

  # Value
  it "should select default value" do
    cell = @row.make_cell

    cell.accessoryView.selectedSegmentIndex.should == -1
    @row.value.should == nil
  end

  it "should select custom value" do
    @row.value = 'Second'
    cell = @row.make_cell

    cell.accessoryView.selectedSegmentIndex.should == 1
    @row.value.should == 'Second'
  end

  it "should bind value to control" do
    @row.value = 'Second'
    cell = @row.make_cell

    @row.value = "First"
    cell.accessoryView.selectedSegmentIndex.should == 0
  end

  it "should bind nil to no selected segment" do
    @row.value = 'Second'
    cell = @row.make_cell

    @row.value = nil
    cell.accessoryView.selectedSegmentIndex.should == UISegmentedControlNoSegment
  end

  it "should work with name-value items" do
    @row = Formotion::Row.new(title: "Options", key: :options, type: :options,
            items: [["First", 1], ["Second", 2]], value: 1)
    @row.reuse_identifier = 'test'
    cell = @row.make_cell

    cell.accessoryView.selectedSegmentIndex.should == 0

    @row.value = 2
    cell.accessoryView.selectedSegmentIndex.should == 1
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
formotion-1.8 spec/row_type/options_spec.rb
formotion-1.7 spec/row_type/options_spec.rb
formotion-1.6 spec/row_type/options_spec.rb
formotion-1.5.1 spec/row_type/options_spec.rb
formotion-1.5.0 spec/row_type/options_spec.rb
formotion-1.4.0 spec/row_type/options_spec.rb
formotion-1.3.1 spec/row_type/options_spec.rb
formotion-1.3 spec/row_type/options_spec.rb
formotion-1.2 spec/row_type/options_spec.rb
formotion-1.1.5 spec/row_type/options_spec.rb