Sha256: 1c20f4e837e9de5da4b893093a3890833d9559939362aacc33ac72e7b54bbd2d

Contents?: true

Size: 1.79 KB

Versions: 10

Compression:

Stored size: 1.79 KB

Contents

require 'test_helper'

class InstagramTest < ActiveSupport::TestCase
  def setup
    @harvester = Lentil::InstagramHarvester.new
  end

  test "Instagram images should be added to Image model without duplication" do
    VCR.use_cassette('instagram_by_tag') do
      instagram_metadata = @harvester.fetch_recent_images_by_tag "huntlibrary"
      @harvester.save_instagram_load instagram_metadata
      assert_raise DuplicateImageError do
        @harvester.save_instagram_load! instagram_metadata
      end
    end
  end

  test "OEmbed should return image ID" do
    image = lentil_images(:uno)
    VCR.use_cassette('instagram_oembed') do
      oembed_data = @harvester.retrieve_oembed_data_from_url(image.url)
      assert_equal(image.external_identifier,oembed_data.fields["media_id"])
    end
  end

  test "Individual images should be saved" do
    VCR.use_cassette('instagram_image_id') do
      instagram_metadata = @harvester.fetch_image_by_id("289998623568090948_31727100")
      @harvester.save_instagram_load instagram_metadata

      assert(Lentil::Image.where(:external_identifier => "289998623568090948_31727100").first.url.length > 1)
    end
  end

  test "Should be able to harvest image data" do
    image = lentil_images(:one)
    VCR.use_cassette('instagram_image_harvest') do
      image_data = @harvester.harvest_image_data(image)
      assert(!image_data.blank?)
    end
  end

  test "Existing image should pass data retrieval check" do
    image = lentil_images(:one)
    VCR.use_cassette('instagram_good_image_check') do
      assert(@harvester.test_remote_image(image))
    end
  end

  test "Nonexistent image should fail data retrieval check" do
    image = lentil_images(:tres)
    VCR.use_cassette('instagram_bad_image_check') do
      assert(!@harvester.test_remote_image(image))
    end
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
lentil-0.1.8 test/unit/lentil/instagram_test.rb
lentil-0.1.7 test/unit/lentil/instagram_test.rb
lentil-0.1.6 test/unit/lentil/instagram_test.rb
lentil-0.1.3 test/unit/lentil/instagram_test.rb
lentil-0.1.2 test/unit/lentil/instagram_test.rb
lentil-0.1.1 test/unit/lentil/instagram_test.rb
lentil-0.1.0 test/unit/lentil/instagram_test.rb
lentil-0.0.3.pre test/unit/lentil/instagram_test.rb
lentil-0.0.2.pre test/unit/lentil/instagram_test.rb
lentil-0.0.1.pre test/unit/lentil/instagram_test.rb