test/test_command.rb in mercurial-ruby-0.5.0 vs test/test_command.rb in mercurial-ruby-0.6.0

- old
+ new

@@ -18,14 +18,20 @@ end it "should execute commands with timeout" do Mercurial.configuration.stubs(:shell_timeout).returns(1) lambda{ - Mercurial::Command.new("sleep 5").execute + Mercurial::Command.new("sleep 6").execute }.must_raise Timeout::Error end + it "should support custom timeout settings" do + lambda{ + Mercurial::Command.new("sleep 3", :timeout => 1).execute + }.must_raise Timeout::Error + end + it "should generate cache key for every command" do key = Mercurial::Command.new("cd #{ @repository.path } && hg log", :repository => @repository).send(:cache_key) key.must_be_kind_of String (key.size > 10).must_equal true @@ -56,7 +62,25 @@ command = Mercurial::Command.new("cd #{ @repository.path } && hg log -v", :repository => @repository) cache_store = mock('cache_store') cache_store.expects(:fetch).never command.execute end + + it "should not cache command when caching was specifically disabled" do + command = Mercurial::Command.new("hg version", :cache => false, :repository => @repository) + cache_store = mock('cache_store') + Mercurial.configuration.stubs(:cache_store).returns(cache_store) + cache_store.expects(:fetch).never + command.execute + end -end \ No newline at end of file + it "should not use caching it it was overridden by repository" do + command = Mercurial::Command.new("cd #{ @repository.path } && hg log -v", :repository => @repository) + cache_store = mock('cache_store') + cache_store.expects(:fetch).never + Mercurial.configuration.stubs(:cache_store).returns(cache_store) + @repository.no_cache do + command.execute + end + end + +end