Sha256: 58f0f5e45bafc4b38a79c6418d18bbb01371aaba3f11f0911da21dfce0aae145

Contents?: true

Size: 828 Bytes

Versions: 5

Compression:

Stored size: 828 Bytes

Contents

require "spec_helper"

RSpec.describe SmsAero::Future do
  subject { described_class[source] }

  context "time in future:" do
    let(:source) { Time.now + 3600 }

    it "returns UNIX time in seconds" do
      expect(subject).to eq source.to_i.to_s
    end
  end

  context "parseable string for time in future:" do
    let(:time)   { Time.now + 3600 }
    let(:source) { time.strftime "%Y-%m-%d %H:%M:%S" }

    it "returns UNIX time in seconds" do
      expect(subject).to eq time.to_i.to_s
    end
  end

  context "time in the past:" do
    let(:source) { Time.now - 3600 }

    it "fails" do
      expect { subject }.to raise_error(StandardError)
    end
  end

  context "not a time:" do
    let(:source) { "foobar" }

    it "fails" do
      expect { subject }.to raise_error(StandardError, /foobar/)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sms_aero-0.2.0 spec/models/future_spec.rb
sms_aero-0.1.3 spec/models/future_spec.rb
sms_aero-0.1.2 spec/models/future_spec.rb
sms_aero-0.1.1 spec/models/future_spec.rb
sms_aero-0.1.0 spec/models/future_spec.rb