aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/model_attribute.rb4
-rw-r--r--spec/lib/model_attribute_spec.rb8
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/model_attribute.rb b/lib/model_attribute.rb
index 081d0cd0f..22c366b37 100644
--- a/lib/model_attribute.rb
+++ b/lib/model_attribute.rb
@@ -55,4 +55,8 @@ class ModelAttribute
# Chouette::RoutingConstraintZone
define :routing_constraint_zone, :name, :string
+
+ def code
+ "#{@klass}##{@name}"
+ end
end
diff --git a/spec/lib/model_attribute_spec.rb b/spec/lib/model_attribute_spec.rb
index da767cfed..ad1dd863f 100644
--- a/spec/lib/model_attribute_spec.rb
+++ b/spec/lib/model_attribute_spec.rb
@@ -13,4 +13,12 @@ RSpec.describe ModelAttribute do
expect(model_attr.data_type).to eq(:string)
end
end
+
+ describe "#code" do
+ it "returns a string representation of the attribute" do
+ model_attr = ModelAttribute.new(:route, :name, :string)
+
+ expect(model_attr.code).to eq('route#name')
+ end
+ end
end