spec/ruco/application_spec.rb in ruco-0.0.37 vs spec/ruco/application_spec.rb in ruco-0.0.38

- old
+ new

@@ -9,10 +9,15 @@ def write(content) File.open(@file,'w'){|f| f.write(content) } end + def read + File.read(@file) + end + + def editor_part(view) view.naive_split("\n")[1..-2].join("\n") end def type(*keys) @@ -246,9 +251,32 @@ 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 + + describe :save do + it "just saves" do + write('') + app.key('x') + app.key(:'Ctrl+s') + read.should == 'x' + end + + it "warns when saving failed" do + begin + `chmod -w #{@file}` + app.key(:'Ctrl+s') + app.view.should include('Permission denied') + app.key(:enter) # retry ? + app.view.should include('Permission denied') + app.key(:escape) + app.view.should_not include('Permission denied') + ensure + `chmod +w #{@file}` end end end end \ No newline at end of file