Sha256: 00bcbaf7f9c6710966d779e601ebd438de4d8ca4f65bc6f335e873f9be4fdbdf

Contents?: true

Size: 1.53 KB

Versions: 3

Compression:

Stored size: 1.53 KB

Contents

require 'helper'

class TestFile < Test::Unit::TestCase
  def setup
    Parse.init
  end

  def test_file_save
    VCR.use_cassette('test_text_file_save', :record => :new_episodes) do
      tf = Parse::File.new({
        :body => "Hello World!", 
        :local_filename => "hello.txt", 
        :content_type => "text/plain"
      })
      tf.save

      assert tf.local_filename
      assert tf.url
      assert tf.parse_filename
      assert tf.body
      assert tf.to_json
      assert_equal String, tf.body.class
    end
  end

  def test_image_save
    #VCR.use_cassette('test_image_file_save', :record => :new_episodes) do
      tf = Parse::File.new({
        :body => IO.read("test/parsers.jpg"), 
        :local_filename => "parsers.jpg", 
        :content_type => "image/jpeg"
      })
      tf.save

      assert tf.local_filename
      assert tf.url
      assert tf.parse_filename
      assert tf.body
      assert tf.to_json
    #end
  end

  def test_associate_with_object
    #VCR.use_cassette('test_image_file_associate_with_object', :record => :new_episodes) do
      tf = Parse::File.new({
        :body => IO.read("test/parsers.jpg"), 
        :local_filename => "parsers.jpg", 
        :content_type => "image/jpeg"
      })
      tf.save

      assert tf.local_filename
      assert tf.url
      assert tf.parse_filename
      assert tf.body
      assert tf.to_json

      object = Parse::Object.new("ShouldHaveFile")
      object["photo"] = tf
      object.save

      assert object["photo"]
      assert object["objectId"]
    #end
  end


end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
parse-ruby-client-0.1.14 test/test_file.rb
parse-ruby-client-0.1.13 test/test_file.rb
parse-ruby-client-0.1.12 test/test_file.rb