Skip to content

Commit fadfbc9

Browse files
committed
Add create_go_makefile skeleton
1 parent f6d4624 commit fadfbc9

File tree

4 files changed

+64
-7
lines changed

4 files changed

+64
-7
lines changed

gem/lib/go_gem/mkmf.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# frozen_string_literal: true
2+
3+
require "mkmf"
4+
5+
module GoGem
6+
# Helper module for creating Go Makefiles
7+
module Mkmf
8+
# @param target [String]
9+
# @param srcprefix [String,nil]
10+
def create_go_makefile(target, srcprefix = nil)
11+
create_makefile(target, srcprefix)
12+
end
13+
end
14+
end
15+
16+
include GoGem::Mkmf # rubocop:disable Style/MixinUsage

gem/spec/go_gem/mkmf_spec.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# frozen_string_literal: true
2+
3+
RSpec.describe GoGem::Mkmf do
4+
describe "#create_go_makefile" do
5+
gem_name = "new_gem"
6+
7+
before(:all) do
8+
@temp_dir = Dir.mktmpdir
9+
10+
Dir.chdir(@temp_dir) do
11+
create_go_makefile("#{gem_name}/#{gem_name}")
12+
end
13+
end
14+
15+
after(:all) do
16+
FileUtils.remove_entry_secure(@temp_dir) if @temp_dir && Dir.exist?(@temp_dir)
17+
end
18+
19+
around do |example|
20+
Dir.chdir(@temp_dir) do
21+
example.run
22+
end
23+
end
24+
25+
describe file("Makefile") do
26+
it { should be_file }
27+
it { should exist }
28+
29+
# content of create_makefile
30+
its(:content) { should match(%r{^SHELL = /bin/sh$}) }
31+
32+
# content of create_go_makefile
33+
its(:content) { should match(%r{^\$\(DLLIB\): Makefile \$\(srcdir\)/\*\.go$}) }
34+
end
35+
end
36+
end

gem/spec/go_gem_spec.rb

Lines changed: 0 additions & 7 deletions
This file was deleted.

gem/spec/spec_helper.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# frozen_string_literal: true
22

33
require "go_gem"
4+
require "go_gem/mkmf"
5+
6+
require "tmpdir"
7+
require "serverspec"
8+
9+
set :backend, :exec
410

511
RSpec.configure do |config|
612
# Enable flags like --only-failures and --next-failure
@@ -12,4 +18,10 @@
1218
config.expect_with :rspec do |c|
1319
c.syntax = :expect
1420
end
21+
22+
config.filter_run_when_matching :focus
23+
24+
config.define_derived_metadata do |meta|
25+
meta[:aggregate_failures] = true
26+
end
1527
end

0 commit comments

Comments
 (0)