Skip to content

Commit

Permalink
#3 Support shortname
Browse files Browse the repository at this point in the history
  • Loading branch information
torrocus committed Aug 7, 2013
1 parent fe9d848 commit 91a9c36
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/user_fullname/model.rb
Expand Up @@ -29,6 +29,10 @@ def lastname=(value)
update_fullname
end

def shortname
"#{firstname[0]}.#{lastname}"
end

private
def update_fullname
send(:fullname=, [@firstname, @lastname].join(' '))
Expand Down
2 changes: 1 addition & 1 deletion lib/user_fullname/version.rb
@@ -1,3 +1,3 @@
module UserFullname
VERSION = "0.0.1"
VERSION = "0.0.2"
end
2 changes: 2 additions & 0 deletions spec/user_fullname/model_spec.rb
Expand Up @@ -42,6 +42,7 @@ def initialize(fullname = nil)
let(:firstname) { rand_name }
let(:lastname) { rand_name }
let(:fullname) { [firstname, lastname].join(' ') }
let(:shortname) { "#{firstname[0]}.#{lastname}" }
subject { DummyClass.new(fullname) }

# its(:fullname) { should eq(fullname) }
Expand All @@ -55,5 +56,6 @@ def initialize(fullname = nil)
subject.fullname = "#{firstname} "
should eq("")
end
its(:shortname) { should eq(shortname) }
end
end

0 comments on commit 91a9c36

Please sign in to comment.