Tag: hook

如何在ruby钩子中加载python文件?

我试图添加钩子来忽略在gitlab中提交的二进制文件,所以我在/opt/gitlab/embedded/service/gitlab-shell/lib添加了新的python(.py)钩子,我在/opt/gitlab/embedded/service/gitlab-shell/hooks/pre-receive.rb加载了该文件/opt/gitlab/embedded/service/gitlab-shell/hooks/pre-receive.rb 但是当我尝试提交文件时,我在提交屏幕中得到了以下exception remote:hooks / pre-receive:17:in require_relative’: cannot load such file — /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_ignore_binary.py (LoadError) remote: from hooks/pre-receive:17:in ‘ 我的预接收挂钩文件是 #!/opt/gitlab/embedded/bin/ruby # Fix the PATH so that gitlab-shell can find git-upload-pack and friends. ENV[‘PATH’] = ‘/opt/gitlab/bin:/opt/gitlab/embedded/bin:’ + ENV[‘PATH’] #!/usr/bin/env ruby #!/usr/bin/env python # This file was placed here by GitLab. It makes sure that your pushed commits […]

是否可以在`somewhere’中添加`before(:each)`钩子,以便所有spec文件都可以运行它?

我正在使用Ruby on Rails 3.2.2和rspec-rails-2.8.1。 为了使我的spec文件DRY (不要重复自己)并为test数据库播种,我想为所有这些spec文件运行一个before(:each)钩子。 也就是说,在我的所有spec文件中,我有以下代码: describe ‘test description’ do before(:each) do load “#{Rails.root}/db/seeds.rb” end … end 是否可以添加“somewhere” before(:each)挂钩,以便所有spec文件都可以运行它? 你有什么建议?