Sha256: 77c2a599c3ac1e78b80f698dc30a725f983a35e8a20d025ad46c0dd114f1dac2

Contents?: true

Size: 867 Bytes

Versions: 27

Compression:

Stored size: 867 Bytes

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))

describe Castronaut::Models::Consumeable do
  
  class FakeModel
    include Castronaut::Models::Consumeable

    attr_accessor :consumed_at, :id
    
    def save!
      
    end
  end
  
  describe "consume!" do
  
    it "sets consumed to the current time" do
      fake_model = stub_model(FakeModel).as_new_record
      fake_model.should_receive(:consumed_at=)
      fake_model.consume!
    end
    
    it "calls save!" do
      fake_model = stub_model(FakeModel).as_new_record
      fake_model.should_receive(:save!)
      fake_model.consume!
    end
  
  end
  
  it "is consumed when consumed_at has a value" do
    fake_model = FakeModel.new
    fake_model.should_not be_consumed
    
    fake_model.consumed_at = Time.now
    fake_model.should be_consumed
  end
  
end

Version data entries

27 entries across 27 versions & 6 rubygems

Version Path
relevance-castronaut-0.5.4 spec/castronaut/models/consumeable_spec.rb
relevance-castronaut-0.6.0 spec/castronaut/models/consumeable_spec.rb
relevance-castronaut-0.6.1 spec/castronaut/models/consumeable_spec.rb
relevance-castronaut-0.7.4 spec/castronaut/models/consumeable_spec.rb
relevance-castronaut-0.7.5 spec/castronaut/models/consumeable_spec.rb
nbudin-castronaut-0.7.5 spec/castronaut/models/consumeable_spec.rb
factorylabs-castronaut-0.7.5 spec/castronaut/models/consumeable_spec.rb