start using code covrage
This commit is contained in:
parent
8e16d7cc00
commit
dbd73b1126
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
*~
|
*~
|
||||||
.loadpath
|
.loadpath
|
||||||
.project
|
.project
|
||||||
|
.DS_Store
|
||||||
|
coverage/
|
||||||
|
5
Makefile
5
Makefile
@ -1,4 +1,7 @@
|
|||||||
.PHONY : test
|
.PHONY : test test-coverage
|
||||||
|
|
||||||
test :
|
test :
|
||||||
testrb -b tests/*
|
testrb -b tests/*
|
||||||
|
|
||||||
|
test-coverage :
|
||||||
|
rcov -x '\/jruby\/lib\/' -x '\/tests\/data\/' tests/*.rb
|
@ -1,11 +1,11 @@
|
|||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require 'mockfs/override'
|
require 'fakefs/safe'
|
||||||
require File.dirname(__FILE__) + '/../classes/Filter.rb'
|
require File.dirname(__FILE__) + '/../classes/Filter.rb'
|
||||||
|
|
||||||
class TestFilter < Test::Unit::TestCase
|
class TestFilter < Test::Unit::TestCase
|
||||||
def setup
|
def setup
|
||||||
@filter = Filter.instance
|
@filter = Filter.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_recalc_pixels
|
def test_recalc_pixels
|
||||||
@ -41,5 +41,34 @@ class TestFilter < Test::Unit::TestCase
|
|||||||
}
|
}
|
||||||
assert_equal(10, @filter.config['width'])
|
assert_equal(10, @filter.config['width'])
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
BIN
tests/data/test_dimensions.png
Normal file
BIN
tests/data/test_dimensions.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 230 B |
Loading…
Reference in New Issue
Block a user