1
0
Fork 0
mirror of https://github.com/ms-ati/docile synced 2023-03-27 23:21:52 -04:00

Add specs of frozen string and number for #dsl_eval_immutable

This commit is contained in:
Marc Siegel 2013-07-28 23:55:14 -04:00
parent cb26f1f69a
commit abd75d6290

View file

@ -248,8 +248,8 @@ describe Docile do
describe "#dsl_eval_immutable" do
context "when DSL context object is a String" do
let(:original) { "Hello, world!" }
context "when DSL context object is a frozen String" do
let(:original) { "I'm immutable!".freeze }
let!(:result) { execute_non_mutating_dsl_against_string }
def execute_non_mutating_dsl_against_string
@ -260,14 +260,29 @@ describe Docile do
end
it "doesn't modify the original string" do
original.should == "Hello, world!"
original.should == "I'm immutable!"
end
it "chains the commands in the block against the DSL context object" do
result.should == "!DLROW ,OLLEH"
result.should == "!ELBATUMMI M'I"
end
end
context "when DSL context object is a number" do
let(:original) { 84.5 }
let!(:result) { execute_non_mutating_dsl_against_number }
def execute_non_mutating_dsl_against_number
Docile.dsl_eval_immutable(original) do
fdiv(2)
floor
end
end
it "chains the commands in the block against the DSL context object" do
result.should == 42
end
end
end
end