Skip to content

Commit

Permalink
Add unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreisner committed Sep 3, 2009
1 parent 670d124 commit 8cc0eaf
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 4 deletions.
58 changes: 55 additions & 3 deletions test/handler_test.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,60 @@
require 'test_helper'

class HandlerTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true

# test "transliteration" do
# unless RUBY_VERSION >= "1.9"
# a = Band.new
# a.name = "Häagen Dazs"
# assert_equal "haagen_dazs", a.generate_handle
# end
# end

test "custom separator" do
a = Person.new
a.name = "Muddy Waters"
assert_equal "muddy-waters", a.generate_handle
end

test "punctuation replacement" do
b = Band.new
{
".38 Special" => "38_special",
"Guns N' Roses" => "guns_n_roses",
"The Rossington-Collins Band" => "the_rossington_collins_band"

}.each do |s,t|
b.name = s
assert_equal t, b.generate_handle
end
end

test "ampersand replacement" do
b = Band.new
{
"Y&T" => "y_and_t",
"Huey Lewis & the News" => "huey_lewis_and_the_news",
"Emerson, Lake & Palmer" => "emerson_lake_and_palmer"

}.each do |s,t|
b.name = s
assert_equal t, b.generate_handle
end
end
end


class Band
include Handler
attr_accessor :name
handle_based_on :name
end


class Person
include Handler
attr_accessor :name
handle_based_on :name, :separator => "-"
end


5 changes: 4 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
require 'rubygems'
require 'active_support'
require 'active_support/test_case'
require 'active_support/test_case'
require 'test/unit'
require 'handler'

0 comments on commit 8cc0eaf

Please sign in to comment.