Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Nested describes with before_each

#140

JSpec supports nested describes, but it appears not to support before_each blocks within nested describes.

Request to allow before_each blocks within nested describes.

Reported by Lawrence Pit · July 21st, 2009 @ 01:32 PM

State: invalid
Milestone: none
Assigned to: nobody

Activity

  1. TJ Holowaychuk
    TJ Holowaychuk
    • State changed from new to invalid
    • Tag set to hooks

    Yup, you have to be careful about var; If you use it in the correct context it will still work but the scoping
    is a bit tricky to see with the grammar version of JSpec. You may want to try something like:

      describe "foo"
        var cart
        before_each
          cart = new ShoppingCart
        end
      end
    

    July 24th, 2009 @ 02:39 PM

  2. TJ Holowaychuk
    TJ Holowaychuk

    Generally it shouldn't really matter. Anything developed correctly wont be polluting anyways so polluting during tests is unlikely to cause problems, it never has for me at least. But then again if people are not careful using var in the correct situations they might fuck stuff up haha. Either way there are many ways to deal with it.

    July 26th, 2009 @ 07:00 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.