Sha256: 59049d4dd5ee0f3027df86c20e3519c40579d00c9c618dbadca62620b87f5693
Contents?: true
Size: 996 Bytes
Versions: 16
Compression:
Stored size: 996 Bytes
Contents
require "spec_helper" describe Pliny::CanonicalLogLineHelpers do class TestCanonicalLogLine include Pliny::CanonicalLogLineHelpers log_field :field_float, Float log_field :field_integer, Integer log_field :field_string, String end it "allows a field to be set" do line = TestCanonicalLogLine.new line.field_string = "foo" end it "allows nils to be set" do line = TestCanonicalLogLine.new line.field_string = nil end it "rejects values that are of the wrong type" do line = TestCanonicalLogLine.new e = assert_raises ArgumentError do line.field_string = true end assert_equal "Expected field_string to be type String (was TrueClass)", e.message end it "produces a hash with #to_h" do line = TestCanonicalLogLine.new line.field_float = 3.14 line.field_integer = 42 line.field_string = "foo" assert_equal({ field_float: 3.14, field_integer: 42, field_string: "foo" }, line.to_h) end end
Version data entries
16 entries across 16 versions & 1 rubygems