From be6634dc3f6bbbae2baa2c566308563117eac24d Mon Sep 17 00:00:00 2001 From: yui-knk Date: Sat, 24 Oct 2015 16:59:34 +0900 Subject: [PATCH] Add test cases which validate results of defined scope --- .../active_record_persistence_multiple_spec.rb | 13 +++++++++++++ .../persistence/active_record_persistence_spec.rb | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/spec/unit/persistence/active_record_persistence_multiple_spec.rb b/spec/unit/persistence/active_record_persistence_multiple_spec.rb index f76963d..0bd5bf9 100644 --- a/spec/unit/persistence/active_record_persistence_multiple_spec.rb +++ b/spec/unit/persistence/active_record_persistence_multiple_spec.rb @@ -298,6 +298,19 @@ describe "named scopes with the new DSL" do it "does not create scopes if requested" do expect(MultipleNoScope).not_to respond_to(:pending) end + + context "result of scope" do + let!(:dsl1) { MultipleSimpleNewDsl.create!(status: :new) } + let!(:dsl2) { MultipleSimpleNewDsl.create!(status: :unknown_scope) } + + after do + MultipleSimpleNewDsl.destroy_all + end + + it "created scope works as where(name: :scope_name)" do + expect(MultipleSimpleNewDsl.unknown_scope).to contain_exactly(dsl2) + end + end end # scopes describe "direct assignment" do diff --git a/spec/unit/persistence/active_record_persistence_spec.rb b/spec/unit/persistence/active_record_persistence_spec.rb index d480cb5..455c4a4 100644 --- a/spec/unit/persistence/active_record_persistence_spec.rb +++ b/spec/unit/persistence/active_record_persistence_spec.rb @@ -299,6 +299,18 @@ describe "named scopes with the new DSL" do expect(NoScope).not_to respond_to(:pending) end + context "result of scope" do + let!(:dsl1) { SimpleNewDsl.create!(status: :new) } + let!(:dsl2) { SimpleNewDsl.create!(status: :unknown_scope) } + + after do + SimpleNewDsl.destroy_all + end + + it "created scope works as where(name: :scope_name)" do + expect(SimpleNewDsl.unknown_scope).to contain_exactly(dsl2) + end + end end # scopes describe "direct assignment" do