Sha256: 44c3042dd8f7ac9f25a9d1da8e70612aff594bde90348a0974ee5e60531bf8ba

Contents?: true

Size: 1.88 KB

Versions: 27

Compression:

Stored size: 1.88 KB

Contents

# frozen_string_literal: true

require "./test/helper"

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

  let(:content) { CONTENT }

  describe "when friend name has no matches" do
    let(:friend_name) { "Garbage" }
    let(:nickname) { "'Amazing Grace'" }

    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(:nickname) { "'Amazing Grace'" }
    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) { "Grace" }

    describe "when nickname is not present on friend" do
      let(:nickname) { "Gracie" }
      it "prints an error message" do
        stderr_only 'Error: Nickname "Gracie" not found for "Grace Hopper"'
      end
    end

    describe "when nickname is present on friend" do
      let(:nickname) { "'Amazing Grace'" }

      it "removes nickname from friend" do
        line_changed(
          "- Grace Hopper (a.k.a. The Admiral a.k.a. Amazing Grace) [Paris] @navy @science",
          "- Grace Hopper (a.k.a. The Admiral) [Paris] @navy @science"
        )
      end

      it "removes parenthetical from file when friend has no more nicknames" do
        run_cmd("remove nickname #{friend_name} 'The Admiral'")
        line_changed(
          "- Grace Hopper (a.k.a. Amazing Grace) [Paris] @navy @science",
          "- Grace Hopper [Paris] @navy @science"
        )
      end

      it "prints an output message" do
        stdout_only 'Nickname removed: "Grace Hopper (a.k.a. The Admiral) [Paris] @navy @science"'
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
friends-0.55 test/commands/remove/nickname_spec.rb
friends-0.54 test/commands/remove/nickname_spec.rb
friends-0.53 test/commands/remove/nickname_spec.rb
friends-0.52 test/commands/remove/nickname_spec.rb
friends-0.51 test/commands/remove/nickname_spec.rb
friends-0.50 test/commands/remove/nickname_spec.rb
friends-0.49 test/commands/remove/nickname_spec.rb
friends-0.48 test/commands/remove/nickname_spec.rb
friends-0.47 test/commands/remove/nickname_spec.rb
friends-0.46 test/commands/remove/nickname_spec.rb
friends-0.45 test/commands/remove/nickname_spec.rb
friends-0.44 test/commands/remove/nickname_spec.rb
friends-0.43 test/commands/remove/nickname_spec.rb
friends-0.42 test/commands/remove/nickname_spec.rb
friends-0.41 test/commands/remove/nickname_spec.rb
friends-0.40 test/commands/remove/nickname_spec.rb
friends-0.39 test/commands/remove/nickname_spec.rb
friends-0.38 test/commands/remove/nickname_spec.rb
friends-0.37 test/commands/remove/nickname_spec.rb
friends-0.36 test/commands/remove/nickname_spec.rb