Sha256: 0ba825c328c0c30ac98d42e3601784aa4986d6db9ddf5b82a321762ead8e7d91

Contents?: true

Size: 698 Bytes

Versions: 4

Compression:

Stored size: 698 Bytes

Contents

require 'spec_helper'

describe "README Features" do
  describe "Errors" do
    let(:item_list) { ExampleCom::ItemList.new(name: 'My list') }

    it "exposes ActiveModel::Errors object" do
      expect(item_list.errors).to be_kind_of(ActiveModel::Errors)
    end

    it "loads errors from remote response" do
      stub_request(*create_item_list_request).to_return(response_with_errors)
      item_list.save

      expect(item_list.errors[:items]).to eq(["can not be empty"])
    end

    def response_with_errors
      {
        status: 422,
        body: { 
          name: "My list",
          errors: {
            items: ["can not be empty"]
          },
        }
      }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
signaling-1.1.2 spec/integration/readme_features/errors_spec.rb
signaling-1.1.1 spec/integration/readme_features/errors_spec.rb
signaling-1.1.0 spec/integration/readme_features/errors_spec.rb
signaling-1.0.0 spec/integration/readme_features/errors_spec.rb