elasticsearch-ruby

https://github.com/elastic/elasticsearch-ruby

Ruby

Ruby integrations for Elasticsearch

Object#stub

Add a temporary stubbed method replacing +name+ for the duration
of the +block+. If +val_or_callable+ responds to #call, then it
returns the result of calling it, otherwise returns the value
as-is. If stubbed method yields a block, +block_args+ will be
passed along. Cleans up the stub at the end of the +block+. The
method +name+ must exist before stubbing.

    def test_stale_eh
      obj_under_test = Something.new
      refute obj_under_test.stale?

      Time.stub :now, Time.at(0) do
        assert obj_under_test.stale?
      end
    end

Source | Google | Stack overflow

Edit

git clone [email protected]:elastic/elasticsearch-ruby.git

cd elasticsearch-ruby

open

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Object-stub-for-pr


# Commit to git

git add git commit -m "better docs for Object#stub"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Object-stub-for-pr

hub pull-request


# Celebrate!