petitviolet blog

    ruby (8 posts)

    Written by petitviolet

    Make Thread synchronous in Rspec

    Stop using sleep to wait for asynchronous execution run on another Thread in Rspec
    tl;dr ruby allow(Thread).to receive(:new).and_yield What's the problem? In Ruby, Thread can be used for asynchronous processings that would take a while. However, the asynchronousity sometimes cause unexpected results in unit tests, like Rspec. Say, a class that uses Thread inte

    allow_any_instance_of to count up number of method calls behind the scene

    Rspec offers allow_any_instance_of to stub any instances that matches given class
    Rspec is one of the most popular test framework in Ruby, and of course it offers lots of functionalities for being able to write various type of test cases, like mock, stub, matcher, etc. allow_any_instance_of is a powerful method, which is able to stub any instance of a class even though using i

    Ruby on Rails on YugabyteDB

    How to use YugabyteDB as a backend storage of Ruby on Rails application.
    YugabyteDB is "The Leading High-Performance Distributed SQL Database". It has been developed as an open source and called [Distributed SQL]( YugabyteDB is a Distributed SQL product, like Google Cloud Spanner which is

    Tiny compiler written in Ruby

    Build a tiny compiler for a toy programming language in Ruby
    As a software engineer's habit, I've implemented a toy programming language in Ruby for my learning. GitHub repository is [petitviolet/9cc-ruby]( What it looks like Almost *basic* syntax is supported, and only int type is available. - use number

    Empower Pattern Matching in Ruby

    2020-04-10RubyFunctional Programming
    Quick overview of pattern match in Ruby and Gems to empower it
    Ruby2.7 provides Pattern Matching feature as an experimental one. I used to do pattern matching in Scala, so I'm excited to be able to use it in Ruby! tl;dr [Rstructural Gem]( what I'

    Circuit Breaker in Ruby

    2020-04-16RubyFunctional Programming
    Introduction of Circuit Breaker and RCB gem I developed
    I've developed a circuit breaker in Ruby, and published it as rcb gem in - GitHub: [petitviolet/rcb]( - RubyGems: [rcb]( What is CircuitBreaker? CircuitBreaker is a well-known pattern to make services stable that

    Imported blogs from Qiita

    Download my contents and tranform into Gatsby style
    Qiita began to provide a feature to show what types of articles I write and put +1. At that time, they made when I read public without opt-in. [ユーザーページをリニューアルしました - Qiita Blog]( I'd like not to make my browsing histories public, so I was going to delete my


    ruby の[guard/guard](を使ってファイルの変更を監視して、 裏で自動コンパイルする 準備 まずguardをインストールする 以下の様な Gemfile を用意する Gemfile source '' gem 'guard' gem 'guard-shell' gem 'rb-readline' gem 'rb-inotify' そして sh gem install bundle bundle install でguard