[rspec-users] more rspec questions

Patrick J. Collins patrick at collinatorstudios.com
Tue Apr 27 17:20:02 EDT 2010


Hi everyone,

I still am on my quest to understand Rspec, and I have a few new questions...

If I have a "complex" method which calls other methods, say something like:

-----

class Foo

  def complex_method
	 setup
    setup_something_else

	 mini_method1
	 mini_method2
	 mini_method3
  end

  private

  def setup
    @somevar = Something.something_else
  end

  def setup_something_else
    @someothervar = SomethingElse.something_else
  end

  def mini_method1
    # do something
  end

  ... etc
end

-----

One way to properly test this would be to write a spec that calls
complex_method and it's output returns what I am expecting..  but if it's
broken, it becomes difficult for me to figure out why without writing
individual tests for the mini_methods.

However, I cannot do tests for mini_methods because they are private, and 2ndly
they require initializer methods (setup/setup_something_else) to be called.

So I am just wondering, what is the proper technique to test these
private mini_methods?

Patrick J. Collins
http://collinatorstudios.com



More information about the rspec-users mailing list