spec/ruco/application_spec.rb in ruco-0.0.10 vs spec/ruco/application_spec.rb in ruco-0.0.11
- old
+ new
@@ -32,11 +32,11 @@
write("123\n456\n789\n")
app.key(:"Ctrl+g") # go to line
app.key(50) # 2
app.key(:enter)
app.view.should == "#{status}123\n456\n789\n#{command}"
- app.cursor.should == [3,0] # 0 offset + 1 for statusbar
+ app.cursor.should == [2,0] # 0 offset + 1 for statusbar
end
describe 'closing' do
it "can quit" do
result = app.key(:"Ctrl+w")
@@ -57,10 +57,26 @@
app.view.split("\n").last.should include("Loose changes")
app.key(:enter).should == :quit
end
end
+ describe 'go to line' do
+ it "goes to the line" do
+ app.key(:"Ctrl+g")
+ app.key(?2)
+ app.key(:enter)
+ app.cursor.should == [2,0] # status bar + 2
+ end
+
+ it "goes to 1 when strange stuff entered" do
+ app.key(:"Ctrl+g")
+ app.key(?0)
+ app.key(:enter)
+ app.cursor.should == [1,0] # status bar + 1
+ end
+ end
+
describe :bind do
it "can execute bound stuff" do
test = 0
app.bind :'Ctrl+q' do
test = 1
@@ -75,8 +91,20 @@
test = 1
end
app.bind :'Ctrl+q', :foo
app.key(:'Ctrl+q')
test.should == 1
+ end
+ end
+
+ describe '.ruco.rb' do
+ it "loads it and can use the bound keys" do
+ Tempfile.string_as_file("Ruco.configure{ bind(:'Ctrl+e'){ @editor.insert('TEST') } }") do |file|
+ File.stub!(:exist?).and_return true
+ File.should_receive(:expand_path).with("~/.ruco.rb").and_return file
+ app.view.should_not include('TEST')
+ app.key(:"Ctrl+e")
+ app.view.should include("TEST")
+ end
end
end
end
\ No newline at end of file