Commit 31da2f7
Changed files (3)
lib
nasty
spec
unit
lib/nasty/binding_behaviour.rb
@@ -0,0 +1,7 @@
+module Nasty
+ module BindingBehaviour
+ def get_binder
+ binding
+ end
+ end
+end
lib/nasty.rb
@@ -1,4 +1,5 @@
require "nasty/background_job"
+require "nasty/binding_behaviour"
require "nasty/command"
require "nasty/composite_command"
require "nasty/kernel"
spec/unit/binding_spec.rb
@@ -0,0 +1,16 @@
+require "spec_helper"
+
+module Nasty
+ describe BindingBehaviour do
+ it "exposes an objects private binding" do
+ item = Object.new
+ item.instance_eval do
+ @message = "secret"
+ end
+ item.extend(Nasty::BindingBehaviour)
+ binding = item.get_binder
+ result = ERB.new("<%= @message %>").result(binding)
+ result.should == "secret"
+ end
+ end
+end