Skip to content

Commit

Permalink
Added RCov task and brought test coverage up to 100%.
Browse files Browse the repository at this point in the history
  • Loading branch information
Norman Clarke committed Dec 15, 2008
1 parent fb7edf9 commit 45da31a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
24 changes: 24 additions & 0 deletions Rakefile
Expand Up @@ -16,3 +16,27 @@ Hoe.new("friendly_id", FriendlyId::Version::STRING) do |p|
p.rdoc_pattern = /^(lib|bin|ext)|txt|rdoc$/
changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
end

desc "Run RCov"
task :rcov do
run_coverage Dir["test/**/*_test.rb"]
end

def run_coverage(files)
rm_f "coverage"
rm_f "coverage.data"
if files.length == 0
puts "No files were specified for testing"
return
end
files = files.join(" ")
if PLATFORM =~ /darwin/
exclude = '--exclude "gems/"'
else
exclude = '--exclude "rubygems"'
end
rcov = "rcov -Ilib:test --sort coverage --text-report #{exclude} --no-validator-links"
cmd = "#{rcov} #{files}"
puts cmd
sh cmd
end
10 changes: 8 additions & 2 deletions test/string_helpers_test.rb
Expand Up @@ -37,7 +37,7 @@ def test_to_friendly_id_should_strip_leading_slashes
def test_to_friendly_id_should_not_modify_valid_name_strings
assert_match /a-b-c-d/, "a-b-c-d".to_friendly_id
end

# These strings are taken from various international Google homepages. I
# would be most grateful if a fluent speaker of any language that uses a
# writing system other than the Roman alphabet could help me make some
Expand All @@ -47,7 +47,7 @@ def test_to_friendly_id_works_with_non_roman_chars
assert_equal "דפים-מישראל", "דפים מישראל".to_friendly_id
assert_equal "لبحث-في-ويب", "لبحث في ويب".to_friendly_id
end

def test_strip_diactics_correctly_strips_diacritics
input = "ÀÁÂÃÄÅÆÇÈÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ"
output = Slug::strip_diacritics(input).split(//)
Expand All @@ -57,4 +57,10 @@ def test_strip_diactics_correctly_strips_diacritics
end
end

def test_strip_diacritics_in_place
string = "á"
string.strip_diacritics!
assert_equal "a", string
end

end

0 comments on commit 45da31a

Please sign in to comment.