test/add_event_helper.rb in friends-0.37 vs test/add_event_helper.rb in friends-0.38

- old
+ new

@@ -49,10 +49,22 @@ def description_parsing_specs(test_stdout: true) describe "description parsing" do let(:date) { Date.today.strftime } + unless test_stdout + describe "when description is blank" do + let(:description) { " " } + + it "prints an error message" do + subject[:stderr].must_equal( + ensure_trailing_newline_unless_empty("Error: Blank #{event} not added") + ) + end + end + end + describe "when description includes a friend's full name (case insensitive)" do let(:description) { "Lunch with grace hopper." } it { line_added "- #{date}: Lunch with **Grace Hopper**." } if test_stdout @@ -273,10 +285,39 @@ if test_stdout it { stdout_only "#{capitalized_event} added: \"#{date}: Grace Hopper! Grace Hopper!!!\"" } end end + describe "when description has a friend's full name which is another friend's first name" do + let(:description) { "Hung out with Elizabeth for most of the day." } + + # Make sure "Elizabeth II" is a better friend than just "Elizabeth" to + # ensure our result isn't due to chance. + let(:content) do + <<-FILE +### Activities: +- 2018-08-05: Royal picnic with **Elizabeth II**. + +### Notes: + +### Friends: +- Elizabeth +- Elizabeth II + +### Locations: +FILE + end + + it { line_added "- #{date}: Hung out with **Elizabeth** for most of the day." } + if test_stdout + it do + stdout_only "#{capitalized_event} added: \"#{date}: "\ + "Hung out with Elizabeth for most of the day.\"" + end + end + end + describe "when description has a name with multiple friend matches" do describe "when there is useful context from past activities" do let(:description) { "Met John + Elizabeth." } # Create a past activity in which Elizabeth Cady Stanton did something @@ -370,9 +411,10 @@ end end end def parsing_specs(event:) + let(:event) { event.to_s } let(:capitalized_event) { event.to_s.capitalize } describe "when given a date and a description in the command" do subject { run_cmd("add #{event} #{date}: #{description}") }