Sha256: b559b1dcd9aa13370ce16a6bc3c382c415669507ba0fde693a486ce9ea17e26d

Contents?: true

Size: 943 Bytes

Versions: 16

Compression:

Stored size: 943 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

16 entries across 16 versions & 1 rubygems

Version Path
lhs-15.3.1 spec/item/becomes_spec.rb
lhs-15.3.1.pre.fixlhc.1 spec/item/becomes_spec.rb
lhs-15.3.0 spec/item/becomes_spec.rb
lhs-15.2.5 spec/item/becomes_spec.rb
lhs-15.2.4 spec/item/becomes_spec.rb
lhs-15.2.3 spec/item/becomes_spec.rb
lhs-15.2.3.pre.favorites.1 spec/item/becomes_spec.rb
lhs-15.2.2.pre.favorites.1 spec/item/becomes_spec.rb
lhs-15.2.2 spec/item/becomes_spec.rb
lhs-15.2.1 spec/item/becomes_spec.rb
lhs-15.2.0 spec/item/becomes_spec.rb
lhs-15.1.1 spec/item/becomes_spec.rb
lhs-15.1.0 spec/item/becomes_spec.rb
lhs-15.0.2 spec/item/becomes_spec.rb
lhs-15.0.1 spec/item/becomes_spec.rb
lhs-15.0.0 spec/item/becomes_spec.rb