spec/sugar-high/alias_spec.rb in sugar-high-0.2.1 vs spec/sugar-high/alias_spec.rb in sugar-high-0.2.2

- old
+ new

@@ -29,10 +29,58 @@ end multi_alias :_before_ => :kristian, :hejsa => :hello, :_direction_ => :reverse end +class Plural + def monster + 'monster' + end + + alias_for :monster, :pluralize => true +end + +class Plural2 + def monster + 'monster' + end + + alias_for :monster, :beast, :pluralize => true +end + + +class Singular + def monsters + 'monsters' + end + + alias_for :monsters, :singularize => true +end + +class Singular2 + def monsters + 'monsters' + end + + alias_for :monsters, :beasts, :singularize => true +end + + +class AliasHash + def monsters + 'monsters' + end + + def monster + 'monster' + end + + + alias_hash :monsters => :beasts, :singularize => true +end + + class Wow REGISTRATION_LINKS = { :new_registration => :sign_up, :edit_registration => :edit_profile } @@ -61,9 +109,32 @@ end it "should find -hejsa alias method for kristian" do Ged.new.respond_to?(:kristian_hejsa).should be_true end + + it "should find singularized alias" do + Singular.new.respond_to?(:monster).should be_true + end + + it "should find singularized alias" do + Singular2.new.respond_to?(:beast).should be_true + end + + it "should find pluralized alias" do + Plural.new.respond_to?(:monsters).should be_true + end + + it "should find pluralized alias" do + Plural2.new.respond_to?(:beasts).should be_true + end + + it "should find nice aliases from using alias_hash" do + ah = AliasHash.new + ah.beasts.should == 'monsters' + ah.beast.should == 'monster' + end + it "should find alias methods!" do w = Wow.new w.respond_to?(:new_registration_link).should be_true w.respond_to?(:sign_up_link).should be_true