summaryrefslogtreecommitdiff
path: root/spec/ruby/core/data/define_spec.rb
blob: abfdd3e6a768ffd88242cee48afdf6c5ff386dfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require_relative '../../spec_helper'
require_relative 'fixtures/classes'

ruby_version_is "3.2" do
  describe "Data.define" 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 a mix of strings and symbols" do
      blockbuster_movie = Data.define("title", :year, "genre")
      blockbuster_movie.members.should == [:title, :year, :genre]
    end
  end
end