Sha256: 17aad5210bb65dad0afe59ee0041d9f05c793ce8be67146fb7ee8886008e7c85

Contents?: true

Size: 941 Bytes

Versions: 30

Compression:

Stored size: 941 Bytes

Contents

require 'rails_helper'

describe LHS::Item do
  before(:each) do
    class Location < LHS::Record
      endpoint 'http://sync/locations'
      endpoint 'http://sync/locations/:id'
    end

    class Synchronization < LHS::Record
      endpoint 'http://sync/locations/:id/sync'
    end

    stub_request(:get, "http://sync/locations/1")
      .to_return(body: {
        id: 1,
        name: 'localsearch'
      }.to_json)

    stub_request(:post, "http://sync/locations/1/sync")
      .with(body: {
        name: 'localsearch'
      }.to_json)
      .to_return(status: 201)
  end

  context 'convert records from class A to class B' do
    it "becomes a record of another class" do
      location = Location.find(1)
      synchronization = location.becomes(Synchronization)
      expect(synchronization).to be_kind_of(Synchronization)
      synchronization.save!
      expect(synchronization).to be_kind_of(Synchronization)
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
lhs-14.6.5 spec/item/becomes_spec.rb
lhs-14.6.4 spec/item/becomes_spec.rb
lhs-14.6.3 spec/item/becomes_spec.rb
lhs-14.6.2 spec/item/becomes_spec.rb
lhs-14.6.1 spec/item/becomes_spec.rb
lhs-14.6.0 spec/item/becomes_spec.rb
lhs-14.5.0 spec/item/becomes_spec.rb
lhs-14.4.0 spec/item/becomes_spec.rb
lhs-14.3.4 spec/item/becomes_spec.rb
lhs-14.3.3 spec/item/becomes_spec.rb
lhs-14.3.2 spec/item/becomes_spec.rb
lhs-14.3.1 spec/item/becomes_spec.rb
lhs-14.3.0 spec/item/becomes_spec.rb
lhs-14.2.0 spec/item/becomes_spec.rb
lhs-14.1.1 spec/item/becomes_spec.rb
lhs-14.1.0 spec/item/becomes_spec.rb
lhs-14.0.3 spec/item/becomes_spec.rb
lhs-14.0.2 spec/item/becomes_spec.rb
lhs-14.0.1 spec/item/becomes_spec.rb
lhs-14.0.0 spec/item/becomes_spec.rb