From dbd73b1126532a2a2946eb7afef23075eafbf718 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 5 Jan 2010 07:28:52 -0500 Subject: [PATCH] start using code covrage --- .gitignore | 3 ++- Makefile | 5 ++++- tests/TestFilter.rb | 33 +++++++++++++++++++++++++++++++-- tests/data/test_dimensions.png | Bin 0 -> 230 bytes 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 tests/data/test_dimensions.png diff --git a/.gitignore b/.gitignore index da43a1c..cf17e31 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *~ .loadpath .project - +.DS_Store +coverage/ diff --git a/Makefile b/Makefile index 827017c..f7c3612 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,7 @@ -.PHONY : test +.PHONY : test test-coverage test : testrb -b tests/* + +test-coverage : + rcov -x '\/jruby\/lib\/' -x '\/tests\/data\/' tests/*.rb \ No newline at end of file diff --git a/tests/TestFilter.rb b/tests/TestFilter.rb index 7a7ae73..33660dc 100644 --- a/tests/TestFilter.rb +++ b/tests/TestFilter.rb @@ -1,11 +1,11 @@ require 'rubygems' require 'test/unit' -require 'mockfs/override' +require 'fakefs/safe' require File.dirname(__FILE__) + '/../classes/Filter.rb' class TestFilter < Test::Unit::TestCase def setup - @filter = Filter.instance + @filter = Filter.new end def test_recalc_pixels @@ -41,5 +41,34 @@ class TestFilter < Test::Unit::TestCase } assert_equal(10, @filter.config['width']) end + + @filter.config = { + 'print' => true, + 'dpi' => 10, + 'width_inches' => 1, + 'height_inches' => 2 + } + assert_equal(10, @filter.config['width']) + assert_equal(20, @filter.config['height']) + end + + def test_cleanup + @filter.cleanup = [ 'test', 'test2', 'test3' ] + FakeFS do + FileUtils.touch [ 'test', 'test3', 'test4' ] + @filter.cleanup + + [ 'test', 'test2', 'test3' ].each do |file| + assert !(File.exists? file) + end + + [ 'test4' ].each do |file| + assert File.exists? file + end + end + end + + def test_get_dimensions + assert_equal [ 50, 75 ], @filter.get_dimensions(File.dirname(__FILE__) + '/data/test_dimensions.png') end end diff --git a/tests/data/test_dimensions.png b/tests/data/test_dimensions.png new file mode 100644 index 0000000000000000000000000000000000000000..dd69db3c03961dbb15adf0b5b1d18fe3f1195dec GIT binary patch literal 230 zcmeAS@N?(olHy`uVBq!ia0vp^MnLS%2qYM!GGB@UDW)WEcNYf6yIsOdfIQ9ukH}&m z?E%JaC$sH9f@KAc=|CE+m%;ySZz7N*?CIhdqH#X?2R|FTgxkx&SzRU!6BvH=3CDH57fZm>FVdQ&MBb@0F~`Gf&c&j literal 0 HcmV?d00001