Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
(:每个)挂钩前的rspec-有条件地应用_Rspec_Rspec Rails_Ruby On Rails 4.2 - Fatal编程技术网

(:每个)挂钩前的rspec-有条件地应用

(:每个)挂钩前的rspec-有条件地应用,rspec,rspec-rails,ruby-on-rails-4.2,Rspec,Rspec Rails,Ruby On Rails 4.2,我的rails\u helper.rb中有以下内容: RSpec.configure do |config| # ... config.before(:each, type: :controller) do # SOMETHING end end 我想定义目录,这个东西将适用于这些目录(在我的情况下,仅适用于spec/controllers/api目录下的文件) 有机会做到这一点吗?您可以使用更专业的名称: 然后在spec/controllers/api中的RSpec示例中

我的
rails\u helper.rb中有以下内容:

RSpec.configure do |config|
  # ...
  config.before(:each, type: :controller) do
    # SOMETHING
  end
end
我想定义目录,这个
东西
将适用于这些目录(在我的情况下,仅适用于
spec/controllers/api
目录下的文件)


有机会做到这一点吗?

您可以使用更专业的名称:

然后在
spec/controllers/api
中的RSpec示例中,添加一些元数据:

RSpec.describe "something", :subtype => :controllers_api do
end

SOMETHING
应仅在具有
:subtype=>:controllers\u api
元数据的示例上运行。我没有使用
:type
,因为它可能定义了其他行为。

您可以为您的:

然后在
spec/controllers/api
中的RSpec示例中,添加一些元数据:

RSpec.describe "something", :subtype => :controllers_api do
end

SOMETHING
应仅在具有
:subtype=>:controllers\u api
元数据的示例上运行。我没有使用
:type
,因为它可能定义了其他行为。

您可以为您的:

然后在
spec/controllers/api
中的RSpec示例中,添加一些元数据:

RSpec.describe "something", :subtype => :controllers_api do
end

SOMETHING
应仅在具有
:subtype=>:controllers\u api
元数据的示例上运行。我没有使用
:type
,因为它可能定义了其他行为。

您可以为您的:

然后在
spec/controllers/api
中的RSpec示例中,添加一些元数据:

RSpec.describe "something", :subtype => :controllers_api do
end
SOMETHING
应仅在具有
:subtype=>:controllers\u api
元数据的示例上运行。我没有使用
:type
,因为它可能定义了其他行为