-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
default_file_spec.rb
45 lines (36 loc) · 1.43 KB
/
default_file_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true
require "./test/helper"
# Since this touches the ~/friends.md file instead of a temp
# one, we only want to run it on our CI servers.
if ENV["TRAVIS"] == "true"
describe "default filename behavior" do
let(:filename) { File.expand_path("~/friends.md") }
after { File.delete(filename) }
# Since the filename is the system-wide one, we can't have
# more than one test that touches it, because multiple
# tests can run in parallel and might stomp on one another.
# Instead, we just run one test that exercises a lot.
# This test specifically checks for regressions akin to
# https://github.com/JacobEvelyn/friends/issues/231
it "creates a new file and adds to it multiple times" do
# File does not exist at first.
value(File.exist?(filename)).must_equal false
`bundle exec bin/friends add friend Mohandas Karamchand Gandhi`
`bundle exec bin/friends add friend Sojourner Truth`
`bundle exec bin/friends add activity 1859-11-30: Lunch with **Harriet Tubman** in _Auburn_.`
`bundle exec bin/friends add note "1851-05-29: Sojourner Truth's speech"`
value(File.read(filename)).must_equal <<-FILE
### Activities:
- 1859-11-30: Lunch with **Harriet Tubman** in _Auburn_.
### Notes:
- 1851-05-29: **Sojourner Truth**'s speech
### Friends:
- Harriet Tubman
- Mohandas Karamchand Gandhi
- Sojourner Truth
### Locations:
- Auburn
FILE
end
end
end