Sha256: 29c5fd086632c146132888b6fe59208051be2e19da04a93e8bce40fdf7237408

Contents?: true

Size: 1.79 KB

Versions: 14

Compression:

Stored size: 1.79 KB

Contents

require File.expand_path('spec/spec_helper')

describe Ruco::TextArea do
  describe :move do
    describe 'pages' do
      it "can move down a page" do
        text = Ruco::TextArea.new("1\n2\n3\n4\n5\n6\n7\n8\n9\n", :lines => 3, :columns => 3)
        text.move(:page_down)
        text.view.should == "3\n4\n5"
        text.cursor.should == [1,0]
      end

      it "keeps cursor position when moving down" do
        text = Ruco::TextArea.new("1\n2abc\n3\n4\n5ab\n6\n7\n8\n9\n", :lines => 3, :columns => 5)
        text.move(:to, 1,4)
        text.move(:page_down)
        text.view.should == "4\n5ab\n6"
        text.cursor.should == [1,3]
      end

      it "can move up a page" do
        text = Ruco::TextArea.new("0\n1\n2\n3\n4\n5\n6\n7\n8\n", :lines => 3, :columns => 3)
        text.move(:to, 4, 0)
        text.view.should == "3\n4\n5"
        text.cursor.should == [1,0]
        text.move(:page_up)
        text.view.should == "0\n1\n2"
        text.cursor.should == [1,0]
      end

      it "keeps column position when moving up" do
        text = Ruco::TextArea.new("0\n1\n2ab\n3\n4\n5abc\n6\n7\n8\n9\n10\n11\n", :lines => 3, :columns => 5)
        text.move(:to, 5, 3)
        text.view.should == "4\n5abc\n6"
        text.cursor.should == [1,3]
        text.move(:page_up)
        text.view.should == "1\n2ab\n3"
        text.cursor.should == [1,3]
      end

      it "moves pages symetric" do
        text = Ruco::TextArea.new("0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n", :lines => 3, :columns => 3)
        text.move(:to, 4, 1)
        text.view.should == "3\n4\n5"
        text.cursor.should == [1,1]

        text.move(:page_down)
        text.move(:page_down)
        text.move(:page_up)
        text.move(:page_up)

        text.cursor.should == [1,1]
        text.view.should == "3\n4\n5"
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ruco-0.1.8 spec/ruco/text_area_spec.rb
ruco-0.1.7 spec/ruco/text_area_spec.rb
ruco-0.1.6 spec/ruco/text_area_spec.rb
ruco-0.1.5 spec/ruco/text_area_spec.rb
ruco-0.1.4 spec/ruco/text_area_spec.rb
ruco-0.1.3 spec/ruco/text_area_spec.rb
ruco-0.1.2 spec/ruco/text_area_spec.rb
ruco-0.1.1 spec/ruco/text_area_spec.rb
ruco-0.1.0 spec/ruco/text_area_spec.rb
ruco-0.0.56 spec/ruco/text_area_spec.rb
ruco-0.0.55 spec/ruco/text_area_spec.rb
ruco-0.0.54 spec/ruco/text_area_spec.rb
ruco-0.0.53 spec/ruco/text_area_spec.rb
ruco-0.0.52 spec/ruco/text_area_spec.rb