sproutapp / pavlov

A BDD framework for your Elixir projects
MIT License
128 stars 7 forks source link

Let statements don't retain memos when used in before callbacks #47

Closed seansu4you87 closed 8 years ago

seansu4you87 commented 8 years ago

Here's a failing spec for https://github.com/sproutapp/pavlov/issues/46

Not sure on how to properly implement this

seansu4you87 commented 8 years ago

The problem is here: https://github.com/sproutapp/pavlov/blob/master/lib/case.ex#L253

We flush the ResultTable before each it. Instead we need to somehow flush before the before statements are run if there are any. This is actually fairly complicated because before an it statement, we need:

  1. All before(:each) statements to be re-executed and retain memos
  2. before(:all) statements should not reference let assignments. See the following rspec error as an example:
       let declaration `hello` accessed in a `before(:context)` hook at:

I'm going to try and see if I can figure out where the callbacks are run, and flush it before that point, thus evaluated lets can retain their memos

inf0rmer commented 8 years ago

Hi! Thanks for investigating this bug in such depth :).

It seems like just flushing it after the examples are run fixed the issue then, or am I missing something else?

Thank you for the contribution! I'll run some more tests when I get home tonight but your solution looks good to me!

seansu4you87 commented 8 years ago

Hey @inf0rmer, I don't quite remember all the details of what I was saying here, but I remember that the issue isn't fixed.

I'm trying to utilize the very handle rspec feature, where you declare all of your dependencies in let statements, which are lazily executed. This way you can override those let statements deep in yoru nesting, when you need to slightly modify part of your set up.

Thanks for looking it over again!

seansu4you87 commented 8 years ago

Gonna close this out for now. Feel free to open it back up if you have time!