我即将为 rspec 编写一个自定义格式化程序,我需要从格式化程序挂钩中访问 letDefinitions。
鉴于:
describe "Example" do
let(:something) { "foo" }
context "something to test" do
# .....
end
end
在我的格式化程序中:
class MyFormatter
RSpec::Core::Formatters.register self, :example_started
def example_started(notification)
@output << "Output of #{value_of_let(:something,notification)}"
end
private
def value_of_let(what, notification)
### is there a way to find :something / 'foo' in notification?
end
end