Skip to content

Commit 18abe1c

Browse files
committed
fix rake task spec
1 parent 8162502 commit 18abe1c

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

lib/rubex/rake_task.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def define_compile_tasks
4141
desc "Compile a Rubex file into a shared object."
4242
task :compile do
4343
file_name = "#{@ext_dir}/#{@name}#{@source_pattern[1..-1]}"
44-
Rubex::Compiler.compile file_name, directory: "#{@ext_dir}"
44+
Rubex::Compiler.compile file_name, target_dir: "#{@ext_dir}"
4545
end
4646
end
4747
Rake::ExtensionTask.new(@name)

spec/rake_task_spec.rb

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
Dir.chdir(dir) do
5555
FileUtils.rm(
5656
Dir.glob(
57-
"#{dir}/#{name}.{c,h,so,o,bundle,dll}") + ["Makefile", "extconf.rb"], force: true
57+
"#{dir}/*.{c,h,so,o,bundle,dll}") + ["Makefile", "extconf.rb"], force: true
5858
)
5959
end
6060
FileUtils.rmdir(dir)
@@ -74,28 +74,36 @@
7474
Rake::Task.clear
7575
end
7676

77-
it "generates the shared object file after compilation" do
78-
ext_path = "#{Dir.pwd}/spec/fixtures/rake_task/single_file"
79-
name = "test"
80-
Rubex::RakeTask.new(name) do
81-
ext ext_path
82-
end
83-
Rake::Task["rubex:compile:install"].invoke
77+
context "for single file" do
78+
it "generates the shared object file after compilation" do
79+
ext_path = "#{Dir.pwd}/spec/fixtures/rake_task/single_file"
80+
name = "test"
81+
Rubex::RakeTask.new(name) do
82+
ext ext_path
83+
end
84+
Rake::Task["rubex:compile:install"].invoke
8485

85-
expect(File.exist?("#{ext_path}/#{name}/#{name}.c")).to eq(true)
86-
expect(File.exist?("#{ext_path}/#{name}/extconf.rb")).to eq(true)
87-
expect(File.exist?("#{ext_path}/#{name}/#{name}.so")).to eq(true)
86+
expect(File.exist?("#{ext_path}/#{name}/#{name}.c")).to eq(true)
87+
expect(File.exist?("#{ext_path}/#{name}/extconf.rb")).to eq(true)
88+
expect(File.exist?("#{ext_path}/#{name}/#{name}.so")).to eq(true)
8889

89-
# delete generated files
90-
dir = "#{ext_path}/#{name}"
91-
Dir.chdir(dir) do
92-
FileUtils.rm(
93-
Dir.glob(
94-
"#{dir}/#{name}.{c,h,so,o,bundle,dll}") + ["Makefile", "extconf.rb"],
95-
force: true
96-
)
90+
# delete generated files
91+
dir = "#{ext_path}/#{name}"
92+
Dir.chdir(dir) do
93+
FileUtils.rm(
94+
Dir.glob(
95+
"#{dir}/#{name}.{c,h,so,o,bundle,dll}") + ["Makefile", "extconf.rb"],
96+
force: true
97+
)
98+
end
99+
FileUtils.rmdir(dir)
100+
end
101+
end
102+
103+
context "for multi file" do
104+
skip "generates .so file after compilation" do
105+
# TODO
97106
end
98-
FileUtils.rmdir(dir)
99107
end
100108
end
101109
end

0 commit comments

Comments
 (0)