Sha256: 08c9adc27c38a8a9454ab5f32b725def0eb8678db74778d1a25aa1c714343c0a

Contents?: true

Size: 1.71 KB

Versions: 8

Compression:

Stored size: 1.71 KB

Contents

# frozen_string_literal: true

require "./test/helper"

clean_describe "remove tag" do
  subject { run_cmd("remove tag #{friend_name} #{tag}") }

  let(:content) { CONTENT }

  describe "when friend name has no matches" do
    let(:friend_name) { "Garbage" }
    let(:tag) { "science" }

    it "prints an error message" do
      stderr_only 'Error: No friend found for "Garbage"'
    end
  end

  describe "when friend name has more than one match" do
    let(:friend_name) { "George" }
    let(:tag) { "science" }
    before { run_cmd("add friend George Harrison") }

    it "prints an error message" do
      stderr_only 'Error: More than one friend found for "George": '\
                  "George Harrison, George Washington Carver"
    end
  end

  describe "when friend name has one match" do
    let(:friend_name) { "Marie" }

    describe "when tag is not present on friend" do
      let(:tag) { "garbage" }
      it "prints an error message" do
        stderr_only 'Error: Tag "@garbage" not found for "Marie Curie"'
      end
    end

    describe "when tag is present on friend" do
      let(:tag) { "science" }

      it "removes tag from friend" do
        line_changed "- Marie Curie [Atlantis] @science", "- Marie Curie [Atlantis]"
      end

      it "prints an output message" do
        stdout_only 'Tag removed from friend: "Marie Curie [Atlantis]"'
      end

      describe "when tag is passed with @" do
        let(:tag) { "@science" }

        it "adds tag to friend" do
          line_changed "- Marie Curie [Atlantis] @science", "- Marie Curie [Atlantis]"
        end

        it "prints an output message" do
          stdout_only 'Tag removed from friend: "Marie Curie [Atlantis]"'
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
friends-0.36 test/commands/remove/tag_spec.rb
friends-0.35 test/commands/remove/tag_spec.rb
friends-0.34 test/commands/remove/tag_spec.rb
friends-0.33 test/commands/remove/tag_spec.rb
friends-0.32 test/commands/remove/tag_spec.rb
friends-0.31 test/commands/remove/tag_spec.rb
friends-0.30 test/commands/remove/tag_spec.rb
friends-0.29 test/commands/remove/tag_spec.rb