summaryrefslogtreecommitdiff
path: root/spec/ruby/language/optional_assignments_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/language/optional_assignments_spec.rb')
-rw-r--r--spec/ruby/language/optional_assignments_spec.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/spec/ruby/language/optional_assignments_spec.rb b/spec/ruby/language/optional_assignments_spec.rb
index 2443cc6b79..ebb5d36351 100644
--- a/spec/ruby/language/optional_assignments_spec.rb
+++ b/spec/ruby/language/optional_assignments_spec.rb
@@ -603,7 +603,7 @@ describe 'Optional variable assignments' do
end
it 'with &&= assignments will fail with non-existent constants' do
- -> { Object::A &&= 10 }.should raise_error(NameError)
+ -> { Object::A &&= 10 }.should.raise(NameError)
end
it 'with operator assignments' do
@@ -615,7 +615,7 @@ describe 'Optional variable assignments' do
end
it 'with operator assignments will fail with non-existent constants' do
- -> { Object::A += 10 }.should raise_error(NameError)
+ -> { Object::A += 10 }.should.raise(NameError)
end
end
end
@@ -623,7 +623,7 @@ end
describe 'Optional constant assignment' do
describe 'with ||=' do
it "assigns a scoped constant if previously undefined" do
- ConstantSpecs.should_not have_constant(:OpAssignUndefined)
+ ConstantSpecs.should_not.const_defined?(:OpAssignUndefined)
module ConstantSpecs
OpAssignUndefined ||= 42
end
@@ -679,7 +679,7 @@ describe 'Optional constant assignment' do
-> {
(x += 1; raise Exception; ConstantSpecs::ClassA)::OR_ASSIGNED_CONSTANT3 ||= (y += 1; :assigned)
- }.should raise_error(Exception)
+ }.should.raise(Exception)
x.should == 1
y.should == 0
@@ -693,11 +693,13 @@ describe 'Optional constant assignment' do
-> {
(x += 1; raise Exception; ConstantSpecs::ClassA)::NIL_OR_ASSIGNED_CONSTANT3 ||= (y += 1; :assigned)
- }.should raise_error(Exception)
+ }.should.raise(Exception)
x.should == 1
y.should == 0
ConstantSpecs::ClassA::NIL_OR_ASSIGNED_CONSTANT3.should == nil
+ ensure
+ ConstantSpecs::ClassA.send(:remove_const, :NIL_OR_ASSIGNED_CONSTANT3)
end
end