Sha256: efa880a833d9377e1474e1622cdf9f6c245e5023f37f48701df2fbed8f9de808

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

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

module Danger
  describe Danger::DiffTodoFinder do
    let(:subject) { Danger::DiffTodoFinder.new }

    describe "#find_diffs_containing_todos" do
      %w(TODO TODO: todo todo: FIXME fixme FIXME: fixme).each do |marker|
        it "identifies a new '#{marker}' as a todo" do
          diffs = [
            Git::Diff::DiffFile.new(
              "base",
              path:  "some/file.rb",
              patch: "+ #{marker} some todo"
            )
          ]

          todos = subject.find_diffs_containing_todos(diffs)

          expect(todos).to_not be_empty
        end
      end

      it "does not identify removed todos as a todo" do
        diffs = [
          Git::Diff::DiffFile.new(
            "base",
            path:  "some/file.rb",
            patch: "- TODO: some todo"
          )
        ]

        todos = subject.find_diffs_containing_todos(diffs)

        expect(todos).to be_empty
      end

      [
        "+ class TodosController",
        "+ function foo(todo) {",
        "+ def todo()"
      ].each do |patch|
        it "does not identify occurences in e.g. a new class name" do
          diffs = [
            Git::Diff::DiffFile.new(
              "base",
              path:  "some/file.rb",
              patch: patch
            )
          ]

          todos = subject.find_diffs_containing_todos(diffs)

          expect(todos).to be_empty
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danger-todoist-0.0.3 spec/diff_todo_finder_spec.rb