Skip to content

Commit

Permalink
add spec for Data.define
Browse files Browse the repository at this point in the history
  • Loading branch information
lxxxvi committed Jan 11, 2023
1 parent 2cdba6f commit 4a03d70
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions core/data/define_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'

ruby_version_is "3.2" do
describe "Data.define" do
describe "stored as constant" do
it "accepts no arguments" do
EmptyData = Data.define
EmptyData.members.should == []
EmptyData.inspect.should == "EmptyData"
end

it "accepts symbols" do
MovieWithSymbol = Data.define(:title, :year)
MovieWithSymbol.members.should == [:title, :year]
MovieWithSymbol.inspect.should == "MovieWithSymbol"
end

it "accepts strings" do
MovieWithString = Data.define("title", "year")
MovieWithString.members.should == [:title, :year]
MovieWithString.inspect.should == "MovieWithString"
end

it "accepts first argument as string" do
BlockbusterMovie = Data.define("Blockbuster", :title, :year)
BlockbusterMovie.members.should == [:title, :year]
BlockbusterMovie.inspect.should == "Data::Blockbuster"
end
end

describe "stored as variable" do
it "accepts no arguments" do
empty_data = Data.define
empty_data.members.should == []
end

it "accepts symbols" do
movie_with_symbol = Data.define(:title, :year)
movie_with_symbol.members.should == [:title, :year]
end

it "accepts strings" do
movie_with_string = Data.define("title", "year")
movie_with_string.members.should == [:title, :year]
end

it "accepts first argument as string" do
blockbuster_movie = Data.define("Blockbuster", :title, :year)
blockbuster_movie.members.should == [:title, :year]
end
end
end
end

0 comments on commit 4a03d70

Please sign in to comment.