spec/learn_test/git_spec.rb in learn-test-3.2.1.pre.6 vs spec/learn_test/git_spec.rb in learn-test-3.2.1.pre.7
- old
+ new
@@ -5,31 +5,38 @@
let!(:working_branch) { 'develop' }
let!(:git_url) { 'https://github.com/learn-co/learn-test' }
let!(:git_base) { instance_double(Git::Base) }
+ let(:wait_thr) { double }
+ let(:wait_thr_value) { double }
+ let(:stdout_and_stderr) { double }
+
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(subject).to receive(:`).with(/learn-test-wip save ".+" -u &> \/dev\/null/ )
- expect($?).to receive(:success?).and_return(true)
+ expect(wait_thr).to receive(:value).and_return(wait_thr_value)
+ expect(wait_thr_value).to receive(:exitstatus).and_return(0)
- expect(git_base).to receive(:push).with('origin', "wip/#{working_branch}:refs/heads/wip")
- expect(git_base).to receive_message_chain(:config, :[]).with('remote.origin.url').and_return("#{git_url}.git")
+ 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")
end
end
context 'failure' do
it 'should return false on process error' do
- allow(Git::Base).to receive(:open).and_return(git_base)
- allow(git_base).to receive(:current_branch)
- allow(subject).to receive(:`)
+ 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($?).to receive(:success?).and_return(false)
+ expect(wait_thr).to receive(:value).and_return(wait_thr_value)
+ expect(wait_thr_value).to receive(:exitstatus).and_return(1)
+
+ expect(Open3).to receive(:popen3).and_yield(nil, nil, nil, wait_thr)
+
expect(subject.run!).to eq(false)
end
it 'should return false on StandardError' do
expect(Git::Base).to receive(:open).and_raise(StandardError)