Commit c8df6bcf authored by Ash McKenzie's avatar Ash McKenzie

Fix some rspec deprecations

parent f2eb95f0
...@@ -17,19 +17,19 @@ describe GitlabAccess do ...@@ -17,19 +17,19 @@ describe GitlabAccess do
end end
subject do subject do
GitlabAccess.new(nil, repo_path, 'key-123', 'wow', 'ssh').tap do |access| GitlabAccess.new(nil, repo_path, 'key-123', 'wow', 'ssh').tap do |access|
access.stub(exec_cmd: :exec_called) allow(access).to receive(:exec_cmd).and_return(:exec_called)
access.stub(api: api) allow(access).to receive(:api).and_return(api)
end end
end end
before do before do
GitlabConfig.any_instance.stub(repos_path: repository_path) allow_any_instance_of(GitlabConfig).to receive(:repos_path).and_return(repository_path)
end end
describe :initialize do describe :initialize do
it { subject.repo_path.should == repo_path } it { expect(subject.send(:repo_path)).to eql repo_path } # FIXME: don't access private instance variables
it { subject.changes.should == ['wow'] } it { expect(subject.send(:changes)).to eql ['wow'] } # FIXME: don't access private instance variables
it { subject.protocol.should == 'ssh' } it { expect(subject.send(:protocol)).to eql 'ssh' } # FIXME: don't access private instance variables
end end
describe "#exec" do describe "#exec" do
...@@ -61,7 +61,7 @@ describe GitlabAccess do ...@@ -61,7 +61,7 @@ describe GitlabAccess do
context "API connection fails" do context "API connection fails" do
before do before do
api.stub(:check_access).and_raise(GitlabNet::ApiUnreachableError) allow(api).to receive(:check_access).and_raise(GitlabNet::ApiUnreachableError)
end end
it "returns false" do it "returns false" do
......
This diff is collapsed.
...@@ -16,22 +16,22 @@ describe GitlabLfsAuthentication do ...@@ -16,22 +16,22 @@ describe GitlabLfsAuthentication do
end end
describe '#build_from_json' do describe '#build_from_json' do
it { subject.username.should == 'dzaporozhets' } it { expect(subject.username).to eql 'dzaporozhets' }
it { subject.lfs_token.should == 'wsnys8Zm8Jn7zyhHTAAK' } it { expect(subject.lfs_token).to eql 'wsnys8Zm8Jn7zyhHTAAK' }
it { subject.repository_http_path.should == 'http://gitlab.dev/repo' } it { expect(subject.repository_http_path).to eql 'http://gitlab.dev/repo' }
end end
describe '#authentication_payload' do describe '#authentication_payload' do
result = "{\"header\":{\"Authorization\":\"Basic ZHphcG9yb3poZXRzOndzbnlzOFptOEpuN3p5aEhUQUFL\"},\"href\":\"http://gitlab.dev/repo/info/lfs/\"}" result = "{\"header\":{\"Authorization\":\"Basic ZHphcG9yb3poZXRzOndzbnlzOFptOEpuN3p5aEhUQUFL\"},\"href\":\"http://gitlab.dev/repo/info/lfs/\"}"
it { subject.authentication_payload.should eq(result) } it { expect(subject.authentication_payload).to eq(result) }
it 'should be a proper JSON' do it 'should be a proper JSON' do
payload = subject.authentication_payload payload = subject.authentication_payload
json_payload = JSON.parse(payload) json_payload = JSON.parse(payload)
json_payload['header']['Authorization'].should eq('Basic ZHphcG9yb3poZXRzOndzbnlzOFptOEpuN3p5aEhUQUFL') expect(json_payload['header']['Authorization']).to eq('Basic ZHphcG9yb3poZXRzOndzbnlzOFptOEpuN3p5aEhUQUFL')
json_payload['href'].should eq('http://gitlab.dev/repo/info/lfs/') expect(json_payload['href']).to eq('http://gitlab.dev/repo/info/lfs/')
end end
end end
end end
...@@ -6,7 +6,7 @@ describe :convert_log_level do ...@@ -6,7 +6,7 @@ describe :convert_log_level do
subject { convert_log_level :extreme } subject { convert_log_level :extreme }
it "converts invalid log level to Logger::INFO" do it "converts invalid log level to Logger::INFO" do
$stderr.should_receive(:puts).at_least(:once) expect($stderr).to receive(:puts).at_least(:once)
should eq(Logger::INFO) should eq(Logger::INFO)
end end
end end
......
This diff is collapsed.
...@@ -31,7 +31,7 @@ describe GitlabPostReceive do ...@@ -31,7 +31,7 @@ describe GitlabPostReceive do
before do before do
$logger = double('logger').as_null_object # Global vars are bad $logger = double('logger').as_null_object # Global vars are bad
GitlabConfig.any_instance.stub(repos_path: repository_path) allow_any_instance_of(GitlabConfig).to receive(:repos_path).and_return(repository_path)
end end
describe "#exec" do describe "#exec" do
......
...@@ -5,8 +5,8 @@ describe NamesHelper do ...@@ -5,8 +5,8 @@ describe NamesHelper do
include NamesHelper include NamesHelper
describe :extract_ref_name do describe :extract_ref_name do
it { extract_ref_name('refs/heads/awesome-feature').should == 'awesome-feature' } it { expect(extract_ref_name('refs/heads/awesome-feature')).to eql 'awesome-feature' }
it { extract_ref_name('refs/tags/v2.2.1').should == 'v2.2.1' } it { expect(extract_ref_name('refs/tags/v2.2.1')).to eql 'v2.2.1' }
it { extract_ref_name('refs/tags/releases/v2.2.1').should == 'releases/v2.2.1' } it { expect(extract_ref_name('refs/tags/releases/v2.2.1')).to eql 'releases/v2.2.1' }
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment