Sha256: acd35325cf080a25c3faf254e6db2fb793131b449cb04a2df12e31abcc83d82c

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 KB

Contents

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

module Danger
  describe Danger::DangerJazzy do
    it 'should be a plugin' do
      expect(Danger::DangerJazzy.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
        @my_plugin = @dangerfile.jazzy
        @default_message = 'Undocumented symbol.'
      end

      context 'changed files contains undocumented symbols' do
        before do
          modified = Git::Diff::DiffFile.new(
            'base',
            path:  'OldFile.swift',
            patch: '- //old'
          )
          added = Git::Diff::DiffFile.new(
            'base',
            path:  'MyFile.swift',
            patch: '+ //new'
          )

          allow(@dangerfile.git).to receive(:diff_for_file)
            .with('OldFile.swift').and_return(modified)

          allow(@dangerfile.git).to receive(:diff_for_file)
            .with('MyFile.swift').and_return(added)

          allow(@dangerfile.git).to receive(:modified_files)
            .and_return(['OldFile.swift'])

          allow(@dangerfile.git).to receive(:added_files)
            .and_return(['MyFile.swift'])
        end

        it 'Warns on undocumented symbols' do
          @my_plugin.path_to_docs = 'spec/fixtures'
          @my_plugin.warn_of_undocumented
          expect(@dangerfile.status_report[:warnings]).to eq([@default_message])
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danger-jazzy-0.1.1 spec/jazzy_spec.rb