我在寻找一种可靠的方法, 在我的开发环境中, 动态地压碎某些方法。 例如我需要开发通常需要访问 Facebook 图表 APIs, 但是没有互联网接入。 我希望能够按住调用fb_ graph 方法的电话, 这样看起来就像我认证了 并且有剖面数据 。 理想的情况是, 我可以用一个小的配置变化来打开或关闭根管 。
有什么想法吗 我猜摩卡这种摩卡能处理得来吗
我在寻找一种可靠的方法, 在我的开发环境中, 动态地压碎某些方法。 例如我需要开发通常需要访问 Facebook 图表 APIs, 但是没有互联网接入。 我希望能够按住调用fb_ graph 方法的电话, 这样看起来就像我认证了 并且有剖面数据 。 理想的情况是, 我可以用一个小的配置变化来打开或关闭根管 。
有什么想法吗 我猜摩卡这种摩卡能处理得来吗
您可以使用 VCR 宝石, 该宝石将把初始 HTTP 请求的结果记录到一个 yml 文件, 然后在随后的 http 请求中使用该 yml 文件的内容。 然后可以配置它, 忽略 VCR 逻辑, 并总是提出 HTTP 请求, 如果需要的话 :
https://www.relishap.com/myronmarston/vcr' rel=“nofollow'>https://www.relishap.com/myronmarston/vcr
摩卡当然可以 但感觉有点奇怪
你也可以做一些类似 依赖注射。
例如:
class User < AR::Base
def find_friends
Facebook.find_friends(facebook_id)
end
end
class Facebook
def self.find_friends(id)
# connect to Facebook here
end
end
class FakeFacebook
def self.find_friends(id)
# a fake implementation here
end
end
在初始化器内部:
if Rails.env.development?
User::Facebook = FakeFacebook
end
collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...
We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...
As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...
I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?
I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...
I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml
guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...
I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...