Last active
August 29, 2015 14:02
-
-
Save JonathonMA/e3c0e7324d0c946ca31e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Evaluator | |
def evaluate &block | |
instance_eval &block | |
end | |
def upcase bar | |
bar.upcase | |
end | |
end | |
describe Evaluator do | |
it "should evaluate a string" do | |
expect(subject.evaluate { upcase("bar") }).to eq "BAR" | |
end | |
it "should evaluate a variable" do | |
bar = "bar" | |
expect(subject.evaluate { upcase(bar) }).to eq "BAR" | |
end | |
let(:baz) { "baz" } | |
it "FAILS to evaluate a let" do | |
expect { | |
expect(subject.evaluate { upcase(baz) }).to eq "BAZ" | |
}.to raise_error | |
end | |
it "should evaluate a let that has been assigned to a variable" do | |
baz2 = baz | |
expect(subject.evaluate { upcase(baz2) }).to eq "BAZ" | |
end | |
def quux | |
"quux" | |
end | |
it "FAILS to evaluate methods" do | |
expect { | |
expect(subject.evaluate { upcase(quux) }).to eq "QUUX" | |
}.to raise_error | |
end | |
it "should evaluate methods with tmp" do | |
quux2 = quux | |
expect(subject.evaluate { upcase(quux2) }).to eq "QUUX" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment