小编trc*_*den的帖子

如何在Rails 3上使用RR(双红宝石)模拟一个带方法的方法

我正在使用Koala gem来发出facebook请求,我有以下代码:

  @graph = Koala::Facebook::API.new(oauth_token)
  @graph.batch do |batch_api|
    #... do stuff here
  end
Run Code Online (Sandbox Code Playgroud)

我想模拟批量调用来模拟我们在那里做的事情.

这是我在RR中所拥有的.

oauth_token= "Sometoken"
batch_api_mock = nil
graph_mock = mock(Koala::Facebook::API).new(oauth_token).mock!
graph_mock.batch.returns do
  yield batch_api_mock if block_given?
end
Run Code Online (Sandbox Code Playgroud)

问题是block_given?即使在我的源代码中传递了一个块,它也会返回false.

我如何使用RR模拟一个采用块的方法?

testing mocking rr ruby-on-rails-3

3
推荐指数
1
解决办法
1428
查看次数

如何在adobe flash professional cs5或cs6中创建垂直线性渐变

如果您转到颜色选择器并选择线性渐变,则始终会获得水平线性渐变.如何将渐变旋转90度以创建在adobe flash professional cs5或6中从上到下移动的渐变?

我的问题源于无法在圆角矩形上创建垂直线性渐变.我可以变换和旋转按钮以获得正确的渐变,但按钮边缘会变形.

我开始:

在此输入图像描述

我结束:

在此输入图像描述

这是我正在使用的颜色选择器.我没有看到渐变的角度选项.

颜色选择器

flash gradient flash-cs5 flash-cs6

1
推荐指数
1
解决办法
1万
查看次数

为什么mongoid在我的模型上抛出未定义的方法`field'?

我有以下内容:

class Email
  include ::Mongoid::Timestamps
  include ::Mongoid::Document

  field :email_address, :type => String
  field :user_id, :type => Integer
  field :campaign, :type => String
  field :stream, :type => String
  field :component, :type => String
  embeds_many :actions
end
Run Code Online (Sandbox Code Playgroud)

并且rails抱怨它无法找到字段方法定义.有人知道为什么吗?

mongoid ruby-on-rails-3

0
推荐指数
1
解决办法
1331
查看次数