Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
@tsinghan
高级会员
第 501 位会员 / 2011-12-19

青岛
51 篇帖子 / 438 条回帖
2 关注者
5 正在关注
79 收藏
海牛海牛,你迈着大步向前走
未设置 GitHub 信息。
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • 程序员的好玩具 - Lego EV3 at 2015年02月13日

    cool

  • 高手对决 -- 博客服务器被黑的故事 at 2015年01月21日

    :thumbsup:

  • 今天论坛速度好快!以后就放这里吧,别搬服务器了。 at 2015年01月19日

    真的很快啊

  • git 协作开发 iOS .pbxproj 总是冲突,大家是怎么做的? at 2015年01月13日

    是因为修改 storyboard 的配置冲突吗

  • iOS 学习资料整理 at 2015年01月08日

    这个好,赞

  • 同一个 app 中 如何处理类似多个 TabBar? at 2015年01月07日

    #1 楼 @ashchan 我是通过 push 方式跳转到第二个界面的,是不是就意味着我在 push 的时候就要切换 rootViewController,而我点击 nav 的返回按钮,是要返回第一个界面,这时候我怎么去吧 rootViewController 切换回来的?

  • 2015年 你打算学习哪门编程语言? at 2015年01月06日

    #1 楼 @ucooling 《Beginning iOS 8 Programming with Swift》 《iOS 8 Swift Programming Cookbook》都不错

  • 我兑现了一个月前的承诺 at 2014年12月28日

    恭喜

  • 今天多看的 Ruby 元编程 2 元 at 2014年12月12日

    第一版啊

  • 去 GitHub 粉一下奥巴马呗 at 2014年12月10日

    xi 大大那个肯定是假的

  • Swift 改写客户端,酝酿中... at 2014年12月02日

    改写完了吗

  • 我承诺,2014 年 结束前开发出。。 at 2014年11月28日

    其实我也要为楼主的机智点赞

  • [成都] Ruby 程序员招聘 at 2014年11月27日

    底薪(基本是你说多少就多少)

  • Udemy 上的课程促销全部是 $10 截止到 11.28 at 2014年11月20日

    要是能听懂 就太完美了 orz

  • Rails 路由系统源码探索 at 2014年11月19日

    点个收藏吧

  • 性能监控的好工具 - NewRelic 简介 at 2014年11月19日

    app server time 是指服务器消耗的时间?从请求到返回数据这一过程吗?还有 503ms 是指整个请求仅消耗了不到 1 秒吗?

  • 青岛房价如何 at 2014年11月19日

    崂山,市南的最贵。李沧 市北 次之,不同的地段价位不一样啦,重庆南路附近的楼盘在 1w4,5 吧,李村的楼盘 1w 出头,仅供参考吧

  • ruby 有没有象 python 的 scrapy 那样的爬虫框架 at 2014年11月17日

    #1 楼 @Rei 有意思

  • rails 随机生成字母跟数字的组合,比如 4 位、6 位、7 位等等 at 2014年11月06日

    SecureRandom.hex(10)

  • 丰富的行业经验 at 2014年11月06日

    呵呵

  • Grape + RSpec 测试 如何 mock at 2014年11月05日

    #12 楼 @JIAZHEN 我按照你上面的写法试了试,我感觉 Club.any_instance.stub(:is_admin?).and_return(true) 这种写法应该可以,但返回的还不是 mock 的 true。

    我的程序代码是这么写的

    @club = fetch_club 
    if @club.is_admin?(current_member.id)
      xxxxx
    end
    

    我感觉是因为 fetch_club(写在 grape 的 helper 里) 这块的问题?我上面是用下面这种方式来 mock fetch_club,这样就正常

    Grape::Endpoint.before_each do |endpoint|
       endpoint.stub(:fetch_club).and_return(@club)
     end
    
  • Grape + RSpec 测试 如何 mock at 2014年11月04日

    额 mock 出来了,问题就是在测试中 mock 的 club 和 api 代码中不是同一个实例 fetch_club 方法是定义在 grape helper 里面 所以就 mock fetch_club https://github.com/intridea/grape#stubbing-helpers 这样 就 ok 了,谢谢帮忙回答问题的几位~~~

    before do
        Grape::Endpoint.before_each do |endpoint|
          endpoint.stub(:fetch_club).and_return(@club)
        end
      end
    
    
      it "creates a conference" do
        @club.stub(:is_admin?).and_return(true)
        post "/api/v1/conferences", @conference_params, {"HTTP_API_KEYAPI_KEY" => @member.api_token}
        expect(response.status).to eq(201)
      end
    
  • Grape + RSpec 测试 如何 mock at 2014年11月04日

    #6 楼 @JIAZHEN 我把测试改了一下,在测试中分别 mock fetch_club, @club.is_admin? 但是 if @club.is_admin?还是返回 false, controller.stub(:fetch_club).and_return(@club) 这种 mock 对吗?

    it "creates a conference" do
         @club.stub(:is_admin?).and_return(true)
         controller.stub(:fetch_club).and_return(@club)
         post "/api/v1/conferences", @conference_params, {"HTTP_API_KEYAPI_KEY" => @member.api_token}
         expect(response.status).to eq(201)
       end
    

    api 代码也同时改了

      post  do
            authenticate!
            @club = fetch_club 
            if @club.is_admin?(current_member.id)
              xxxxxx
            end
    end
    
  • Grape + RSpec 测试 如何 mock at 2014年11月04日

    感觉 测试 mock 的 club 实例 和 程序中的不是同一个

  • Grape + RSpec 测试 如何 mock at 2014年11月04日

    #5 楼 @kayakjiang 换了这种也不行,我感觉@JIAZHEN 这种说法 应该是对的,但是实际还是返回 false

  • Grape + RSpec 测试 如何 mock at 2014年11月04日

    #6 楼 @JIAZHEN 额 , fetch_club 方法 Club.where.first,我在测试中设置了个断点

    before(:each) do
         @club   = create(:public_community)
         @member = @club.member
       end
    
       it "creates a conference" do
         Club.any_instance.stub(:is_admin?).and_return(true)
         binding.pry
         post "/api/v1/conferences", @conference_params, {"HTTP_API_KEYAPI_KEY" => @member.api_token}
         expect(response.status).to eq(201)
       end
    

    在断点处调试 @club.is_admin?(@member.id) => false

    这里直接输入 false 了,哪里不对?

  • 依然会后赶 at 2014年11月04日

    为了看第一张照片里的妹子,我把电脑都倒过来了~~~~~~

  • Grape + RSpec 测试 如何 mock at 2014年11月03日

    #3 楼 @kayakjiang 恩 这个是 在 before(:each) 里面 create 出来的

    before(:each) do
         @club   = create(:public_community)
       end
    
  • 上一页
  • 1
  • 2
  • 3
  • 4
  • …
  • 14
  • 15
  • 下一页
关于 / RubyConf / Ruby 镜像 / RubyGems 镜像 / 活跃会员 / 组织 / API / 贡献者
由众多爱好者共同维护的 Ruby 中文社区,本站使用 Homeland 构建,并采用 Docker 部署。
服务器由 赞助 CDN 由 赞助
iOS 客户端 / Android 客户端 简体中文 / English