spec/unit/plugin/associates_spec.rb in rom-sql-1.3.5 vs spec/unit/plugin/associates_spec.rb in rom-sql-2.0.0.beta1

- old
+ new

@@ -16,14 +16,10 @@ let(:join_relation) do instance_double(ROM::SQL::Relation) end - let(:registry) do - Hash.new { |h, k| h.fetch(k.to_sym) }.update(posts: posts, tags: tags) - end - let(:command_class) do Class.new(ROM::SQL::Commands::Create) do use :associates, tags: [] end end @@ -31,26 +27,25 @@ let(:associations) do Hash.new { |h, k| h.fetch(k.to_sym) }.update(posts: posts_assoc) end let(:tags_assoc) do - ROM::SQL::Association::ManyToMany.new(:posts, :tags, through: :posts_tags) + ROM::SQL::Associations::ManyToMany.new(double(:definition).as_null_object, {}) end let(:posts_assoc) do - ROM::SQL::Association::ManyToMany.new(:tags, :posts, through: :posts_tags) + ROM::SQL::Associations::ManyToMany.new(double(:definition).as_null_object, {}) end before do - allow(posts).to receive(:__registry__).and_return(registry) - allow(associations).to receive(:try).and_yield(tags_assoc) + allow(associations).to receive(:[]).and_return(tags_assoc) allow(tags_assoc).to receive(:join_keys).and_return({}) end shared_context 'associates result' do it 'inserts join tuples and returns child tuples with combine keys' do - expect(tags_assoc).to receive(:persist).with(registry, post_tuples, tag_tuples) - expect(tags_assoc).to receive(:parent_combine_keys).with(registry).and_return(%i[name tag]) + expect(tags_assoc).to receive(:persist).with(post_tuples, tag_tuples) + expect(tags_assoc).to receive(:parent_combine_keys).and_return(%i[name tag]) result = command.associate(post_tuples, tag_tuples, assoc: tags_assoc, keys: {}) expect(result). to match_array([