Sha256: 6ccf576aba9902cab017ea66f612f39262c018d7eae2e9dac466e75a1bb2e16e

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

describe 'Yapper syncing documents' do
  extend WebStub::SpecHelpers

  before do
    class Document
      include Yapper::Document
      include Yapper::Sync

      field :field_1
      sync :to => '/api/documents', :auto => [:get, :save]

      def sync_as
        image = Yapper::Sync::Data.new(:data => UIImagePNGRepresentation(UIImage.alloc.init),
                                       :fileName => 'file.png',
                                       :mimeType => 'image/png')
        {
          :field_1 => field_1,
          :image   => image
        }
      end
    end
  end
  before { Yapper::Sync.base_url = 'http://example.com' }
  before { disable_network_access! }
  after  { enable_network_access! }
  after  { Yapper::DB.purge }
  after  { Object.send(:remove_const, 'Document') }

  # TODO Webstub is not straighforward as body is not known at stub time
  # it 'on create' do
    # stub_request(:get, "http://example.com/api/documents").
      # with(:body => { document: { field_1: 'text' } }).
      # to_return(:json => { document: { field_1: 'text' } })

    # document = Document.create(:field_1 => 'text')

    # wait 2

    # document.reload
    # document._synced_at.should.not == nil
  # end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
motion-yapper-0.0.1 spec/integration/sync_spec.rb