Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Conversation

natsumesou
Copy link

I think this is a bug. and should not store let variable.

this is demo spec.
https://gist.github.com/natsumesou/5300504

@myronmarston
Copy link
Member

This has already been fixed in 2.13.1, although we've never intended to support calling a let from before(:all). In 2.13.1 we've added a deprecation warning since a fair number of users have been doing this even though there's no reasonable, non-confusing semantics for how these things could be combined.

Here's the output from that demo spec on 2.13.1:

Rspec Tests Evaluation
WARNING: let declaration `test` accessed in a `before(:all)` hook at:
  /Users/myron/code/rspec-dev/repos/rspec-mocks/spec/rspec/mocks/at_most_spec.rb:96:in `block (2 levels) in <top (required)>'

This is deprecated behavior that will not be supported in RSpec 3.

`let` and `subject` declarations are not intended to be called
in a `before(:all)` hook, as they exist to define state that
is reset between each example, while `before(:all)` exists to
define state that is shared across examples in an example group.

  when set variable by let
    should eq 401
  when set variable by let too
    should eq 200

Finished in 0.00195 seconds
2 examples, 0 failures

@natsumesou
Copy link
Author

oh, I see. thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants