Sha256: 2f50cf00203b458c5258fb5cbbcaaefed1a2e2da3250df0fb7e0e1fd2d2fae0d
Contents?: true
Size: 1.68 KB
Versions: 3
Compression:
Stored size: 1.68 KB
Contents
require File.expand_path('spec/spec_helper') describe Ruco::Form do let(:form){ Ruco::Form.new('Test', :columns => 30){|value| Ruco::Command.new(:find, value) } } it "positions cursor in text field" do form.cursor.should == [0, 5] end describe :insert do it "adds label size and input size" do form.insert('abc') form.cursor.should == [0, 8] end it "returns nil on any insert" do form.insert('abc').should == nil end it "returns value on enter" do form.insert('abc') form.insert("d\n").should == Ruco::Command.new(:find, 'abcd') end end describe :move do it "moves in text-field" do form.insert('abc') form.move(:relative, 0, -1) form.cursor.should == [0,7] end it "cannot move out of left side" do form.move(:relative, 0, -3) form.cursor.should == [0,5] end it "cannot move out of right side" do form.move(:relative, 0, 4) form.cursor.should == [0,5] form.insert('abc') form.move(:relative, 0, 4) form.cursor.should == [0,8] end end describe :delete do it "removes characters forward" do form.insert('abc') form.move(:relative, 0, -2) form.delete(1) form.view.should == 'Test ac' end it "removes characters backward" do form.insert('abc') form.move(:relative, 0, -1) form.delete(-1) form.view.should == 'Test ac' end it "moves the cursor backward" do form.insert('abc') form.move(:relative, 0, -1) form.delete(-1) form.cursor.should == [0,6] end end describe :view do it "can be viewed" do form.view.should == "Test " end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ruco-0.0.8 | spec/ruco/form_spec.rb |
ruco-0.0.7 | spec/ruco/form_spec.rb |
ruco-0.0.6 | spec/ruco/form_spec.rb |