From 7f883fe8d9878c89a6a0d6452e798c080381c5ff Mon Sep 17 00:00:00 2001 From: Tam Vo Date: Sun, 24 Jun 2012 15:05:57 -0400 Subject: [PATCH] Fix test --- .rvmrc | 4 +++- Gemfile.lock | 11 +++++++---- test/dummy_dropbox_sdk_test.rb | 30 +++++++++++++++++------------- test/fixtures/file.txt | 1 - 4 files changed, 27 insertions(+), 19 deletions(-) delete mode 100644 test/fixtures/file.txt diff --git a/.rvmrc b/.rvmrc index 71c000c..afcfa59 100644 --- a/.rvmrc +++ b/.rvmrc @@ -1 +1,3 @@ -rvm use 1.8.7@dummy_dropbox +rvm use 1.8.7@dummy_dropbox --create +echo rvm_auto_reload_flag=1 >> ~/.rvmrc +echo rvm_auto_reload_flag=2 >> ~/.rvmrc diff --git a/Gemfile.lock b/Gemfile.lock index 270e641..05bfc94 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,20 +1,23 @@ PATH remote: . specs: - dummy_dropbox_sdk (0.0.11) + dummy_dropbox_sdk (0.0.13) dropbox-sdk (>= 1.1) GEM remote: http://rubygems.org/ specs: - dropbox-sdk (1.1) + ansi (1.4.2) + dropbox-sdk (1.3) json - json (1.6.1) + json (1.7.3) + turn (0.9.5) + ansi PLATFORMS ruby DEPENDENCIES bundler (>= 1.0.0.rc.6) - dropbox-sdk (>= 1.1) dummy_dropbox_sdk! + turn diff --git a/test/dummy_dropbox_sdk_test.rb b/test/dummy_dropbox_sdk_test.rb index 44badef..c0aea57 100644 --- a/test/dummy_dropbox_sdk_test.rb +++ b/test/dummy_dropbox_sdk_test.rb @@ -6,7 +6,7 @@ def setup @session = DropboxSession.new('key', 'secret') @client = DropboxClient.new(@session) end - + def test_serialize assert_equal("--- dummy serial\n", @session.serialize ) end @@ -29,29 +29,32 @@ def test_create_folder metadata = @client.file_create_folder '/tmp_folder' assert( File.directory?( "#{DummyDropbox.root_path}/tmp_folder" ) ) assert_equal(true, metadata["is_dir"]) - + FileUtils.rm_r( "#{DummyDropbox.root_path}/tmp_folder" ) end def test_upload FileUtils.rm_r( "#{DummyDropbox.root_path}/file.txt" ) if File.exists?( "#{DummyDropbox.root_path}/file.txt" ) - file_fixture = File.new("#{File.dirname(__FILE__)}/fixtures/file.txt") + File.open("test/file.txt", "w"){|f| f.write("file content")} + DummyDropbox.root_path = "test/" + + file_fixture = File.new("#{File.dirname(__FILE__)}/file.txt") metadata = @client.put_file('file.txt', file_fixture) - assert_equal( - file_fixture.read, + assert_equal( + File.read("#{File.dirname(__FILE__)}/file.txt"), File.read( "#{DummyDropbox.root_path}/file.txt" ) ) - assert( !metadata['is_dir'] ) + assert(!metadata["is_dir"]) FileUtils.rm_r( "#{DummyDropbox.root_path}/file.txt" ) end - + # TODO these methods I don't used yet. They are commented out because they # have to be checked against the api if the signature match - + # def test_download # assert_equal( "File 1", @session.download( '/file1.txt' ) ) # end - # + # # def test_list # assert_equal(['/file1.txt', '/folder1'], @session.list('').map{ |e| e.path } ) # assert_equal(['folder1/file2.txt', 'folder1/file3.txt'], @session.list('folder1').map{ |e| e.path } ) @@ -61,14 +64,15 @@ def test_upload # FileUtils.mkdir_p( "#{DummyDropbox.root_path}/tmp_folder" ) # 3.times { |i| FileUtils.touch( "#{DummyDropbox.root_path}/tmp_folder/#{i}.txt" ) } # - # assert( File.exists?( "#{DummyDropbox.root_path}/tmp_folder" ) ) + # assert( File.exists?( "#{DummyDropbox.root_path}/tmp_folder" ) ) # assert( File.exists?( "#{DummyDropbox.root_path}/tmp_folder/0.txt" ) ) - # + # # metadata = @session.delete '/tmp_folder/0.txt' # assert( !File.exists?( "#{DummyDropbox.root_path}/tmp_folder/0.txt" ) ) - # + # # metadata = @session.delete '/tmp_folder' # assert( !File.exists?( "#{DummyDropbox.root_path}/tmp_folder" ) ) # end - + end + diff --git a/test/fixtures/file.txt b/test/fixtures/file.txt deleted file mode 100644 index 8773f39..0000000 --- a/test/fixtures/file.txt +++ /dev/null @@ -1 +0,0 @@ -file content \ No newline at end of file