Permalink
Browse files

Demodulize singular and plural keys in inflector

  • Loading branch information...
1 parent bbaf7da commit 4401c04d95e2098be15e6ba952c43b343a7ea0bf Micah Cooper and Travis Anderson committed with Hashrocket Workstation Sep 27, 2012
Showing with 14 additions and 3 deletions.
  1. +2 −2 lib/decent_exposure/inflector.rb
  2. +12 −1 spec/decent_exposure/inflector_spec.rb
@@ -19,11 +19,11 @@ def parameter
end
def singular
- original.parameterize
+ original.demodulize.parameterize
end
def plural
- original.pluralize
+ original.demodulize.pluralize
end
alias collection plural
@@ -19,7 +19,7 @@ class Fox; end
end
end
- describe "#plural" do
+ describe "#plural?" do
let(:inflector) { DecentExposure::Inflector.new(name) }
subject { inflector.plural? }
@@ -33,4 +33,15 @@ class Fox; end
it { should be_false }
end
end
+
+ describe "#singular" do
+ let(:inflector) { DecentExposure::Inflector.new(name) }
+
+ context "with a namespaced name" do
+ let(:name) { "Content::Page" }
+ it "returns a demodulized parameterized string" do
+ inflector.singular.should == "page"
+ end
+ end
+ end
end

0 comments on commit 4401c04

Please sign in to comment.