spec/author_spec.rb in toadie-0.0.7 vs spec/author_spec.rb in toadie-0.0.8
- old
+ new
@@ -2,53 +2,53 @@
describe Toadie::Author do
let(:author) { Toadie::Author.new(name: 'Geordi LaForge', emails: ['Geordi@uss-enterprise.com'], nicknames: ['geordi', 'laforge']) }
it "sets attributes on initialize" do
- author.name.should == 'Geordi LaForge'
- author.emails.should == ['Geordi@uss-enterprise.com']
- author.nicknames.should == ['geordi', 'laforge']
+ expect(author.name).to eq 'Geordi LaForge'
+ expect(author.emails).to eq ['Geordi@uss-enterprise.com']
+ expect(author.nicknames).to eq ['geordi', 'laforge']
end
it "builds a identifier by using the email" do
- author.identifier.should == 'geordiussenterprisecom'
+ expect(author.identifier).to eq 'geordiussenterprisecom'
end
describe "#to_s" do
it "uses the name attribute if present" do
- author.to_s.should == "Geordi LaForge"
+ expect(author.to_s).to eq "Geordi LaForge"
end
it "uses a nickname if present" do
author.name = nil
- author.to_s.should == 'geordi'
+ expect(author.to_s).to eq 'geordi'
end
it "uses the email address finally" do
author.name = nil
author.nicknames = []
- author.to_s.should == 'Geordi@uss-enterprise.com'
+ expect(author.to_s).to eq 'Geordi@uss-enterprise.com'
end
end
describe "#find_by_email" do
it "returns a author if it exists" do
author = Toadie::Author.create(emails: ['androids@humanafterall.org', 'data@uss-enterprise.com'])
- Toadie::Author.find_by_email('data@uss-enterprise.com').should == author
+ expect(Toadie::Author.find_by_email('data@uss-enterprise.com')).to eq author
end
it "returns nil if no author was found" do
- Toadie::Author.find_by_email('q@uss-enterprise.com').should be_nil
+ expect(Toadie::Author.find_by_email('q@uss-enterprise.com')).to be_nil
end
end
describe "#create" do
it "assigns all attributes to the author" do
author = Toadie::Author.create(emails: ['data@uss-enterprise.com'], name: 'Data', nicknames: ['data'])
- author.name.should == 'Data'
- author.emails.should == ['data@uss-enterprise.com']
- author.nicknames.should == ['data']
+ expect(author.name).to eq 'Data'
+ expect(author.emails).to eq ['data@uss-enterprise.com']
+ expect(author.nicknames).to eq ['data']
end
it "works with symbolized hash key" do
expect {
Toadie::Author.create(emails: ['Data@uss-enterprise.com'])
@@ -70,19 +70,19 @@
describe "#find_or_create" do
it "returns a author if it was found" do
author = Toadie::Author.create(emails: ['no1@uss-enterprise.com'])
expect {
- Toadie::Author.find_or_create('no1@uss-enterprise.com').should == author
+ expect(Toadie::Author.find_or_create('no1@uss-enterprise.com')).to eq author
}.to_not change { Toadie::Author.all.size }
end
it "creates a author if it was not found" do
expect {
author = Toadie::Author.find_or_create('no1@uss-enterprise.com', name: 'William T. Riker', nicknames: ['riker', 'no1'])
- author.emails.should == ['no1@uss-enterprise.com']
- author.name.should == 'William T. Riker'
- author.nicknames.should == ['riker', 'no1']
+ expect(author.emails).to eq ['no1@uss-enterprise.com']
+ expect(author.name).to eq 'William T. Riker'
+ expect(author.nicknames).to eq ['riker', 'no1']
}.to change { Toadie::Author.all.size }.by(1)
end
end
-end
\ No newline at end of file
+end