Sha256: 27bef0ed68aa7c7c07793b4c8f1816a1e9d8868530ab8b4d90b3e71ada240e94

Contents?: true

Size: 1.83 KB

Versions: 1

Compression:

Stored size: 1.83 KB

Contents

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

shared_examples_for "Any transient" do
  it "should be Transient" do
    @instance.should respond_to(:effective_at)
    @instance.should respond_to(:expiring_at)
    @instance.should respond_to(:effective_through)
    @instance.should respond_to(:permanent?)
    @instance.should respond_to(:effective?)
    @instance.should respond_to(:expired?)
  end

  it "should report permanence" do
    @instance.effective_at = DateTime.beginning_of
    @instance.expiring_at = DateTime.end_of

    @instance.should be_permanent
    @instance.should be_effective
    @instance.should be_current
    @instance.should_not be_expired
    @instance.should_not be_past
    @instance.should_not be_future
  end

  it "should report temporariness" do
    @instance.effective_at = 5.minutes.ago
    @instance.expiring_at = 5.minutes.from_now

    @instance.should_not be_permanent
    @instance.should be_effective
    @instance.should be_current
    @instance.should_not be_expired
    @instance.should_not be_past
    @instance.should_not be_future
  end

  it "should report expiration" do
    @instance.effective_at = 10.minutes.ago
    @instance.expiring_at = 5.minutes.ago

    @instance.should_not be_permanent
    @instance.should_not be_effective
    @instance.should be_expired
  end

  it "should report upcomingness" do
    @instance.effective_at = 5.minutes.from_now
    @instance.expiring_at = 10.minutes.from_now

    @instance.should_not be_permanent
    @instance.should_not be_effective
    @instance.should_not be_current
    @instance.should_not be_expired
    @instance.should_not be_past
    @instance.should be_future
  end

  it "should invoke callbacks around expire!" do
    @instance.should_receive(:before_expire!)
    @instance.should_receive(:after_expire!)
    @instance.expire!
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
transient-1.0.0 spec/transient_shared_spec.rb