Sha256: a6239c7418dce82028ae336f0e1f4a6f5fe72b8ae309335aa51d27d9813603de

Contents?: true

Size: 956 Bytes

Versions: 4

Compression:

Stored size: 956 Bytes

Contents

# -*- encoding : utf-8 -*-
require 'spec_helper'

describe "Exchange::Helper" do
  subject { Exchange::Helper }
  describe "assure_time" do
    before(:each) do
      time = Time.now
      Time.stub! :now => time
    end
    context "with a time object" do
      it "should return that time object" do
        Exchange::Helper.assure_time(Time.now - 3400).should == Time.now - 3400
      end
    end
    context "with a string" do
      it "should send to Time.gm" do
        Time.should_receive(:gm).with('2011','09','09').once.and_return('TIME')
        Exchange::Helper.assure_time('2011-09-09').should == 'TIME'
      end
    end
    context "with nil" do
      it "should return nil if no default is defined" do
        Exchange::Helper.assure_time(nil).should be_nil
      end
      it "should return the default if the default is defined" do
        Exchange::Helper.assure_time(nil, :default => :now).should == Time.now
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
exchange-1.1.0 spec/exchange/helper_spec.rb
exchange-1.0.4 spec/exchange/helper_spec.rb
exchange-1.0.2 spec/exchange/helper_spec.rb
exchange-1.0.0 spec/exchange/helper_spec.rb