文章列表
 
您正在查看 "Ror" 分类下的文章

2012-02-24 18:46

难点在于如果构造出一个假的imap server,然imap client能”连接“上,rspec代码为:

describe 'MyImapClient' do

  

  context "test imap" do

    

    it "should be able to get my mail using imap connect" do

      imaps_test do |port|

        @imap_client = Net::IMAP.new("localhost", :port => port, :

 
2012-02-21 12:30

require 'webmock/rspec'

发现执行

Feedzirra::Feed.fetch_and_parse(‘http://news.yahoo.com/rss/economy’)

没有触发webmock

原因是为了实现高效的数据抓取,Feedzirra使用了curb,curb不是用net::http,所以webmock无法勾住。

那只好勾住fetch_and_parse,让这个方法返回已经适当的值就行,具体如下:

      stub(Feedzirra::Feed).fetch_and_parse do |url|

        resp = Net::HTTP.g

 
2012-02-16 18:05

# with block argument

MyClass.run { puts "start" }

# rspec mocks:

MyClass.stub!(:run).and_yield

# rr:

mock(MyClass).run { |block| block.call }

 

# by argument type

# rr:

stub(User).find do |id|

  if id != '123'

  raise "Unexpected id #{id.inspect} passed to me"

  else

    fake

 
2012-02-08 15:32

Invalid gemspec in [/Users/rain/.rvm/gems/ruby-1.9.2-p180@remotipart/specifications/actionmailer-3.2.0.gemspec]: Illformed requirement ["#<Syck::DefaultKey:0x00000105543c50> 3.2.0"]

 

 

gem list

 

*** LOCAL GEMS ***

 

bundler (1.0.18)

hirb (0.4.5)

rake (0.8.7)

rubygems-update (1.7.2)

 

 

 

solution:

 
2012-02-07 21:02

webmock跟fakeweb差不多,都是用于stubbing http request,支持多种样式的匹配,不过webmock支持httpclient(fb_graph用到)这个gem,而且当有没有stub住的会打印出stub_request的代码,对写测试代码很方便实用。

 
2012-02-03 0:17

Visor是个很酷的Terminal辅助工具,但有时在刷页面debugger时总是需要手工调出来不是很“爽”,于是有了比较爽的解决方法。

 

建一个apple script,用来调出visor:

~/bin/visor

内容:

#!/bin/sh

osascript <<END 
tell application "System Events" to keystroke "\`" using control down

END

加执行权限:

chmod +x ~/bin/visor

 
2012-02-03 0:14

@consumer  = OAuth::Consumer.new(CONSUMER_KEY, CONSUMER_SECRET, :site => 'http://www.tumblr.com')

request_token = @consumer.get_request_token(:oauth_callback => url('/authorize')))

open request_token.authorize_url to get oauth_verifier

# in authorize action, use oauth_verifier to get access token, secret

access_token = request_token.get_access_token(:oauth_verifier =>

 
2012-01-16 12:49

给Photo使用了 CarrierWave 来处理图片上传和使用 MiniMagick 做缩略图生成

class Photo < ActiveRecord::Base  

  mount_uploader :image, ImageUploader

end

 

class ImageUploader < CarrierWave::Uploader::Base

  include CarrierWave::MiniMagick

  

  # Create different versions of your uploaded files:

  version :t

 
2012-01-10 22:23

class SystemMailer < ActionMailer::Base

  add_template_helper(ApplicationHelper)

end

 
2012-01-09 16:04

class AddReservationsCountToRestaurants < ActiveRecord::Migration

  def change

    add_column :restaurants, :reservations_count, :integer, :default => 0

    

    say_with_time "update counter cache" do

      Restaurant.reset_column_information

      

      Restaurant.find_each do |r|

 
   
 
 
文章分类
 
 
Php(22)
 
Web Ue(12)
 
Fun(49)
 
 
Js(23)
 
Ror(99)
 
Unix(29)
 
 
 
 
 
 
 
 
Git(2)
 
 
Ios(2)
 
Css(1)
 
Tools(13)
 
   
 
文章存档
 
     
 
最新文章评论
  

回复mathewxiang:确实好用,个人感觉比TextMate(不论v1,v2)都好用
 

回复qiaolegedou:到官方问问吧,好多年没碰Ext了
 

看来现在的sublime在mac用户中很火啊.
 

火狐上会跟grid交叉显示是什么情况呢?
 

讲得很深,看不懂,试试~~~~~~~~~~
   
帮助中心 | 空间客服 | 投诉中心 | 空间协议
©2012 Baidu