diff options
Diffstat (limited to 'spec/hashie/extensions/method_access_spec.rb')
-rw-r--r-- | spec/hashie/extensions/method_access_spec.rb | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/spec/hashie/extensions/method_access_spec.rb b/spec/hashie/extensions/method_access_spec.rb index 8268430..6034cef 100644 --- a/spec/hashie/extensions/method_access_spec.rb +++ b/spec/hashie/extensions/method_access_spec.rb @@ -12,34 +12,34 @@ describe Hashie::Extensions::MethodReader do subject { ReaderHash } it 'reads string keys from the method' do - subject.new('awesome' => 'sauce').awesome.should eq 'sauce' + expect(subject.new('awesome' => 'sauce').awesome).to eq 'sauce' end it 'reads symbol keys from the method' do - subject.new(awesome: 'sauce').awesome.should eq 'sauce' + expect(subject.new(awesome: 'sauce').awesome).to eq 'sauce' end it 'reads nil and false values out properly' do h = subject.new(nil: nil, false: false) - h.nil.should eq nil - h.false.should eq false + expect(h.nil).to eq nil + expect(h.false).to eq false end it 'raises a NoMethodError for undefined keys' do - lambda { subject.new.awesome }.should raise_error(NoMethodError) + expect { subject.new.awesome }.to raise_error(NoMethodError) end describe '#respond_to?' do it 'is true for string keys' do - subject.new('awesome' => 'sauce').should be_respond_to(:awesome) + expect(subject.new('awesome' => 'sauce')).to be_respond_to(:awesome) end it 'is true for symbol keys' do - subject.new(awesome: 'sauce').should be_respond_to(:awesome) + expect(subject.new(awesome: 'sauce')).to be_respond_to(:awesome) end it 'is false for non-keys' do - subject.new.should_not be_respond_to(:awesome) + expect(subject.new).not_to be_respond_to(:awesome) end end end @@ -53,22 +53,22 @@ describe Hashie::Extensions::MethodWriter do it 'writes from a method call' do subject.awesome = 'sauce' - subject['awesome'].should eq 'sauce' + expect(subject['awesome']).to eq 'sauce' end it 'converts the key using the #convert_key method' do - subject.stub!(:convert_key).and_return(:awesome) + allow(subject).to receive(:convert_key).and_return(:awesome) subject.awesome = 'sauce' - subject[:awesome].should eq 'sauce' + expect(subject[:awesome]).to eq 'sauce' end it 'raises NoMethodError on non equals-ending methods' do - lambda { subject.awesome }.should raise_error(NoMethodError) + expect { subject.awesome }.to raise_error(NoMethodError) end it '#respond_to? correctly' do - subject.should be_respond_to(:abc=) - subject.should_not be_respond_to(:abc) + expect(subject).to be_respond_to(:abc=) + expect(subject).not_to be_respond_to(:abc) end end @@ -84,31 +84,31 @@ describe Hashie::Extensions::MethodQuery do subject { QueryHash } it 'is true for non-nil string key values' do - subject.new('abc' => 123).should be_abc + expect(subject.new('abc' => 123)).to be_abc end it 'is true for non-nil symbol key values' do - subject.new(abc: 123).should be_abc + expect(subject.new(abc: 123)).to be_abc end it 'is false for nil key values' do - subject.new(abc: false).should_not be_abc + expect(subject.new(abc: false)).not_to be_abc end it 'raises a NoMethodError for non-set keys' do - lambda { subject.new.abc? }.should raise_error(NoMethodError) + expect { subject.new.abc? }.to raise_error(NoMethodError) end it '#respond_to? for existing string keys' do - subject.new('abc' => 'def').should be_respond_to('abc?') + expect(subject.new('abc' => 'def')).to be_respond_to('abc?') end it '#respond_to? for existing symbol keys' do - subject.new(abc: 'def').should be_respond_to(:abc?) + expect(subject.new(abc: 'def')).to be_respond_to(:abc?) end it 'does not #respond_to? for non-existent keys' do - subject.new.should_not be_respond_to('abc?') + expect(subject.new).not_to be_respond_to('abc?') end end @@ -116,6 +116,6 @@ describe Hashie::Extensions::MethodAccess do it 'includes all of the other method mixins' do klass = Class.new(Hash) klass.send :include, Hashie::Extensions::MethodAccess - (klass.ancestors & [Hashie::Extensions::MethodReader, Hashie::Extensions::MethodWriter, Hashie::Extensions::MethodQuery]).size.should eq 3 + expect((klass.ancestors & [Hashie::Extensions::MethodReader, Hashie::Extensions::MethodWriter, Hashie::Extensions::MethodQuery]).size).to eq 3 end end |