Sha256: e63c89099f506736eaab67859b5aa1487e3e7534635e3fe25ea22a1427448c9e

Contents?: true

Size: 1.58 KB

Versions: 49

Compression:

Stored size: 1.58 KB

Contents

module Ddr::Models
  RSpec.describe AdminSet, ddr_aux: true do

    describe ".call" do
      let(:obj) { Item.new }

      describe "when the object has an admin set" do
        before { obj.admin_set = "dvs" }
        describe "and the admin set code is found" do
          before {
            allow(described_class).to receive(:get).with(:find, code: "dvs") {
              {"id"=>1, "code"=>"dvs", "title"=>"Data and Visualization Services", "created_at"=>"2015-09-15T16:15:58.514Z", "updated_at"=>"2015-09-15T16:15:58.514Z"}
            }
          }
          it "returns an AdminSet instance" do
            expect(described_class.call(obj)).to be_a(described_class)
          end
        end
        describe "and the admin set is not found" do
          before {
            allow(described_class).to receive(:get).with(:find, code: "dvs")
                                       .and_raise(ActiveResource::ResourceNotFound, "404")
          }
          it "raises an exception" do
            expect { described_class.call(obj) }.to raise_error(Ddr::Models::NotFoundError)
          end
        end
      end

      describe "when the object does not have an admin set" do
        it "returns nil" do
          expect(described_class.call(obj)).to be_nil
        end
      end
    end

    describe "instance methods" do
      subject { described_class.new("id"=>1, "code"=>"dvs", "title"=>"Data and Visualization Services", "created_at"=>"2015-09-15T16:15:58.514Z", "updated_at"=>"2015-09-15T16:15:58.514Z") }
      its(:to_s) { is_expected.to eq("Data and Visualization Services") }
    end

  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
ddr-models-2.4.2 spec/models/admin_set_spec.rb
ddr-models-3.0.0.beta.4 spec/models/admin_set_spec.rb
ddr-models-2.4.1 spec/models/admin_set_spec.rb
ddr-models-2.4.0 spec/models/admin_set_spec.rb
ddr-models-2.4.0.rc6 spec/models/admin_set_spec.rb
ddr-models-2.4.0.rc5 spec/models/admin_set_spec.rb
ddr-models-2.4.0.rc4 spec/models/admin_set_spec.rb
ddr-models-2.4.0.rc3 spec/models/admin_set_spec.rb
ddr-models-2.4.0.rc2 spec/models/admin_set_spec.rb