Thursday, April 18, 2013

[RSpec] Refer to let value that has the same name in outer scope

There is a situation in RSpec when you want to redefine let value in the inner scope base on value from the outer scope. In RSpec 2.13, you can do that by referring outer scope value with super() (parens are required)

describe "doing something to a book" do
let(:attributes) { { isbn: '45689511687', title: 'My Insane' } }
# ...
context "when the book has hard cover" do
let(:attributes) { super().merge(hard_cover: true) }
# ...
end
end
view raw rspec-super.rb hosted with ❤ by GitHub
Credit: RSpec 2.13 is released!

No comments:

Collectd PostgreSQL Plugin

I couldn't find this link when searching with google https://www.collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresq...