Permalink
Browse files

Refactoring test setup.

  • Loading branch information...
1 parent 7c7a1f3 commit 10a71cf3063751cd437de1c3612dc64d58f01eae @janfri committed May 14, 2012
Showing with 23 additions and 24 deletions.
  1. +23 −24 test/test_writer.rb
View
@@ -7,16 +7,9 @@ class TestWriter < Test::Unit::TestCase
@writer = MultiExiftool::Writer.new
end
- context 'command method' do
+ context 'various filename combinations' do
- test 'simple case' do
- @writer.filenames = %w(a.jpg b.tif c.bmp)
- @writer.values = {:author => 'janfri'}
- command = 'exiftool -author=janfri a.jpg b.tif c.bmp'
- assert_equal command, @writer.command
- end
-
- test 'no filenames set' do
+ test 'command method, no filenames set' do
@writer.values = {:author => 'janfri'}
assert_raises MultiExiftool::Error do
@writer.command
@@ -34,8 +27,28 @@ class TestWriter < Test::Unit::TestCase
assert_equal command, @writer.command
end
- test 'no values set' do
+ test 'filenames with spaces' do
+ @writer.filenames = ['one file with spaces.jpg', 'another file with spaces.tif']
+ @writer.values = {:author => 'janfri'}
+ command = 'exiftool -author=janfri one\ file\ with\ spaces.jpg another\ file\ with\ spaces.tif'
+ assert_equal command, @writer.command
+ end
+
+ end
+
+ context 'command method, various tags' do
+
+ setup do
@writer.filenames = %w(a.jpg b.tif c.bmp)
+ end
+
+ test 'simple case' do
+ @writer.values = {:author => 'janfri'}
+ command = 'exiftool -author=janfri a.jpg b.tif c.bmp'
+ assert_equal command, @writer.command
+ end
+
+ test 'no values set' do
assert_raises MultiExiftool::Error do
@writer.command
end
@@ -46,59 +59,45 @@ class TestWriter < Test::Unit::TestCase
end
test 'tags with spaces in values' do
- @writer.filenames = %w(a.jpg b.tif c.bmp)
@writer.values = {:author => 'janfri', :comment => 'some comment'}
command = 'exiftool -author=janfri -comment=some\ comment a.jpg b.tif c.bmp'
assert_equal command, @writer.command
end
test 'tags with rational value' do
- @writer.filenames = %w(a.jpg b.tif c.bmp)
@writer.values ={shutterspeed: Rational(1, 125)}
command = 'exiftool -shutterspeed=1/125 a.jpg b.tif c.bmp'
assert_equal command, @writer.command
end
test 'tags with array-like values' do
- @writer.filenames = %w(a.jpg b.tif c.bmp)
@writer.values = {keywords: ['one', 'two', 'and three']}
command = 'exiftool -keywords=one -keywords=two -keywords=and\ three a.jpg b.tif c.bmp'
assert_equal command, @writer.command
end
- test 'filenames with spaces' do
- @writer.filenames = ['one file with spaces.jpg', 'another file with spaces.tif']
- @writer.values = {:author => 'janfri'}
- command = 'exiftool -author=janfri one\ file\ with\ spaces.jpg another\ file\ with\ spaces.tif'
- assert_equal command, @writer.command
- end
-
test 'options with boolean argument' do
- @writer.filenames = %w(a.jpg b.tif c.bmp)
@writer.values = {:author => 'janfri'}
@writer.options = {:overwrite_original => true}
command = 'exiftool -overwrite_original -author=janfri a.jpg b.tif c.bmp'
assert_equal command, @writer.command
end
test 'options with value argument' do
- @writer.filenames = %w(a.jpg b.tif c.bmp)
@writer.values = {:author => 'janfri'}
@writer.options = {:out => 'output_file'}
command = 'exiftool -out output_file -author=janfri a.jpg b.tif c.bmp'
assert_equal command, @writer.command
end
test 'numerical flag' do
- @writer.filenames = %w(a.jpg b.tif c.bmp)
@writer.values = {:author => 'janfri'}
@writer.numerical = true
command = 'exiftool -n -author=janfri a.jpg b.tif c.bmp'
assert_equal command, @writer.command
end
test 'overwrite_original flag' do
- @writer.filenames = %w(a.jpg b.tif c.bmp)
@writer.values = {author: 'janfri'}
@writer.overwrite_original = true
command = 'exiftool -overwrite_original -author=janfri a.jpg b.tif c.bmp'

0 comments on commit 10a71cf

Please sign in to comment.