Sha256: 19a75675165ef4b02887463219e10162f06ac3dfb2a1ccc4beb6f6a32ec423d9

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

require "helper"

describe Gasoline::Drop do

  describe "basic setup" do
    before do
      @drop = Gasoline::Drop.new("Fire", "http://water.com", "Burn")
    end

    it "should have a name" do
      assert_equal "Fire", @drop.name
    end

    it "should have a url" do
      assert_equal "http://water.com", @drop.url
    end

    it "should have a description" do
      assert_equal "Burn", @drop.description
    end
  end

  describe "loading from hash" do
    before do
      @h = {
      :name => "Fire",
      :url => "http://water.com",
      :description => "Desc"
      }
      @drop = Gasoline::Drop.new_from_yml(@h)
    end

    [:name, :url, :description].each do |s|
      it "should have a #{s}" do
        assert_equal @h[s], @drop.send(s)
      end
    end
  end

  describe "getting the content" do
    before do
      @url = "https://gist.github.com/3258692"
      @drop = Gasoline::Drop.new("xyz", @url, "zyx")
    end

    it "should get the raw gist url" do
      assert_equal "https://raw.github.com/gist/3258692", @drop.raw_gist_url
    end

    it "should set header with name" do
      assert_match "xyz", @drop.header
    end

    it "should set header with description" do
      assert_match "zyx", @drop.description
    end

    it "should return nil if there was any error fetching it" do
      @drop.stubs(:download_content).raises(StandardError, 'some error probably 404')
      assert_nil @drop.patch
    end

    it "should try to download when asked for patch" do
      @drop.expects(:download_content).returns("ZE JS CONTENT")
      assert_match "ZE JS", @drop.patch
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gasoline-0.0.2 test/drop_test.rb