タグ

2014年1月10日のブックマーク (3件)

  • Chef を Ruby コード内で利用する

    こんにちは。@jedipunkz です。 require ‘chef’ して Ruby コードの中で chef を利用したいと思って色々調べていた のですが、そもそもリファレンスが無くサンプルコードもごくわずかしかネット上に見 つけられない状態でした。結局ソースコードを読んで理解していく世界なわけですが、 サンプルコードが幾つかあると他の人に役立つかなぁと思い、ブログに載せていこうか なぁと。 まず Chef サーバへアクセスするためには下記の情報が必要です。 ユーザ名 ユーザ用のクライアント鍵 Chef サーバの URL これらは Chef::Config で記していきます。 では早速サンプルコードです。まずは data bags 内データの一覧を取得するコードで す。data bags 内のデータを全で取得し配列で表示します。 #!/usr/bin/env ruby require '

    Chef を Ruby コード内で利用する
  • RSpecのshouldはもう古い!新しい記法expectを使おう!

    というように書くようになりました。 別にshouldを使った記法がなくなったわけではありませんが、 https://github.com/rspec/rspec-expectations のREADME.mdには、もう新しいSyntaxの説明しか載っていないし、今後はexpectの方を使っていくほうがいいでしょう。 http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax には、新しいSyntaxを導入した背景が説明されています。 簡潔に書くと、shouldだとBasicObjectを継承したクラスのテストを書くときに不具合が起こるみたいですね。 移行方法 基的には、上に書いたように、 foo.should を expect(foo).to に foo.should_not を expect(foo).

    RSpecのshouldはもう古い!新しい記法expectを使おう!
    yugui
    yugui 2014/01/10
  • RSpec's New Expectation Syntax

    There are a few things motivating this new syntax, and I wanted to blog about it to spread awareness. Delegation Issues Between method_missing, BasicObject and the standard library’s delegate, ruby has very rich tools for building delegate or proxy objects. Unfortunately, RSpec’s should syntax, as elegantly as it reads, is prone to producing weird, confusing failures when testing delegate/proxy ob

    RSpec's New Expectation Syntax
    yugui
    yugui 2014/01/10