From 722529e76a576869393eab67711ef169b01fe301 Mon Sep 17 00:00:00 2001 From: Myron Marston Date: Thu, 7 Jun 2012 17:38:19 -0700 Subject: [PATCH] Refactor away the use of #its. #its is going away in rspec-core at some future point, so we shouldn't use it here. --- spec/rspec/mocks/stub_const_spec.rb | 60 ++++++++++++++--------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/spec/rspec/mocks/stub_const_spec.rb b/spec/rspec/mocks/stub_const_spec.rb index 8162cc855..5520e9f2f 100644 --- a/spec/rspec/mocks/stub_const_spec.rb +++ b/spec/rspec/mocks/stub_const_spec.rb @@ -244,63 +244,63 @@ def change_const_value_to(value) describe Constant do describe ".original" do context 'for a previously defined unstubbed constant' do - subject { Constant.original("TestClass::M") } + let(:const) { Constant.original("TestClass::M") } - its(:name) { should eq("TestClass::M") } - its(:previously_defined?) { should be_true } - its(:stubbed?) { should be_false } - its(:original_value) { should eq(:m) } + it("exposes its name") { const.name.should eq("TestClass::M") } + it("indicates it was previously defined") { const.should be_previously_defined } + it("indicates it has not been stubbed") { const.should_not be_stubbed } + it("exposes its original value") { const.original_value.should eq(:m) } end context 'for a previously defined stubbed constant' do before { stub_const("TestClass::M", :other) } - subject { Constant.original("TestClass::M") } + let(:const) { Constant.original("TestClass::M") } - its(:name) { should eq("TestClass::M") } - its(:previously_defined?) { should be_true } - its(:stubbed?) { should be_true } - its(:original_value) { should eq(:m) } + it("exposes its name") { const.name.should eq("TestClass::M") } + it("indicates it was previously defined") { const.should be_previously_defined } + it("indicates it has been stubbed") { const.should be_stubbed } + it("exposes its original value") { const.original_value.should eq(:m) } end context 'for a previously undefined stubbed constant' do before { stub_const("TestClass::Undefined", :other) } - subject { Constant.original("TestClass::Undefined") } + let(:const) { Constant.original("TestClass::Undefined") } - its(:name) { should eq("TestClass::Undefined") } - its(:previously_defined?) { should be_false } - its(:stubbed?) { should be_true } - its(:original_value) { should be_nil } + it("exposes its name") { const.name.should eq("TestClass::Undefined") } + it("indicates it was not previously defined") { const.should_not be_previously_defined } + it("indicates it has been stubbed") { const.should be_stubbed } + it("returns nil for the original value") { const.original_value.should be_nil } end context 'for a previously undefined unstubbed constant' do - subject { Constant.original("TestClass::Undefined") } + let(:const) { Constant.original("TestClass::Undefined") } - its(:name) { should eq("TestClass::Undefined") } - its(:previously_defined?) { should be_false } - its(:stubbed?) { should be_false } - its(:original_value) { should be_nil } + it("exposes its name") { const.name.should eq("TestClass::Undefined") } + it("indicates it was not previously defined") { const.should_not be_previously_defined } + it("indicates it has not been stubbed") { const.should_not be_stubbed } + it("returns nil for the original value") { const.original_value.should be_nil } end context 'for a previously defined constant that has been stubbed twice' do before { stub_const("TestClass::M", 1) } before { stub_const("TestClass::M", 2) } - subject { Constant.original("TestClass::M") } + let(:const) { Constant.original("TestClass::M") } - its(:name) { should eq("TestClass::M") } - its(:previously_defined?) { should be_true } - its(:stubbed?) { should be_true } - its(:original_value) { should eq(:m) } + it("exposes its name") { const.name.should eq("TestClass::M") } + it("indicates it was previously defined") { const.should be_previously_defined } + it("indicates it has been stubbed") { const.should be_stubbed } + it("exposes its original value") { const.original_value.should eq(:m) } end context 'for a previously undefined constant that has been stubbed twice' do before { stub_const("TestClass::Undefined", 1) } before { stub_const("TestClass::Undefined", 2) } - subject { Constant.original("TestClass::Undefined") } + let(:const) { Constant.original("TestClass::Undefined") } - its(:name) { should eq("TestClass::Undefined") } - its(:previously_defined?) { should be_false } - its(:stubbed?) { should be_true } - its(:original_value) { should be_nil } + it("exposes its name") { const.name.should eq("TestClass::Undefined") } + it("indicates it was not previously defined") { const.should_not be_previously_defined } + it("indicates it has been stubbed") { const.should be_stubbed } + it("returns nil for the original value") { const.original_value.should be_nil } end end end