Sha256: 8471e5ecc41560c616987355a13918c4966c1fd711a46bdf4b24a768042ec764

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

require "spec_helper"

describe Mblox::SmsResponse::Result do
  describe "code" do
    it "cannot be blank" do
      result = described_class.new(nil, "123")
      result.valid?
      result.errors[:code].should include("Code cannot be blank")
    end

    it "must be a number" do
      result = described_class.new('abc', "123")
      result.valid?
      result.errors[:code].should include("Code must be an integer")
    end

    it "must be an integer" do
      result = described_class.new(3.14159, "123")
      result.valid?
      result.errors[:code].should include("Code must be an integer")
    end
  end

  describe "text" do
    it "cannot be blank" do
      result = described_class.new(0, '')
      result.valid?
      result.errors[:text].should include("Text cannot be blank")
    end
  end

  describe "is_ok?" do
    it "is true for code 0" do
      described_class.new(0, "123").is_ok?.should be_true
    end

    10.times do |i|
      it "is false for code #{i+1}" do
        described_class.new(i+1, "123").is_ok?.should be_false
      end
    end
  end

  describe "==" do
    it "should be true if code and text are the same" do
      lhs = described_class.new(0, 'OK')
      rhs = described_class.new(0, 'OK')
      (lhs == rhs).should be_true
    end

    it "should be false if code does not match" do
      lhs = described_class.new(0, 'OK')
      rhs = described_class.new(4, 'OK')
      (lhs == rhs).should be_false
    end
    it "should be false if text does not match" do
      lhs = described_class.new(0, 'OK')
      rhs = described_class.new(0, '__OK__')
      (lhs == rhs).should be_false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mblox-0.1.0 spec/sms_response_result_spec.rb