Skip to content

Commit

Permalink
Started adding regression spec(s)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvjones89 committed Jun 4, 2017
1 parent c683d1b commit 6249598
Showing 1 changed file with 34 additions and 19 deletions.
53 changes: 34 additions & 19 deletions spec/sheldon/brain_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,36 +53,52 @@
end

describe "#forget" do
before(:each) do
brain.learn("my git config", abs_learn_path)
brain.recall("my git config")
end
context "for a cue that's recalled on the local host" do

it "should delete the entry from Sheldon's memory" do
expect(memory.has_cue?("my git config")).to be true
brain.forget("my git config")
expect(memory.has_cue?("my git config")).to be false
end
before(:each) do
brain.learn("my git config", abs_learn_path)
brain.recall("my git config")
end

it "should delete the memorised file/folder from Sheldon's brain" do
expect(File).to exist(abs_brain_path)
brain.forget("my git config")
expect(File).not_to exist(abs_brain_path)
it "should delete the entry from Sheldon's memory" do
expect(memory.has_cue?("my git config")).to be true
brain.forget("my git config")
expect(memory.has_cue?("my git config")).to be false
end


it "should delete the memorised file/folder from Sheldon's brain" do
expect(File).to exist(abs_brain_path)
brain.forget("my git config")
expect(File).not_to exist(abs_brain_path)
end

it "should purge any broken symlinks from the local filesystem" do
expect(File).to be_symlink("spec/Users/test/dotfiles/.gitconfig")
expect(FileUtils).to receive(:rm_r).twice
brain.forget("my git config")
expect(File).not_to be_symlink("spec/Users/test/dotfiles/.gitconfig")
end
end

it "should purge any broken symlinks from the user's filesystem" do
expect(File).to be_symlink("spec/Users/test/dotfiles/.gitconfig")
brain.forget("my git config")
expect(File).not_to be_symlink("spec/Users/test/dotfiles/.gitconfig")
context "for a cue that is NOT recalled on the local host" do
before(:each) do
brain.learn("my git config", abs_learn_path)
end

it "should NOT attempt to delete any symlinks from the local filesystem" do
brain.forget("my git config")
expect(FileUtils).to receive(:rm_r).once
end
end
end


describe "#recalled?" do
context "for a file that has been recalled" do
it "should return true" do
brain.learn("my git config", abs_learn_path)
brain.recall("my git config")
expect(brain.recalled?("my git config")).to be true
end
end

Expand Down Expand Up @@ -125,5 +141,4 @@
brain.list_cues
end
end

end

0 comments on commit 6249598

Please sign in to comment.