Skip to content

Instantly share code, notes, and snippets.

@jamesdavidson
Created November 17, 2014 08:58
Show Gist options
  • Save jamesdavidson/fbd3e57af261fc1e747a to your computer and use it in GitHub Desktop.
Save jamesdavidson/fbd3e57af261fc1e747a to your computer and use it in GitHub Desktop.
rspec urgh
context "When I count" do
(0..10).each do |i|
puts i
let (:num) { i + 1}
it "gets cached." do
puts num
end
end
end
@TimMoore
Copy link

Each let should be in its own context, or else each iteration overrides the definition used by all of the it blocks:

context "When I count" do
  (0..10).each do |i|
    context "with i = #{i}" do
      puts i
      let (:num) { i + 1}
      it "gets cached." do
        puts num
      end
    end
  end
end

@jamesdavidson
Copy link
Author

Thanks Tim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment