aboutsummaryrefslogtreecommitdiffstats
path: root/spec/lib/model_attribute_spec.rb
diff options
context:
space:
mode:
authorTeddy Wing2017-09-22 12:25:36 +0200
committerTeddy Wing2017-09-22 12:25:36 +0200
commit404b143af9ed49912e1e0065c832639188aa87de (patch)
tree1cb3060bb7bb7d7531818946d423897c0ceff701 /spec/lib/model_attribute_spec.rb
parent9179af1df905ff9980228d2aa0ba77418f2781aa (diff)
downloadchouette-core-404b143af9ed49912e1e0065c832639188aa87de.tar.bz2
ModelAttribute: Add `.classes` method
This allows people to get a list of the classes defined in `ModelAttribute`. The classes are turned into constant-cased strings. Not sure if that's useful, but this is how it was described in the ticket. Refs #4401
Diffstat (limited to 'spec/lib/model_attribute_spec.rb')
-rw-r--r--spec/lib/model_attribute_spec.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/lib/model_attribute_spec.rb b/spec/lib/model_attribute_spec.rb
index faea0b483..9e10bf40f 100644
--- a/spec/lib/model_attribute_spec.rb
+++ b/spec/lib/model_attribute_spec.rb
@@ -14,6 +14,22 @@ RSpec.describe ModelAttribute do
end
end
+ describe ".classes" do
+ it "returns the list of classes of ModelAttributes in .all" do
+ ModelAttribute.instance_variable_set(:@__all__, [
+ ModelAttribute.new(:route, :name, :string),
+ ModelAttribute.new(:journey_pattern, :name, :string),
+ ModelAttribute.new(:time_table, :start_date, :date)
+ ])
+
+ expect(ModelAttribute.classes).to match_array([
+ 'Route',
+ 'JourneyPattern',
+ 'TimeTable'
+ ])
+ end
+ end
+
describe ".methods_by_class" do
it "returns all ModelAttributes for a given class" do
ModelAttribute.instance_variable_set(:@__all__, [