spec/resume_spec.rb in resumetools-0.2.7.6 vs spec/resume_spec.rb in resumetools-0.2.8

- old
+ new

@@ -1,20 +1,20 @@ #-- # Copyright (c) 2009 Virgil Dimaguila -# +# # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation # files (the "Software"), to deal in the Software without # restriction, including without limitation the rights to use, # copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following # conditions: -# +# # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. -# +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, @@ -25,11 +25,11 @@ require File.join(File.dirname(__FILE__), "spec_helper") def resume_attributes - { + { :full_name => "Albert Einstein", :url => "http://phys6.science.org/einstein", :email => "albert.einstein@science.org", :telephone => "(555) 123-4567", :address1 => "221 Relativity Circle", @@ -59,95 +59,99 @@ describe "Resume" do before do @attributes = resume_attributes end - + it "has initial properties after creation" do @resume = ResumeTools::Resume.new - @resume.full_name.should be_blank - @resume.has_url?.should be_false - @resume.has_email?.should be_false - @resume.has_telephone?.should be_false - @resume.has_address1?.should be_false - @resume.has_address2?.should be_false - @resume.has_sections?.should be_false + + expect(@resume.full_name).to be_blank + expect(@resume.has_url?).to be false + expect(@resume.has_email?).to be false + expect(@resume.has_telephone?).to be false + expect(@resume.has_address1?).to be false + expect(@resume.has_address2?).to be false + expect(@resume.has_sections?).to be false end - + it "is created with hash properties" do @resume = ResumeTools::Resume.new(@attributes) - @resume.has_url?.should be_true - @resume.has_email?.should be_true - @resume.has_telephone?.should be_true - @resume.has_address1?.should be_true - @resume.has_address2?.should be_true - - @resume.full_name.should == @attributes[:full_name] - @resume.url.should == @attributes[:url] - @resume.telephone.should == @attributes[:telephone] - @resume.address1.should == @attributes[:address1] - @resume.address2.should == @attributes[:address2] - @resume.should have(0).sections + + expect(@resume.has_url?).to be true + expect(@resume.has_email?).to be true + expect(@resume.has_telephone?).to be true + expect(@resume.has_address1?).to be true + expect(@resume.has_address2?).to be true + + expect(@resume.full_name).to eq @attributes[:full_name] + expect(@resume.url).to eq @attributes[:url] + expect(@resume.telephone).to eq @attributes[:telephone] + expect(@resume.address1).to eq @attributes[:address1] + expect(@resume.address2).to eq @attributes[:address2] + expect(@resume.sections.length).to eq 0 end end describe "Section" do before(:each) do @resume = ResumeTools::Resume.new(resume_attributes) @attributes = section_attributes end - + it "is created in resume" do @resume.create_section do |s| s.title = @attributes[:title] s.para = @attributes[:para] end - - @resume.should have(1).sections - @resume.has_sections?.should be_true + + expect(@resume.sections.length).to eq 1 + expect(@resume.has_sections?).to be true + section = @resume.sections[0] - section.title.should == @attributes[:title] - section.para.should == @attributes[:para] + expect(section.title).to eq @attributes[:title] + expect(section.para).to eq @attributes[:para] end - + it "should have no items" do section = ResumeTools::Section.new - section.should have(0).items - section.has_items?.should be_false + expect(section.items.length).to eq 0 + expect(section.has_items?).to be false end - + it "should have no periods" do section = ResumeTools::Section.new - section.has_periods?.should be_false + expect(section.has_periods?).to be false end - - + + it "should be able to add items" do section = ResumeTools::Section.new section.create_item do |item| item.text = "This is item A." end - section.should have(1).items + expect(section.items.length).to eq 1 + section.add_item(ResumeTools::Item.new(:text => "This is item B.")) - section.should have(2).items - section.items[0].text.should == "This is item A." - section.items[1].text.should == "This is item B." - section.has_items?.should be_true + expect(section.items.length).to eq 2 + expect(section.items[0].text).to eq "This is item A." + expect(section.items[1].text).to eq "This is item B." + expect(section.has_items?).to be true end - + it "is created in the right order" do @resume.create_section do |s| s.title = "First" end @resume.create_section do |s| s.title = "Second" end - - @resume.sections[0].title.should == "First" - @resume.sections[1].title.should == "Second" + + expect(@resume.sections[0].title).to eq "First" + expect(@resume.sections[1].title).to eq "Second" end end describe "Period" do @@ -155,36 +159,36 @@ @resume = ResumeTools::Resume.new(resume_attributes) @resume.create_section(section_attributes) @section = @resume.sections[0] @attributes = period_attributes end - + it "is created in a section" do @section.create_period do |p| p.title = @attributes[:title] p.location = @attributes[:location] p.organization = @attributes[:organization] p.dtstart = @attributes[:dtstart] p.dtend = @attributes[:dtend] end - - @section.should have(1).periods + expect(@section.periods.length).to eq 1 + period = @section.periods[0] - period.title.should == @attributes[:title] - period.location.should == @attributes[:location] - period.organization.should == @attributes[:organization] - period.dtstart.should == @attributes[:dtstart] - period.dtend.should == @attributes[:dtend] + expect(period.title).to eq @attributes[:title] + expect(period.location).to eq @attributes[:location] + expect(period.organization).to eq @attributes[:organization] + expect(period.dtstart).to eq @attributes[:dtstart] + expect(period.dtend).to eq @attributes[:dtend] end - + it "is added in the right order" do @section.create_period :title => "First" @section.create_period :title => "Second" - - @section.should have(2).periods - @section.periods[0].title.should == "First" - @section.periods[1].title.should == "Second" + + expect(@section.periods.length).to eq 2 + expect(@section.periods[0].title).to eq "First" + expect(@section.periods[1].title).to eq "Second" end end describe "Item" do @@ -193,25 +197,25 @@ @resume.create_section(section_attributes) @resume.sections[0].create_period(period_attributes) @period = @resume.sections[0].periods[0] @attributes = item_attributes end - + it "is created in a period" do @period.create_item do |i| i.text = @attributes[:text] end - - @period.should have(1).items + + expect(@period.items.length).to eq 1 item = @period.items[0] - item.text.should == @attributes[:text] + expect(item.text).to eq @attributes[:text] end - + it "is addd in the right order" do @period.create_item :text => "First" @period.create_item :text => "Second" - - @period.should have(2).items - @period.items[0].text.should == "First" - @period.items[1].text.should == "Second" + + expect(@period.items.length).to eq 2 + expect(@period.items[0].text).to eq "First" + expect(@period.items[1].text).to eq "Second" end end