Sha256: e5eed18b908bd1cc4a7d594bb44e9b961d42fbfcf60797ee975f5f9c1d200165

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

require File.expand_path('../spec_helper', __FILE__)

module Danger
  describe Danger::DangerLgtm do
    it 'should be a plugin' do
      expect(Danger::DangerLgtm.new(nil)).to be_a Danger::Plugin
    end

    #
    # You should test your custom attributes and methods here
    #
    describe 'with Dangerfile' do
      before do
        @dangerfile = testing_dangerfile
        @lgtm = @dangerfile.lgtm
      end

      # Some examples for writing tests
      # You should replace these with your own.

      it 'lgtm with no violation' do
        @lgtm.check_lgtm
        expect(@dangerfile.status_report[:markdowns].length).to eq(1)
      end

      it 'pick random pic from lgtm.in' do
        mock = double(
          :[] => 'https://lgtm.in/p/sSuI4hm0q',
          body: JSON.generate(
            actualImageUrl: 'https://example.com/image.jpg'
          )
        )

        allow(Net::HTTP).to receive(:start).and_return(mock)

        @lgtm.check_lgtm

        expect(@dangerfile.status_report[:markdowns][0].message)
          .to match(%r{https:\/\/example.com\/image.jpg})
      end

      it 'use given url' do
        @lgtm.check_lgtm image_url: 'http://imgur.com/Irk2wyX.jpg'
        expect(@dangerfile.status_report[:markdowns][0].message)
          .to match(%r{http:\/\/imgur\.com\/Irk2wyX\.jpg})
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danger-lgtm-0.2.0 spec/lgtm_spec.rb