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:
parent
cb26f1f69a
commit
abd75d6290
1 changed files with 19 additions and 4 deletions
|
@ -248,8 +248,8 @@ describe Docile do
|
||||||
|
|
||||||
describe "#dsl_eval_immutable" do
|
describe "#dsl_eval_immutable" do
|
||||||
|
|
||||||
context "when DSL context object is a String" do
|
context "when DSL context object is a frozen String" do
|
||||||
let(:original) { "Hello, world!" }
|
let(:original) { "I'm immutable!".freeze }
|
||||||
let!(:result) { execute_non_mutating_dsl_against_string }
|
let!(:result) { execute_non_mutating_dsl_against_string }
|
||||||
|
|
||||||
def execute_non_mutating_dsl_against_string
|
def execute_non_mutating_dsl_against_string
|
||||||
|
@ -260,14 +260,29 @@ describe Docile do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't modify the original string" do
|
it "doesn't modify the original string" do
|
||||||
original.should == "Hello, world!"
|
original.should == "I'm immutable!"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "chains the commands in the block against the DSL context object" do
|
it "chains the commands in the block against the DSL context object" do
|
||||||
result.should == "!DLROW ,OLLEH"
|
result.should == "!ELBATUMMI M'I"
|
||||||
end
|
end
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue