title: rspec shoulda matchers with friendly id custom slug not working
body: <p>I have a model with custom slug with friendly id:</p>
  
  <pre><code># == Schema Information
  #
  # Table name: blogs
  #
  #  id               :integer          not null, primary key
  #  title            :string           not null
  #  content          :text             not null
  #  is_published     :boolean          default("false"), not null
  #  slug             :string
  #  publishing_date  :datetime
  #  tags             :text             default("{}"), not null, is an Array
  #  meta_keywords    :text             default("{}"), not null, is an Array
  #  meta_description :text
  #  page_title       :string(70)
  #  author_id        :integer          default("1")
  #  blog_category_id :integer          default("1")
  #  author_type      :integer          default("0"), not null
  #  created_at       :datetime         not null
  #  updated_at       :datetime         not null
  #
  
  class Blog &lt; ActiveRecord::Base
    enum author_type: [:content_contributor]
    enum publishing_status: [:reviewing, :accepted, :rejected]
    include FriendlyId
    friendly_id :title_and_category, use: [:slugged, :history]
    has_attached_file :featured_image,  styles: { large: '600x600&gt;', medium: '300x300&gt;',  thumb: '100x100&gt;' }, default_url: 'No_image.jpg.png'
    validates_attachment_content_type :featured_image,  content_type: /\Aimage\/.*\Z/
    belongs_to :author, class_name: 'ContentContributor', foreign_key: 'author_id', inverse_of: :blogs
    belongs_to :featured_product, class_name: 'Product', foreign_key: 'featured_product_id', inverse_of: :blogs
    belongs_to :blog_category, inverse_of: :blogs
    belongs_to :deleted_by, class_name: 'User', foreign_key: 'deleted_by_id'
    validates :author, presence: true
    validates :author_type, presence: true
    validates :title, presence: true
    validates :content, presence: true
    validates :tags, presence: true
    validates :meta_keywords, presence: true
  
    def title_and_category
      "#{blog_category.name} #{title}"
    end
  end
  </code></pre>
  
  <p>I have written spec for the model like this:</p>
  
  <pre><code>it { should define_enum_for(:author_type) }
    it { should define_enum_for(:publishing_status) }
    it { should belong_to(:author).class_name("ContentContributor").with_foreign_key("author_id").inverse_of(:blogs) }
    it { should belong_to(:featured_product).class_name("Product").with_foreign_key("featured_product_id").inverse_of(:blogs) }
    it { should belong_to(:deleted_by).class_name("User").with_foreign_key("deleted_by_id") }
    it { should belong_to(:blog_category).inverse_of(:blogs) }
    it { should validate_presence_of(:author) }
    it { should validate_presence_of(:author_type) }
    it { should validate_presence_of(:title) }
    it { should validate_presence_of(:content) }
    it { should validate_presence_of(:tags) }
    it { should validate_presence_of(:meta_keywords) }
  </code></pre>
  
  <p>The above fails with the following errors:</p>
  
  <p>Failures:</p>
  
  <pre><code>  1) Blog should require author to be set
       Failure/Error: it { should validate_presence_of(:author) }
       NoMethodError:
         undefined method `name' for nil:NilClass
       # ./app/models/blog.rb:41:in `title_and_category'
       # ./spec/models/blog_spec.rb:33:in `block (2 levels) in &lt;top (required)&gt;'
  
    2) Blog should require author_type to be set
       Failure/Error: it { should validate_presence_of(:author_type) }
       NoMethodError:
         undefined method `name' for nil:NilClass
       # ./app/models/blog.rb:41:in `title_and_category'
       # ./spec/models/blog_spec.rb:34:in `block (2 levels) in &lt;top (required)&gt;'
  
    3) Blog should require title to be set
       Failure/Error: it { should validate_presence_of(:title) }
       NoMethodError:
         undefined method `name' for nil:NilClass
       # ./app/models/blog.rb:41:in `title_and_category'
       # ./spec/models/blog_spec.rb:35:in `block (2 levels) in &lt;top (required)&gt;'
  
    4) Blog should require content to be set
       Failure/Error: it { should validate_presence_of(:content) }
       NoMethodError:
         undefined method `name' for nil:NilClass
       # ./app/models/blog.rb:41:in `title_and_category'
       # ./spec/models/blog_spec.rb:36:in `block (2 levels) in &lt;top (required)&gt;'
  
    5) Blog should require tags to be set
       Failure/Error: it { should validate_presence_of(:tags) }
       NoMethodError:
         undefined method `name' for nil:NilClass
       # ./app/models/blog.rb:41:in `title_and_category'
       # ./spec/models/blog_spec.rb:37:in `block (2 levels) in &lt;top (required)&gt;'
  
    6) Blog should require meta_keywords to be set
       Failure/Error: it { should validate_presence_of(:meta_keywords) }
       NoMethodError:
         undefined method `name' for nil:NilClass
       # ./app/models/blog.rb:41:in `title_and_category'
       # ./spec/models/blog_spec.rb:38:in `block (2 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p>I removed the code for custom name building and all the above passed but not with custom slug built. What should be changed?</p>