Commits

Michael Granger  committed 0b5177d

Adding some monkeypatch specs (refs #1), fixing some edge-case pluralizations.

  • Participants
  • Parent commits f251780

Comments (0)

Files changed (3)

File lib/linguistics/en/pluralization.rb

 
 		# Handle ...y
 		when /(.*[aeiou])y$/i then             return "#{$1}ys"
+		when /(.*)Secretary$/ then             return "#{$1}Secretaries"
 		when /([A-Z].*y)$/ then                return "#{$1}s"
 		when /(.*)y$/i then                    return "#{$1}ies"
 

File spec/linguistics/en/articles_spec.rb

 		reset_logging()
 	end
 
+	it "adds EN::Articles to the list of English language modules" do
+		Linguistics::EN.should have_extension( :articles )
+	end
+
+
+	describe "in monkeypatch mode" do
+
+		let( :monkeypatched_class ) do
+			Class.new do
+				def to_s; "antelope"; end
+			end
+		end
+		let( :monkeypatched_object ) do
+			Linguistics.use( :en, classes: monkeypatched_class, monkeypatch: true )
+			monkeypatched_class.new
+		end
+
+
+		it "uses the stringified receiver as the object which should get the article" do
+			monkeypatched_object.a.should == 'an antelope'
+		end
+
+		it "uses correct pluralization to form the negative article" do
+			monkeypatched_object.no.should == 'no antelopes'
+		end
+
+	end
+
 
 	it "uses 'an' as the indefinite article for 'A.B.C'" do
 		"A.B.C".en.a.should == "an A.B.C"
 	end
 
 
+	it "uses correct pluralization to form the negative article" do
+		"mouse".en.no.should == "no mice"
+	end
+
+	it "uses currect pluralization for noun phrases to form the negative article" do
+		"univariate statistic".en.no.should == "no univariate statistics"
+	end
+
+	it "uses the correct pluralization for 'Secretary of State' to form the negative article" do
+		"Secretary of State".en.no.should == "no Secretaries of State"
+	end
+
+
 	context "lprintf formatters" do
 
 		it "registers the :A lprintf formatter" do

File spec/linguistics/en/pluralization_spec.rb

 	end
 
 
-	it "pluralizes 'ferry' as 'ferries'" do
+	it "pluralizes 'ferry as 'ferries'" do
 		'ferry'.en.plural.should == 'ferries' # 
 	end
 
 
 	end
 
+	context "workarounds" do
+
+		it "correctly pluralizes 'Secretary' when capitalized, despite the proper-noun exception" do
+			'Secretary'.en.plural.should == 'Secretaries'
+		end
+
+	end
+
 end