Sha256: 45f27a4e6b8cb0a52db4d961c2354a23d1783f9dfb2a4386deeaceaa2e827c1d

Contents?: true

Size: 834 Bytes

Versions: 1

Compression:

Stored size: 834 Bytes

Contents

require File.dirname(__FILE__) + '/spec_helper'

class User < ActiveRecord::Base
  attr_accessible :first_name, :last_name, :username
  suggestions_for :username
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
    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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
username_suggester-0.1.0 spec/suggestions_for_spec.rb