spec/learn_test/git_spec.rb in learn-test-3.2.4 vs spec/learn_test/git_spec.rb in learn-test-3.3.0.pre.1
- old
+ new
@@ -1,47 +1,53 @@
# frozen_string_literal: true
-describe LearnTest::GitWip do
- subject { described_class }
+describe LearnTest::Git do
+ describe '.open' do
+ context 'defaults' do
+ it 'should instantiate LearnTest::Git::Base' do
+ expect(LearnTest::Git::Base).to receive(:open).with('./', {})
+ LearnTest::Git.open
+ end
+ end
- let!(:working_branch) { 'develop' }
- let!(:git_url) { 'https://github.com/learn-co/learn-test' }
- let!(:git_base) { instance_double(Git::Base) }
+ context 'with options' do
+ it 'should instantiate LearnTest::Git::Base' do
+ directory = './foo'
+ options = { logger: false }
- let(:wait_thr) { double }
- let(:wait_thr_value) { double }
- let(:stdout_and_stderr) { double }
+ expect(LearnTest::Git::Base).to receive(:open).with(directory, options)
- context 'success' do
- it 'should return the git url' do
- expect(Git::Base).to receive(:open).with('./', { log: false }).and_return(git_base)
- expect(git_base).to receive(:current_branch).and_return(working_branch)
-
- expect(wait_thr).to receive(:value).and_return(wait_thr_value)
- expect(wait_thr_value).to receive(:exitstatus).and_return(0)
-
- expect(Open3).to receive(:popen3).and_yield(nil, nil, nil, wait_thr)
-
- expect(git_base).to receive_message_chain(:config, :[]).with('remote.origin.url').and_return("#{git_url}.git")
- expect(subject.run!).to eq("#{git_url}/tree/wip")
+ LearnTest::Git.open(
+ directory: directory,
+ options: options
+ )
+ end
end
end
- context 'failure' do
- it 'should return false on process error' do
- expect(Git::Base).to receive(:open).with('./', { log: false }).and_return(git_base)
- expect(git_base).to receive(:current_branch).and_return(working_branch)
+ describe LearnTest::Git::Base do
+ it 'should inherit from ::Git::Base' do
+ expect(LearnTest::Git::Base).to be < ::Git::Base
+ end
- expect(wait_thr).to receive(:value).and_return(wait_thr_value)
- expect(wait_thr_value).to receive(:exitstatus).and_return(1)
+ describe '#wip' do
+ let!(:repo) { described_class.open('./') }
+ let!(:message) { 'FooBar' }
+ let!(:wip) { double(LearnTest::Git::Wip::Base) }
- expect(Open3).to receive(:popen3).and_yield(nil, nil, nil, wait_thr)
+ it 'should require a :message' do
+ expect { repo.wip }.to raise_error(ArgumentError)
+ end
- expect(subject.run!).to eq(false)
- end
+ it 'should instantiate and run .process!' do
+ expect(LearnTest::Git::Wip::Base)
+ .to receive(:new)
+ .with(base: repo, message: message)
+ .and_return(wip)
- it 'should return false on StandardError' do
- expect(Git::Base).to receive(:open).and_raise(StandardError)
- expect(subject.run!).to eq(false)
+ expect(wip).to receive(:process!)
+
+ expect(repo.wip(message: message)).to eq(wip)
+ end
end
end
end