Skip to content

Commit

Permalink
Add test coverage for parsing aliases (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjwp authored Jul 8, 2020
1 parent 689e140 commit 37aaebf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
16 changes: 16 additions & 0 deletions spec/avro/builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@
end

it { is_expected.to be_json_eql(expected.to_json) }

it "sets aliases for the type", :aliases do
expect(schema.aliases).to eq(['Foo', 'Bar'])
end
end

context "enum with symbols splat" do
Expand Down Expand Up @@ -455,6 +459,10 @@
end

it { is_expected.to be_json_eql(expected.to_json) }

it "sets aliases for the schema", :aliases do
expect(schema.aliases).to eq(['MoreThanSix'])
end
end

context "fixed type with type_aliases via block" do
Expand Down Expand Up @@ -1966,6 +1974,10 @@
end

it { is_expected.to be_json_eql(expected.to_json) }

it "sets an alias for the record", :aliases do
expect(schema.aliases).to eq(['LinkedLongs'])
end
end

context "a field with aliases and a type with aliases" do
Expand Down Expand Up @@ -2001,6 +2013,10 @@
end

it { is_expected.to be_json_eql(expected.to_json) }

it "sets aliases for fields", :aliases do
expect(schema.fields.first.aliases).to eq(['field_alias'])
end
end

context "doc option on field" do
Expand Down
9 changes: 9 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
end

enum_default_supported = Avro::Schema::EnumSchema.instance_methods.include?(:default)
aliases_supported = Avro::Schema::NamedSchema.instance_methods.include?(:aliases)

config.around(:each, :enum_default) do |example|
# The Avro gem does not correctly set a version :(
Expand All @@ -28,4 +29,12 @@
skip "enum_default not supported by this Avro version"
end
end

config.around(:each, :aliases) do |example|
if aliases_supported
example.run
else
skip "aliases not supported by this Avro version"
end
end
end

0 comments on commit 37aaebf

Please sign in to comment.