Skip to content

Commit

Permalink
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/ruby/language/constants_spec.rb
Original file line number Diff line number Diff line change
@@ -375,6 +375,26 @@ module ConstantSpecs
end

end

describe "with &&=" do
it "re-assigns a scoped constant if already true" do
module ConstantSpecs
OpAssignTrue = true
end
ConstantSpecs::OpAssignTrue &&= 1
ConstantSpecs::OpAssignTrue.should == 1
ConstantSpecs.send :remove_const, :OpAssignTrue
end

it "leaves scoped constant if not true" do
module ConstantSpecs
OpAssignFalse = false
end
ConstantSpecs::OpAssignFalse &&= 1
ConstantSpecs::OpAssignFalse.should == false
ConstantSpecs.send :remove_const, :OpAssignFalse
end
end
end

describe "Constant resolution within a singleton class (class << obj)" do

0 comments on commit e2669a6

Please sign in to comment.