Permalink
Browse files

Replace @instance with let(:instance)

  • Loading branch information...
1 parent d37aecb commit 73d24c2b3fcc6656dc3c94f843bf946fdd4577f1 @weppos committed Oct 29, 2012
@@ -8,7 +8,9 @@
end
it "requires the URL argument" do
- lambda { klass.new }.should raise_error(ArgumentError)
+ expect {
+ klass.new
+ }.to raise_error(ArgumentError)
end
end
@@ -2,9 +2,9 @@
describe Whois::Record::Parser::Base do
- before(:each) do
- @part = Whois::Record::Part.new(:body => "This is the response.", :host => "whois.example.test")
- end
+ let(:part) {
+ Whois::Record::Part.new(body: "This is the response.", host: "whois.example.test")
+ }
describe ".property_register" do
@@ -20,35 +20,35 @@
it "returns false if the property is not supported" do
koncrete = Class.new(klass) do
end
- koncrete.new(@part).property_supported?(:disclaimer).should be_false
- koncrete.new(@part).respond_to?(:disclaimer).should be_true
+ koncrete.new(part).property_supported?(:disclaimer).should be_false
+ koncrete.new(part).respond_to?(:disclaimer).should be_true
end
it "returns true if the property is supported" do
koncrete = Class.new(klass) do
property_register(:disclaimer, :supported) {}
end
- koncrete.new(@part).property_supported?(:disclaimer).should be_true
- koncrete.new(@part).respond_to?(:disclaimer).should be_true
+ koncrete.new(part).property_supported?(:disclaimer).should be_true
+ koncrete.new(part).respond_to?(:disclaimer).should be_true
end
end
describe "#initialize" do
it "requires a part" do
lambda { klass.new }.should raise_error(ArgumentError)
- lambda { klass.new(@part) }.should_not raise_error
+ lambda { klass.new(part) }.should_not raise_error
end
it "sets the part" do
- klass.new(@part).part.should be(@part)
+ klass.new(part).part.should be(part)
end
end
describe "#content" do
it "returns the part body" do
- i = klass.new(@part)
- i.content.should be(@part.body)
+ i = klass.new(part)
+ i.content.should be(part.body)
end
end
@@ -99,28 +99,28 @@
describe "#changed?" do
it "raises if the argument is not an instance of the same class" do
lambda do
- klass.new(@part).changed?(Object.new)
+ klass.new(part).changed?(Object.new)
end.should raise_error
lambda do
- klass.new(@part).changed?(klass.new(@part))
+ klass.new(part).changed?(klass.new(part))
end.should_not raise_error
end
end
describe "#unchanged?" do
it "raises if the argument is not an instance of the same class" do
lambda do
- klass.new(@part).unchanged?(Object.new)
+ klass.new(part).unchanged?(Object.new)
end.should raise_error
lambda do
- klass.new(@part).unchanged?(klass.new(@part))
+ klass.new(part).unchanged?(klass.new(part))
end.should_not raise_error
end
it "returns true if self and other references the same object" do
- i = klass.new(@part)
+ i = klass.new(part)
i.unchanged?(i).should be_true
end
@@ -146,62 +146,62 @@
property_supported(:registrant_contacts) { [c1, c2] }
property_supported(:admin_contacts) { [] }
property_supported(:technical_contacts) { [c3] }
- end.new(@part)
+ end.new(part)
koncrete.contacts.should == [c1, c2, c3]
end
it "returns an empty array when no contact is supported" do
- i = klass.new(@part)
+ i = klass.new(part)
i.contacts.should == []
end
end
describe "#response_incomplete?" do
it "is undefined" do
- klass.new(@part).respond_to?(:response_incomplete?).should be_false
+ klass.new(part).respond_to?(:response_incomplete?).should be_false
end
# it "returns nil" do
- # i = klass.new(@part)
+ # i = klass.new(part)
# i.response_incomplete?.should be_nil
# end
#
# it "is false" do
- # i = klass.new(@part)
+ # i = klass.new(part)
# i.response_incomplete?.should be_false
# end
end
describe "#response_throttled?" do
it "is undefined" do
- klass.new(@part).respond_to?(:response_throttled?).should be_false
+ klass.new(part).respond_to?(:response_throttled?).should be_false
end
# it "returns nil" do
- # i = klass.new(@part)
+ # i = klass.new(part)
# i.response_throttled?.should be_nil
# end
#
# it "is false" do
- # i = klass.new(@part)
+ # i = klass.new(part)
# i.response_throttled?.should be_false
# end
end
describe "#response_unavailable?" do
it "is undefined" do
- klass.new(@part).respond_to?(:response_unavailable?).should be_false
+ klass.new(part).respond_to?(:response_unavailable?).should be_false
end
# it "returns nil" do
- # i = klass.new(@part)
+ # i = klass.new(part)
# i.response_unavailable?.should be_nil
# end
#
# it "is false" do
- # i = klass.new(@part)
+ # i = klass.new(part)
# i.response_unavailable?.should be_false
# end
end
@@ -3,16 +3,16 @@
describe Whois::Record::Parser::Blank do
- before(:each) do
- @part = Whois::Record::Part.new(:body => "This is the response.", :host => "whois.example.test")
- end
+ let(:part) {
+ Whois::Record::Part.new(body: "This is the response.", host: "whois.example.test")
+ }
Whois::Record::Parser::PROPERTIES.each do |method|
describe method do
it "raises Whois::ParserNotFound" do
- lambda do
- klass.new(@part).send(method)
- end.should raise_error(Whois::ParserNotFound, /whois.example.test/)
+ expect {
+ described_class.new(part).send(method)
+ }.to raise_error(Whois::ParserNotFound, /whois.example.test/)
end
end
end
@@ -2,9 +2,7 @@
describe Whois::Record::Parser do
- before(:each) do
- @record = Whois::Record.new(nil, [])
- end
+ let(:record) { Whois::Record.new(nil, []) }
describe ".parser_klass" do
@@ -46,12 +44,12 @@ class PreloadedParserTest
describe "#initialize" do
it "requires an record" do
lambda { klass.new }.should raise_error(ArgumentError)
- lambda { klass.new(@record) }.should_not raise_error
+ lambda { klass.new(record) }.should_not raise_error
end
it "sets record from argument" do
- instance = klass.new(@record)
- instance.record.should be(@record)
+ instance = klass.new(record)
+ instance.record.should be(record)
end
end
@@ -246,28 +244,28 @@ class Whois::Record::Parser::Contacts3Test< Whois::Record::Parser::Base
describe "#changed?" do
it "raises if the argument is not an instance of the same class" do
lambda do
- klass.new(@record).changed?(Object.new)
+ klass.new(record).changed?(Object.new)
end.should raise_error
lambda do
- klass.new(@record).changed?(klass.new(@record))
+ klass.new(record).changed?(klass.new(record))
end.should_not raise_error
end
end
describe "#unchanged?" do
it "raises if the argument is not an instance of the same class" do
lambda do
- klass.new(@record).unchanged?(Object.new)
+ klass.new(record).unchanged?(Object.new)
end.should raise_error
lambda do
- klass.new(@record).unchanged?(klass.new(@record))
+ klass.new(record).unchanged?(klass.new(record))
end.should_not raise_error
end
it "returns true if self and other references the same object" do
- instance = klass.new(@record)
+ instance = klass.new(record)
instance.unchanged?(instance).should be_true
end
Oops, something went wrong. Retry.

0 comments on commit 73d24c2

Please sign in to comment.