<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Although it would be nice (and not too difficult) to have the example
runner intercept any class creation (and perhaps other global/constant
definitions) and undef them after each example.<br>
<br>
It certainly seems reasonable to have any defined classes go away after
an example.<br>
<br>
aslak hellesoy wrote:
<blockquote
 cite="mid:8d961d900709202353k58eb5ex6db6e5cebaaf484a@mail.gmail.com"
 type="cite">
  <pre wrap="">You can have a global after block in your spec_helper.rb that
undefines all such constants. Then you just have to remember to add
these constants to some global array whenever you define them.

a

On 9/21/07, Matt Margolis <a class="moz-txt-link-rfc2396E" href="mailto:matt@mattmargolis.net">&lt;matt@mattmargolis.net&gt;</a> wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">I have some specs that involve the use of eval and class definitions to
test code generation.  I want to always start with a clean slate so none
of my tests fail or succeed incorrectly due to artifacts left over from
previous specs.

Example of my situation
  Spec 1 defines
    class Fish
    class Cod &lt; Fish
  Spec 2 defines
    class Animal
    class Cod &lt; Animal

In this situation the second spec will fail since Cod was previously
defined to be a subclass of Fish and you can not change the superclass
of a subclass in ruby without causing an exception.

I want the resetting to be as automatic as possible since calling
remove_constant on every class my code defines after each spec is a real
pain since this situation is going to crop up in lots of different specs
and describe blocks.

Thank you,
Matt Margolis
_______________________________________________
rspec-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a>
<a class="moz-txt-link-freetext" href="http://rubyforge.org/mailman/listinfo/rspec-users">http://rubyforge.org/mailman/listinfo/rspec-users</a>

    </pre>
  </blockquote>
  <pre wrap=""><!---->_______________________________________________
rspec-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a>
<a class="moz-txt-link-freetext" href="http://rubyforge.org/mailman/listinfo/rspec-users">http://rubyforge.org/mailman/listinfo/rspec-users</a>
  </pre>
</blockquote>
<br>
</body>
</html>