spec/verifier_spec.rb in yard-0.8.7.6 vs spec/verifier_spec.rb in yard-0.9.0

- old
+ new

@@ -1,104 +1,104 @@ require File.dirname(__FILE__) + '/spec_helper' describe YARD::Verifier do - describe '#parse_expressions' do - it "should create #__execute method" do + describe "#parse_expressions" do + it "creates #__execute method" do v = Verifier.new("expr1") - v.should respond_to(:__execute) + expect(v).to respond_to(:__execute) end - it "should parse @tagname into tag('tagname')" do - obj = mock(:object) - obj.should_receive(:tag).with('return') + it "parses @tagname into tag('tagname')" do + obj = double(:object) + expect(obj).to receive(:tag).with('return') Verifier.new('@return').call(obj) end - it "should parse @@tagname into object.tags('tagname')" do - obj = mock(:object) - obj.should_receive(:tags).with('return') + it "parses @@tagname into object.tags('tagname')" do + obj = double(:object) + expect(obj).to receive(:tags).with('return') Verifier.new('@@return').call(obj) end - it "should allow namespaced tag using @{} syntax" do - obj = mock(:object) - obj.should_receive(:tag).with('yard.return') + it "allows namespaced tag using @{} syntax" do + obj = double(:object) + expect(obj).to receive(:tag).with('yard.return') Verifier.new('@{yard.return}').call(obj) end - it "should allow namespaced tags using @{} syntax" do - obj = mock(:object) - obj.should_receive(:tags).with('yard.return') + it "allows namespaced tags using @{} syntax" do + obj = double(:object) + expect(obj).to receive(:tags).with('yard.return') Verifier.new('@@{yard.return}').call(obj) end - it "should call methods on tag object" do - obj = mock(:object) - obj2 = mock(:tag) - obj.should_receive(:tag).with('return').and_return obj2 - obj2.should_receive(:foo) + it "calls methods on tag object" do + obj = double(:object) + obj2 = double(:tag) + expect(obj).to receive(:tag).with('return').and_return obj2 + expect(obj2).to receive(:foo) Verifier.new('@return.foo').call(obj) end - it "should send any missing methods to object" do - obj = mock(:object) - obj.should_receive(:has_tag?).with('return') + it "sends any missing methods to object" do + obj = double(:object) + expect(obj).to receive(:has_tag?).with('return') Verifier.new('has_tag?("return")').call(obj) end - it "should allow multiple expressions" do - obj = mock(:object) - obj.should_receive(:tag).with('return').and_return(true) - obj.should_receive(:tag).with('param').and_return(false) - Verifier.new('@return', '@param').call(obj).should == false + it "allows multiple expressions" do + obj = double(:object) + expect(obj).to receive(:tag).with('return').and_return(true) + expect(obj).to receive(:tag).with('param').and_return(false) + expect(Verifier.new('@return', '@param').call(obj)).to be false end end - describe '#o' do - it "should alias object to o" do - obj = mock(:object) - obj.should_receive(:a).ordered + describe "#o" do + it "aliases object to o" do + obj = double(:object) + expect(obj).to receive(:a).ordered Verifier.new('o.a').call(obj) end end - describe '#call' do - it "should mock a nonexistent tag so that exceptions are not raised" do - obj = mock(:object) - obj.should_receive(:tag).and_return(nil) - Verifier.new('@return.text').call(obj).should == false + describe "#call" do + it "doubles a nonexistent tag so that exceptions are not raised" do + obj = double(:object) + expect(obj).to receive(:tag).and_return(nil) + expect(Verifier.new('@return.text').call(obj)).to be false end - it "should not fail if no expressions were added" do - lambda { Verifier.new.call(nil) }.should_not raise_error + it "does not fail if no expressions were added" do + expect { Verifier.new.call(nil) }.not_to raise_error end - it "should always ignore proxy objects and return true" do + it "always ignores proxy objects and return true" do v = Verifier.new('tag(:x)') - lambda { v.call(P('foo')).should == true }.should_not raise_error + expect { expect(v.call(P('foo'))).to be true }.not_to raise_error end end - describe '#expressions' do - it "should maintain a list of all unparsed expressions" do - Verifier.new('@return.text', '@private').expressions.should == ['@return.text', '@private'] + describe "#expressions" do + it "maintains a list of all unparsed expressions" do + expect(Verifier.new('@return.text', '@private').expressions).to eq ['@return.text', '@private'] end end - describe '#expressions=' do - it "should recompile expressions when attribute is modified" do - obj = mock(:object) - obj.should_receive(:tag).with('return') + describe "#expressions=" do + it "recompiles expressions when attribute is modified" do + obj = double(:object) + expect(obj).to receive(:tag).with('return') v = Verifier.new v.expressions = ['@return'] v.call(obj) end end - describe '#add_expressions' do - it "should add new expressions and recompile" do - obj = mock(:object) - obj.should_receive(:tag).with('return') + describe "#add_expressions" do + it "adds new expressions and recompile" do + obj = double(:object) + expect(obj).to receive(:tag).with('return') v = Verifier.new v.add_expressions '@return' v.call(obj) end end \ No newline at end of file