Commit ac8a0fa0 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Few code improvements for spec/lib/gitlab/plugin_spec.rb

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 79d91120
...@@ -4,7 +4,7 @@ describe Gitlab::Plugin do ...@@ -4,7 +4,7 @@ describe Gitlab::Plugin do
describe '.execute' do describe '.execute' do
let(:data) { Gitlab::DataBuilder::Push::SAMPLE_DATA } let(:data) { Gitlab::DataBuilder::Push::SAMPLE_DATA }
let(:plugin) { Rails.root.join('plugins', 'test.rb') } let(:plugin) { Rails.root.join('plugins', 'test.rb') }
let(:tmp_file) { Tempfile.new('plugin-dump').path } let(:tmp_file) { Tempfile.new('plugin-dump') }
before do before do
File.write(plugin, plugin_source) File.write(plugin, plugin_source)
...@@ -13,7 +13,7 @@ describe Gitlab::Plugin do ...@@ -13,7 +13,7 @@ describe Gitlab::Plugin do
after do after do
FileUtils.rm(plugin) FileUtils.rm(plugin)
FileUtils.rm(tmp_file) tmp_file.close!
end end
subject { described_class.execute(plugin.to_s, data) } subject { described_class.execute(plugin.to_s, data) }
...@@ -23,17 +23,17 @@ describe Gitlab::Plugin do ...@@ -23,17 +23,17 @@ describe Gitlab::Plugin do
it 'ensures plugin received data via stdin' do it 'ensures plugin received data via stdin' do
subject subject
expect(File.read(tmp_file)).to eq(data.to_json) expect(File.read(tmp_file.path)).to eq(data.to_json)
end end
end end
private private
def plugin_source def plugin_source
<<-EOS <<~EOS
#!/usr/bin/env ruby #!/usr/bin/env ruby
x = STDIN.read x = STDIN.read
File.write('#{tmp_file}', x) File.write('#{tmp_file.path}', x)
EOS EOS
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