diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2018-02-26 17:33:19 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2018-02-26 17:33:19 +0200 |
commit | 7424e0e5b4fd875588a2dd5a15ee5de1559c13db (patch) | |
tree | 01021d4a267180992e80a3b66ba222d3e43c456d /spec/lib | |
parent | 3073f1aa6e8658825af739440f7288deeef9169d (diff) | |
download | gitlab-ce-7424e0e5b4fd875588a2dd5a15ee5de1559c13db.tar.gz |
Add specs for Gitlab::Plugin [ci skip]
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/plugin_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/lib/gitlab/plugin_spec.rb b/spec/lib/gitlab/plugin_spec.rb new file mode 100644 index 00000000000..1dc508f86ce --- /dev/null +++ b/spec/lib/gitlab/plugin_spec.rb @@ -0,0 +1,39 @@ +require 'spec_helper' + +describe Gitlab::Plugin do + describe '.execute' do + let(:data) { Gitlab::DataBuilder::Push::SAMPLE_DATA } + let(:plugin) { Rails.root.join('plugins', 'test.rb') } + let(:tmp_file) { Tempfile.new('plugin-dump').path } + + before do + File.write(plugin, plugin_source) + File.chmod(0o777, plugin) + end + + after do + FileUtils.rm(plugin) + FileUtils.rm(tmp_file) + end + + subject { described_class.execute(plugin.to_s, data) } + + it { is_expected.to be true } + + it 'ensures plugin received data via stdin' do + subject + + expect(File.read(tmp_file)).to eq(data.to_json) + end + end + + private + + def plugin_source + <<-EOS +#!/usr/bin/env ruby +x = STDIN.read +File.write('#{tmp_file}', x) + EOS + end +end |