Sha256: 5eb6e9b501931aec9137bff4901cce373987f51fed82c2ac4f90e652873705c1
Contents?: true
Size: 1.68 KB
Versions: 61
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| @result = 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 "does not return result on normal insert" do form.insert('abc') @result.should == nil end it "returns result on enter" do form.insert('abc') form.insert("d\n") @result.should == "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
61 entries across 61 versions & 1 rubygems