Skip to content

Latest commit

 

History

History
40 lines (26 loc) · 1.38 KB

2014-02-06.md

File metadata and controls

40 lines (26 loc) · 1.38 KB

Kashyap

http://dhruvaray.github.io/spa-eye/models.html

Firebug plugin for inspecting Backbone apps. Sort of like ember-inspector for Chrome.

Hemant

Depending on configuration in tests

Quite often rails projects depend on a config.yml and values within it for functioning. What seems innocus at first, we start depending on values within config.yml in our unit tests as well. For example, if config.yml defines app_email as foo@example.com then tests depend on that value being foo@example.com.

What I am slowly beginning to realize (working on Brightbox project) is - depending on values within config.yml in specs is really a anti-pattern. Not only now specs require a proper config.yml for running the tests, but also - sometimes values present in config.yml can dictate the behaviour of unit test itself.

A solution that we are working to use in Brightbox is to use configatron.temp and remove dependence on config.yml altogether. For example:

# in spec_helper.rb
config.around(:each) do |example|
  configatron.temp do
    .. set values required here
    yield
  end
end

This has the benefit that, tests run in a uniform environment across the board. People often have different values in config.yml locally.

This also ensures that whatever setup we require for proepr config.yml can be performed in around(:each) block.