Sha256: 624871f72b3c015b9dc75dcc59e23f3f89f67e591c42f0126c8bea538a5fec3f

Contents?: true

Size: 730 Bytes

Versions: 25

Compression:

Stored size: 730 Bytes

Contents

require 'spec_helper'

describe Resource::Serialization::Boolean do
  [true,  "true",  "TRUE",  "1", 1, 1.0, "x", "X", "t", "T"].each do |true_value|
    context "when value is #{true_value}" do
      it "returns true" do
        subject.class.serialize(true_value).should be_true
      end
    end
  end

  [false, "false", "FALSE", "0", 0, 0.0,  "", " ", "f", "F", nil].each do |false_value|
    context "when value is #{false_value}" do
      it "returns false" do
        subject.class.serialize(false_value).should be_false
      end
    end
  end

  context "when an invalid value is serialized" do
    it "raises an error" do
      expect {subject.class.serialize("neither true or false")}.to raise_error
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
transcriber-0.0.26 spec/unit/resource/serialization/boolean_spec.rb
transcriber-0.0.25 spec/unit/resource/serialization/boolean_spec.rb
transcriber-0.0.24 spec/unit/resource/serialization/boolean_spec.rb
transcriber-0.0.23 spec/unit/resource/serialization/boolean_spec.rb
transcriber-0.0.22 spec/unit/resource/serialization/boolean_spec.rb
transcriber-0.0.21 spec/unit/resource/serialization/boolean_spec.rb
transcriber-0.0.20 spec/unit/resource/serialization/boolean_spec.rb
transcriber-0.0.19 spec/unit/resource/serialization/boolean_spec.rb
transcriber-0.0.18 spec/unit/resource/serialization/boolean_spec.rb
transcriber-0.0.17 spec/unit/resource/serialization/boolean_spec.rb
transcriber-0.0.16 spec/unit/resource/serialization/boolean_spec.rb
transcriber-0.0.15 spec/unit/resource/serialization/boolean_spec.rb
transcriber-0.0.14 spec/unit/resource/serialization/boolean_spec.rb
transcriber-0.0.13 spec/unit/resource/serialization/boolean_spec.rb
transcriber-0.0.12 spec/unit/resource/serialization/boolean_spec.rb
transcriber-0.0.11 spec/unit/resource/serialization/boolean_spec.rb
transcriber-0.0.10 spec/unit/resource/serialization/boolean_spec.rb
transcriber-0.0.9 spec/unit/resource/serialization/boolean_spec.rb
transcriber-0.0.8 spec/unit/resource/serialization/boolean_spec.rb
transcriber-0.0.7 spec/unit/resource/serialization/boolean_spec.rb