spec/pgit/current_project_spec.rb in pgit-0.0.3 vs spec/pgit/current_project_spec.rb in pgit-0.0.4
- old
+ new
@@ -1,6 +1,6 @@
-require 'pgit'
+require 'spec_helper'
# .edderic-dotfiles/config.yml
# projects
# - path: ~/Therapy-Exercises-Online
# id: 12345
# api_token: asoeuhot
@@ -20,28 +20,27 @@
fake_configuration = double('configuration', to_yaml: fake_yaml)
end
describe 'PGit::CurrentProject' do
describe '#new(config_yaml)' do
- describe 'none of the projects listed matches the working directory' do
- it 'should throw an error' do
- error_message = "None of the project paths matches the working directory"
- fake_project_1 = { "path" => "~/some-non-matching-path",
- "id" => 12345,
- "api_token" => "astoeuh" }
- fake_project_2 = { "path" => "~/some-other-non-matching-path",
- "id" => 19191,
- "api_token" => "astoeuh" }
- fake_project_list = [ fake_project_1, fake_project_2 ]
- fake_yaml = { "projects" => fake_project_list }
- fake_pwd = "/Therapy-Exercises-Online/some_other_project/some_subdirectory"
- fake_configuration = double('configuration', to_yaml: fake_yaml)
- allow(Dir).to receive(:pwd).and_return(fake_pwd)
+ it 'should delegate to PGit::CurrentProject::Validator' do
+ fake_project_1 = { "path" => "~/some-non-matching-path",
+ "id" => 12345,
+ "api_token" => "astoeuh" }
+ fake_project_2 = { "path" => "~/some-other-non-matching-path",
+ "id" => 19191,
+ "api_token" => "astoeuh" }
+ fake_project_list = [ fake_project_1, fake_project_2 ]
+ fake_yaml = { "projects" => fake_project_list }
+ fake_pwd = "/Therapy-Exercises-Online/some_other_project/some_subdirectory"
+ fake_configuration = double('configuration', to_yaml: fake_yaml)
+ allow(Dir).to receive(:pwd).and_return(fake_pwd)
+ allow(PGit::CurrentProject::Validator).to receive(:new).with []
- expect{ PGit::CurrentProject.new(fake_configuration.to_yaml) }.to raise_error(error_message)
- end
- end
+ PGit::CurrentProject.new(fake_configuration.to_yaml)
+ expect(PGit::CurrentProject::Validator).to have_received(:new).with []
+ end
end
describe '#pwd' do
describe 'more than one of the projects listed matches the working directory' do
it "should return the more specific directory" do