encyclopegia.org

Bogus (Ruby)

Bogus is a Ruby API library used for minimizing risks involved in isolated unit testing. It was initially released in July 2012 by rubygems.org. Through Bogus, a piece of code can be tested in a fast and safe manner, without any actual integration with external programs. Bogus cannot mock or stub methods not present in the required external environment.

Bogus is a Ruby API library used for minimizing risks involved in isolated unit testing. It was initially released in July 2012 by rubygems.org. Through Bogus, a piece of code can be tested in a fast and safe manner, without any actual integration with external programs. Bogus cannot mock or stub methods not present in the required external environment. The syntax is similar to that of ruby stubbing: RR syntax stub(object).method_name { return_value } Bogus syntax stub(object).method_name(any_args) { return_value } The main difference between fakes and stubbing is that in fakes, method call can be verified before stubbing. But in stubbing, to verify that a method call has occurred, stubbing beforehand is necessary. Syntax: mock(object).method_name(*args) { return_value } Bogus configuration syntax: Bogus.configure do |c| c.search_modules = [Object] c.fake_ar_attributes = true end By default, Bogus does not maintain a namespace. Therefore, during the search for a particular class(to resolve a class name), the search is performed on all of the identifiers. In order to narrow down the search space, Search_modules can be customized to include a particular module of classes. For example: Bogus.configure do |c| c.search_modules Here, 'Bar' is a module which contains a set of classes where the search has to be performed. This feature deals with the ActiveRecord::Base class. Here, the Active Record is a module and Base is one of its classes. Active Record's attributes are not explicit. Their modification is done in the database directly. The Base class is a special class that has methods it responds to but doesn't explicitly mention as its own methods. Therefore, when such a method is faked, it raises an error because the method does not exist for the class. For example, class BlogPost true blog_post.method(:name) # raises NameError To avoid this problem, fake_ar_modules is set to true. Then fakes can be created with no error. ===Sources=== https://www.relishapp.com/bogus/bogus/v/0-1-6/docs/getting-started https://github.com/psyho/bogus https://github.com/groyoh/bogus https://www.ruby-toolbox.com/projects/bogus https://packages.debian.org/sid/ruby/ruby-bogus http://gunpowderlabs.com/blog/write-safer-tests-with-bogus/ https://coderwall.com/p/d1dksg/safe-stubbing-with-bogus http://bogus-wrug-2013-07.herokuapp.com/#59

References

No reference rows published for this article.

Cite this article

MLA

"Bogus (Ruby)." encyclopegia.org, 2025, https://encyclopegia.org/wiki/bogus-ruby. Accessed 24 November 2026.

Chicago

"Bogus (Ruby)." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/bogus-ruby.

APA

encyclopegia.org. (2025). Bogus (Ruby). Retrieved November 24, 2026, from https://encyclopegia.org/wiki/bogus-ruby

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Claims

PredicateValueSource
release date2012Wikipedia

Related articles

Jorge Cervós-Navarro

enwiki · references available

Dan Totheroh

enwiki · references available

Against the Day (Cronin novel)

enwiki · references available

Wind from the East

enwiki · references available

Ani DiFranco discography

enwiki · references available

Chadsmoor

enwiki · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1330478183 · 0.5 · snapshot enwiki-001330478183

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.