无法连接到Microsoft远程调试监视器。(Unable to connect to the Microsoft Remote Debugging Monitor. A security package specific error occurred)
尝试附加到在我们域中的另一台PC上运行的远程调试监视器时,出现以下错误:
“无法连接到名为''的Microsoft Visual Studio远程调试监视器。出现安全软件包特定错误。”
另外,如果您在远程机器上查看,则可以在远程调试器窗口中看到自己已“连接”。
I'm getting the following error when trying to attach to a remote debugging monitor running on another PC on our domain:
"Unable to connect to the Microsoft Visual Studio Remote Debugging Monitor named ''. A security package specific error occurred."
In addition, if you look on the remote machine you can see yourself as "connected" in the remote debugger window.
原文:https://stackoverflow.com/questions/4786016
最满意答案
首先,最好提取对User模型的
find(:all, ...)
调用。 例如,将其search
。class User < ActiveRecord::Base scope :search_by_email, lambda { |email| joins(:roles).where(["name IN (?) and email like '#{email}%'",["content team","ops team"]]) } end
然后在控制器中使用它:
def admin_search @admins = User.search_by_email(params[:email]).paginate(:page => params[:page], :per_page => 10) end
现在,您可以单独测试
search_by_email
方法 - 检查,它只返回“内容团队”和“操作团队”的结果,正确使用空电子邮件字符串等。我不认为你必须测试
paginate
方法,因为它应该已经在kaminari,will_paginate或你使用的任何东西测试过。 但是如果你想确定它被调用,那么你可以在控制器规范中使用模拟期望(should_receive
)。编辑:规格如何看起来像
describe User do describe ".search_by_email" do let(:content_team) { Role.create! name: "content team" } let(:ops_team) { Role.create! name: "ops team" } let(:another_team) { Role.create! name: "another team" } it "should search in content team" do content_team_user = User.create! email: "joe.black@example.com", roles: [content_team] User.search_by_email("black").should == [content_team_user] end it "should search in ops team" do ops_team_user = User.create! email: "joe.black@example.com", roles: [ops_team] User.search_by_email("black").should == [ops_team_user] end it "should not search in other teams" do other_team_user = User.create! email: "joe.black@example.com", roles: [another_team] User.search_by_email("black").should == [] end it "should not search by empty string" do content_team_user = User.create! email: "joe.black@example.com", roles: [content_team_user] User.search_by_email("").should == [] User.search_by_email(nil).should == [] end # more specs for search... end end describe UsersController do describe "admin search" do let(:admin_user) { double(:admin_user).as_null_object } let(:search_string) { 'joe' } it "should search for admin users" do User.should_receive(:search_by_email).with(search_string).and_return([admin_user]) get :admin_search, email: search_string assigns(:admins).should == [admin_user] end end end
First of all, it's better to extract
find(:all, ...)
call to User model. Call itsearch
, for instance.class User < ActiveRecord::Base scope :search_by_email, lambda { |email| joins(:roles).where(["name IN (?) and email like '#{email}%'",["content team","ops team"]]) } end
Use it in the controller then:
def admin_search @admins = User.search_by_email(params[:email]).paginate(:page => params[:page], :per_page => 10) end
Now, you can test the
search_by_email
method in isolation - check, that it returns result for "content team" and "ops team" only, correctly works with empty email string and so on.I don't think you have to test
paginate
method, as it should be already tested in kaminari, will_paginate or whatever you use. But if you want to be sure, that it is being called, than you can use mock expectations (should_receive
) in the controller specs.EDIT: How the specs could look like
describe User do describe ".search_by_email" do let(:content_team) { Role.create! name: "content team" } let(:ops_team) { Role.create! name: "ops team" } let(:another_team) { Role.create! name: "another team" } it "should search in content team" do content_team_user = User.create! email: "joe.black@example.com", roles: [content_team] User.search_by_email("black").should == [content_team_user] end it "should search in ops team" do ops_team_user = User.create! email: "joe.black@example.com", roles: [ops_team] User.search_by_email("black").should == [ops_team_user] end it "should not search in other teams" do other_team_user = User.create! email: "joe.black@example.com", roles: [another_team] User.search_by_email("black").should == [] end it "should not search by empty string" do content_team_user = User.create! email: "joe.black@example.com", roles: [content_team_user] User.search_by_email("").should == [] User.search_by_email(nil).should == [] end # more specs for search... end end describe UsersController do describe "admin search" do let(:admin_user) { double(:admin_user).as_null_object } let(:search_string) { 'joe' } it "should search for admin users" do User.should_receive(:search_by_email).with(search_string).and_return([admin_user]) get :admin_search, email: search_string assigns(:admins).should == [admin_user] end end end
相关问答
更多-
如何在控制器中测试Rspec(How to test Rspec in controller)[2022-09-25]
首先,最好提取对User模型的find(:all, ...)调用。 例如,将其search 。 class User < ActiveRecord::Base scope :search_by_email, lambda { |email| joins(:roles).where(["name IN (?) and email like '#{email}%'",["content team","ops team"]]) } end 然后在控制器中使用它: def admin_search ... -
我不认为uniq! 是您希望在这种情况下使用的方法,请参阅: 如果没有更改,则返回nil(即没有找到重复项)。 https://ruby-doc.org/core-2.2.0/Array.html#method-i-uniq-21 所以它是这样工作的: 2.3.1 :008 > a = [1,2,3,3,nil].uniq! => [1, 2, 3, nil] 2.3.1 :009 > a = [1,2,3,nil].uniq! => nil 2.3.1 :010 > 另一方面, uniq作用如下: ...
-
无法用rspec测试控制器(Can't test controllers with rspec)[2022-02-19]
将您的控制器规范更改为请求规范,这是从RSpec 3.5开始,在Rails中测试控制器的首选方法 由于在原始配置中没有将#bar动作绑定到URL,因此您会收到该错误。 所以当规范执行#bar ,没有该动作的URL。 控制器规范不像您想象的那样工作; 没有任何事情要求你指定的路径。 相反,它会执行您在#bar操作中编写的代码,并从响应中拉取网址。 为了减轻这一点,你可以改变你的规格type:来:request而不是:controller 。 那你可以这样做: RSpec.describe Applicatio ... -
Rspec控制器基本测试(Rspec controller basic test)[2022-03-19]
默认情况下,rspec配置为不呈现视图( 请参见此处 )可以在spec / support / spec_helper.rb(或spec / support / rails_helper.rb)中进行更改,如下所示: RSpec.configure do |config| config.render_views = true end 或者可以在需要的spec文件中添加块: require 'rails_helper' RSpec.configure do |config| config. ... -
您对该请求的呼叫应该在任何should_receive 。 这是一件紧张的事情。 所以它有这样的读法,“当发生这种情况时,类别应该收到一些东西”。 “发生这种情况”是指请求。 it "should find the category by url" do Category.should_receive(:find).with... get "show", { your params, if you're sending some in } end 此外,您至少要通过调用控制器方法本身的方式来执行 ...
-
您可以尝试使用should_receive并将其放入块之前,因为这是一种更好的做法: describe AttachmentsController do describe "POST create" do let(:attachment) { mock_attachment(:save => save_result) } subject { post :create, :attachment => params } before do Attachment.sho ...
-
我一直在敲我的头好几个小时,但我只想出来了。 我需要在用户工厂中确认用户 。 我想因为我在设计中启用了confirmable模块,并且用户未被确认,所以它默默地不允许我进行身份验证... ...如果rspec / rails / devise产生某种错误指向我这里的问题,肯定会很好。 为了完整起见,我在撰写本文时添加了用于在FactoryGirl版本中确认用户的代码: FactoryGirl.define do factory :confirmed_user, :parent => :user do ...
-
我实际上没有看到测试中的重载(你应该在那里做一个)。 200会建议eihter(a)有一个用户认证步骤,你在测试中没有处理过,或者(b)有一个验证问题。 您可以在upate方法中使用gem'prie'和binding.pry来测试其中一个/两个。 如果pry没有在更新中执行,那么更新没有执行(可能是用户身份验证问题),如果确实执行了,你可以查看@project.errors.full_messages以查看问题所在。 I don't actually see a reload in the test (yo ...
-
您的错误来自您的视图,但默认情况下,RSpec中的控制器测试不会呈现视图。 您可以使用rspec-rails的render_views方法强制您的控制器规范呈现视图。 Your error is coming from your view, but by default, controller tests in RSpec won't render views. You can use rspec-rails's render_views method to force your controller sp ...
-
这是一个请求规范(基本上是一个rails集成测试),旨在跨越多个请求,可能跨越控制器。 controller变量由集成测试提供的请求方法设置( get , put , post等) 如果您使用capybara DSL(访问,点击等),那么集成测试方法永远不会被调用,因此controller将是零。 使用水豚时,您无法访问单个控制器实例,因此您无法测试诸如signed_in? 返回 - 您必须测试更高级别的行为(例如页面上的内容)。 This is a request spec (which is basic ...