Sha256: 2afa5124f4198bba06dd58f02fc90f4e3b8e97151ab1751d358ea52ebb788e92

Contents?: true

Size: 856 Bytes

Versions: 2

Compression:

Stored size: 856 Bytes

Contents

require 'spec_helper'

describe Banyan::BanyanModel do
  let(:timestamp) { 1.day.ago }
  subject { FactoryGirl.create :banyan_model, :updated_at => timestamp }

  it                      { should be_valid }
  its('categories.class') { should eql(Array) }
  its(:categories)        { should be_empty }

  context "with category created" do
    let(:category) { FactoryGirl.create :banyan_category }

    before do
      subject.categories << category
      subject.reload
    end

    its(:categories) { should include(category) }
    its(:updated_at) { should be > timestamp }
    it "should be visible from category" do
      category.banyan_model_categorizations.should include(subject)
    end

    it "should return only one instance of a category" do
      subject.categories << category
      subject.categories.should have(1).item
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
banyan-1.1.1 spec/banyan/banyan_model_spec.rb
banyan-1.0.1 spec/banyan/banyan_model_spec.rb