Sha256: e0fbe99c6cf0e6b2debebdd7d5130c709ab8774b91ada89588eb62377c7f830c
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
require File.dirname(__FILE__) + '/spec_helper' class User < ActiveRecord::Base attr_accessible :first_name, :last_name, :username suggestions_for :username, :exclusion => ['luk'] end describe UsernameSuggester::UsernameSuggestions do before(:each) do @user = User.new(:first_name => "Jerry", :last_name => "Luk") end it "should able to suggest usernames" do suggestions = @user.username_suggestions suggestions.should_not be_blank suggestions.should include "jerry" end it "should able to suggest usernames that are not taken" do UsernameSuggester::Suggester.send(:define_method, :rand) { 1 } User.create!(:username => "jerry") 1.upto(10) do |i| User.create!(:username => "jerry#{i}") end suggestions = @user.username_suggestions suggestions.should_not be_blank suggestions.should_not include "jerry" suggestions.should include "jerry11" end it "should not suggest usernames in the exclusion list" do UsernameSuggester::Suggester.send(:define_method, :rand) { 1 } suggestions = @user.username_suggestions suggestions.should_not be_blank suggestions.should_not include "luk" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
username_suggester-0.2.2 | spec/suggestions_for_spec.rb |