Browse files

Merge pull request #58 from syntaxritual/demodulize

Demodulize singular and plural keys in inflector
  • Loading branch information...
2 parents bbaf7da + 4401c04 commit c88ad339e8d6778bf2df8a3dcd84c5f14ad1da1f @voxdolo voxdolo committed 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
View
4 lib/decent_exposure/inflector.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
View
13 spec/decent_exposure/inflector_spec.rb
@@ -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 c88ad33

Please sign in to comment.