aboutsummaryrefslogtreecommitdiffstats
path: root/spec/lib/model_attribute_spec.rb
diff options
context:
space:
mode:
authorTeddy Wing2017-09-19 15:39:37 +0200
committerTeddy Wing2017-09-19 16:12:55 +0200
commit2f555897bff3f8fa6dd5e9e0c6d48f0073edc349 (patch)
tree330d0e36000cefd4265bf211b2ad7131f31af187 /spec/lib/model_attribute_spec.rb
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
Diffstat (limited to 'spec/lib/model_attribute_spec.rb')
-rw-r--r--spec/lib/model_attribute_spec.rb8
1 files changed, 4 insertions, 4 deletions
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)