Permalink
Browse files

make access to the test suites part of the ruby lib

  • Loading branch information...
1 parent c4f860e commit d50a72c5defebeab8ba7f52d85e2a621b811b473 @rcarver rcarver committed May 18, 2010
Showing with 32 additions and 22 deletions.
  1. +22 −0 lib/fontvariationdescription/test.rb
  2. +3 −10 test/compactor_test.rb
  3. +3 −10 test/expander_test.rb
  4. +4 −2 test/test_helper.rb
@@ -0,0 +1,22 @@
+require 'yaml'
+
+module FontVariationDescription
+ module Test
+ extend self
+
+ def compact_tests
+ data = YAML.load_file(File.dirname(__FILE__) + "/../../compact.yml")
+ data['tests'].map { |test|
+ [test['fontface'], test['fvd'], test['description']]
+ }
+ end
+
+ def expand_tests
+ data = YAML.load_file(File.dirname(__FILE__) + "/../../expand.yml")
+ data['tests'].map { |test|
+ [test['fontface'], test['fvd'], test['description']]
+ }
+ end
+
+ end
+end
View
@@ -6,17 +6,10 @@ def setup
@compactor = FontVariationDescription::Compactor.new
end
- Data = YAML.load_file(File.dirname(__FILE__) + "/../compact.yml")
-
- Data['tests'].each_with_index do |test, index|
- description = test['description']
- fvd = test['fvd']
- fontface = test['fontface']
-
+ # See compact.yml for test cases.
+ FontVariationDescription::Test.compact_tests.each_with_index do |(fontface, fvd, description), index|
define_method "test_#{index}_#{description.gsub(/\W/, '')}" do
- expected = fvd
- actual = @compactor.parse(fontface)
- assert_equal expected, actual, description
+ assert_equal fvd, @compactor.parse(fontface), description
end
end
View
@@ -6,17 +6,10 @@ def setup
@expander = FontVariationDescription::Expander.new
end
- Data = YAML.load_file(File.dirname(__FILE__) + "/../expand.yml")
-
- Data['tests'].each_with_index do |test, index|
- description = test['description']
- fvd = test['fvd']
- fontface = test['fontface']
-
+ # See expand.yml for test cases.
+ FontVariationDescription::Test.expand_tests.each_with_index do |(fontface, fvd, description), index|
define_method "test_#{index}_#{description.gsub(/\W/, '')}" do
- expected = fontface
- actual = @expander.parse(fvd)
- assert_equal actual, expected, description
+ assert_equal @expander.parse(fvd), fontface, description
end
end
View
@@ -1,5 +1,7 @@
require 'test/unit'
-require 'yaml'
-require File.dirname(__FILE__) + '/../lib/fontvariationdescription'
+$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
+
+require 'fontvariationdescription'
+require 'fontvariationdescription/test'

0 comments on commit d50a72c

Please sign in to comment.