Sha256: a9d9f14ef18696360c716918a3fdc457c336aa9337626b250fb3313ffcb3e2f4

Contents?: true

Size: 1.6 KB

Versions: 49

Compression:

Stored size: 1.6 KB

Contents

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

    describe ".call" do
      describe "when the slug is found" do
        before {
          allow(described_class).to receive(:get).with(:find, slug: "abc") {
            {"id"=>1, "slug"=>"abc", "name"=>"A, B, and C Services", "short_name"=>"ABCS",
             "url"=>"http://library.inst.edu/abc", "phone"=>"555-1234", "email"=>"abc@library.inst.edu",
             "ask"=>"http://library.inst.edu/abc-ask", "created_at"=>"2015-09-15T16:15:58.514Z",
             "updated_at"=>"2015-09-15T16:15:58.514Z"}
          }
        }
        it "returns a Contact instance" do
          expect(described_class.call("abc")).to be_a(described_class)
        end
      end
      describe "when the slug is not found" do
        before {
          allow(described_class).to receive(:get).with(:find, slug: "abc")
                                     .and_raise(ActiveResource::ResourceNotFound, "404")
        }
        it "raises an exception" do
          expect { described_class.call("abc") }.to raise_error(Ddr::Models::NotFoundError)
        end
      end
    end

    describe "instance methods" do
      subject {
        described_class.new(
          "id"=>1, "slug"=>"abc", "name"=>"A, B, and C Services", "short_name"=>"ABCS",
          "url"=>"http://library.inst.edu/abc", "phone"=>"555-1234", "email"=>"abc@library.inst.edu",
          "ask"=>"http://library.inst.edu/abc-ask", "created_at"=>"2015-09-15T16:15:58.514Z",
          "updated_at"=>"2015-09-15T16:15:58.514Z"
        )
      }
      its(:to_s) { is_expected.to eq("A, B, and C Services") }
    end

  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
ddr-models-2.4.11 spec/models/contact_spec.rb
ddr-models-3.0.8 spec/models/contact_spec.rb
ddr-models-3.0.7 spec/models/contact_spec.rb
ddr-models-3.0.6 spec/models/contact_spec.rb
ddr-models-3.0.5 spec/models/contact_spec.rb
ddr-models-3.0.4 spec/models/contact_spec.rb
ddr-models-3.0.3 spec/models/contact_spec.rb
ddr-models-3.0.2 spec/models/contact_spec.rb
ddr-models-3.0.1 spec/models/contact_spec.rb
ddr-models-3.0.0 spec/models/contact_spec.rb
ddr-models-3.0.0.rc6 spec/models/contact_spec.rb
ddr-models-3.0.0.rc5 spec/models/contact_spec.rb
ddr-models-3.0.0.rc4 spec/models/contact_spec.rb
ddr-models-3.0.0.rc3 spec/models/contact_spec.rb
ddr-models-3.0.0.rc2 spec/models/contact_spec.rb
ddr-models-3.0.0.rc1 spec/models/contact_spec.rb
ddr-models-3.0.0.beta.22 spec/models/contact_spec.rb
ddr-models-3.0.0.beta.21 spec/models/contact_spec.rb
ddr-models-2.4.10 spec/models/contact_spec.rb
ddr-models-3.0.0.beta.20 spec/models/contact_spec.rb