Project

tout

0.0
No commit activity in last 3 years
No release in over 3 years
Allow the easy testing of private methods.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.14
~> 10.0
~> 3.0
 Project Readme

Tout

Tout is a small helper for altering the visibility of methods while testing them. This allows classes to be structured with normal public/private methods while still maintaining full test coverage.

Tout allows a private method to be made public only for the duration of the test group, it sets the method back to private at the end of the example group to avoid any possible side effects.

Usage

Tout allows the easy and safe testing of private methods via the publicize helper like so:

publicize(class, :method_name)

Here it is in use in a small test suite:

class NormalClass
  def public_foo
    "public"
  end

  private

  def private_foo
    "private"
  end
end

describe NormalClass do
  describe "#private_foo"
    publicize(described_class, :private_foo)

    it "returns 'private'" do
      expect(described_class.private_foo).to eq("private")
    end
  end  
end

Installation

Add this line to your application's Gemfile:

gem 'tout'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tout

After the gem is installed setup Tout in your RSpec config like so:

RSpec.configure do |config|
  config.extend(Tout)
end

License

The gem is available as open source under the terms of the MIT License.