aboutsummaryrefslogtreecommitdiffstats
path: root/spec/lib/model_attribute_spec.rb
diff options
context:
space:
mode:
authorTeddy Wing2017-09-22 12:11:41 +0200
committerTeddy Wing2017-09-22 12:11:41 +0200
commit9179af1df905ff9980228d2aa0ba77418f2781aa (patch)
tree4cc86f11fb885b86671bf7d222e7c7b86835dc69 /spec/lib/model_attribute_spec.rb
parent198659b133aba39cdd92d37fd3b93a223159994b (diff)
downloadchouette-core-9179af1df905ff9980228d2aa0ba77418f2781aa.tar.bz2
ModelAttribute: Add `.methods_by_class_and_type` method
This enables filtering by class like `.methods_by_class` and additionally only selecting attributes matching a certain data type. Refs #4401
Diffstat (limited to 'spec/lib/model_attribute_spec.rb')
-rw-r--r--spec/lib/model_attribute_spec.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/lib/model_attribute_spec.rb b/spec/lib/model_attribute_spec.rb
index 2da178d2c..faea0b483 100644
--- a/spec/lib/model_attribute_spec.rb
+++ b/spec/lib/model_attribute_spec.rb
@@ -31,6 +31,21 @@ RSpec.describe ModelAttribute do
end
end
+ describe ".methods_by_class_and_type" do
+ it "returns ModelAttributes of a certain class and type" do
+ ModelAttribute.instance_variable_set(:@__all__, [
+ ModelAttribute.new(:route, :name, :string),
+ ModelAttribute.new(:route, :checked_at, :date),
+ ModelAttribute.new(:journey_pattern, :name, :string),
+ ModelAttribute.new(:journey_pattern, :section_status, :integer)
+ ])
+
+ expect(ModelAttribute.methods_by_class_and_type(:route, :string)).to match_array([
+ ModelAttribute.new(:route, :name, :string)
+ ])
+ end
+ end
+
describe "#code" do
it "returns a string representation of the attribute" do
model_attr = ModelAttribute.new(:route, :name, :string)