Skip to content

Commit 33298de

Browse files
committed
extract spec fs helper into module
1 parent 8181759 commit 33298de

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

spec/cc/engine/rubocop_spec.rb

+1-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
module CC::Engine
66
describe Rubocop do
7+
include FilesystemHelpers
78
before { @code = Dir.mktmpdir }
89

910
describe "#run" do
@@ -333,12 +334,6 @@ def issues(output)
333334
output.split("\0").map { |x| JSON.parse(x) }
334335
end
335336

336-
def create_source_file(path, content)
337-
abs_path = File.join(@code, path)
338-
FileUtils.mkdir_p(File.dirname(abs_path))
339-
File.write(abs_path, content)
340-
end
341-
342337
def run_engine(config = nil)
343338
io = StringIO.new
344339
rubocop = Rubocop.new(@code, config, io)

spec/spec_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
require "rspec"
2+
3+
Dir.glob("spec/support/**/*.rb").each(&method(:load))

spec/support/filesystem_helpers.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module FilesystemHelpers
2+
def create_source_file(path, content)
3+
abs_path = File.join(@code, path)
4+
FileUtils.mkdir_p(File.dirname(abs_path))
5+
File.write(abs_path, content)
6+
end
7+
end

0 commit comments

Comments
 (0)