(:每个)挂钩前的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
,因为它可能定义了其他行为