aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2017-09-19 15:39:37 +0200
committerTeddy Wing2017-09-19 16:12:55 +0200
commit2f555897bff3f8fa6dd5e9e0c6d48f0073edc349 (patch)
tree330d0e36000cefd4265bf211b2ad7131f31af187
parent8e8cfa6c52ff8fc2a655b768db5baafed40c1a2d (diff)
downloadchouette-core-2f555897bff3f8fa6dd5e9e0c6d48f0073edc349.tar.bz2
ModelAttribute spec: Allow test to handle existing elements in `@@all`
When `ModelAttribute` instances are added to `@@all` directly in the class, the test breaks. Make it a little more robust by checking change in array size instead of total size. Refs #4401
-rw-r--r--lib/model_attribute.rb2
-rw-r--r--spec/lib/model_attribute_spec.rb8
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/model_attribute.rb b/lib/model_attribute.rb
index be5caea94..b1297d43d 100644
--- a/lib/model_attribute.rb
+++ b/lib/model_attribute.rb
@@ -14,4 +14,6 @@ class ModelAttribute
@name = name
@data_type = data_type
end
+
+ define :journey_pattern, :name, :string
end
diff --git a/spec/lib/model_attribute_spec.rb b/spec/lib/model_attribute_spec.rb
index 88d3997b6..da767cfed 100644
--- a/spec/lib/model_attribute_spec.rb
+++ b/spec/lib/model_attribute_spec.rb
@@ -1,11 +1,11 @@
RSpec.describe ModelAttribute do
describe ".define" do
it "adds a new instance of ModelAttribute to @@all" do
- ModelAttribute.define(:route, :name, :string)
+ expect do
+ ModelAttribute.define(:route, :name, :string)
+ end.to change { ModelAttribute.all.length }.by(1)
- expect(ModelAttribute.all.length).to eq(1)
-
- model_attr = ModelAttribute.all.first
+ model_attr = ModelAttribute.all.last
expect(model_attr).to be_an_instance_of(ModelAttribute)
expect(model_attr.klass).to eq(:route)