diff --git a/spec/application_helper_spec.rb b/spec/application_helper_spec.rb index f81aafe9cd..128caf87b6 100644 --- a/spec/application_helper_spec.rb +++ b/spec/application_helper_spec.rb @@ -52,11 +52,11 @@ describe ApplicationHelper do before do @project = project - User.stub(:current).and_return project_member + allow(User).to receive(:current).and_return project_member end after do - User.unstub(:current) + allow(User).to receive(:current).and_call_original end context "Simple Document links" do @@ -67,25 +67,25 @@ describe ApplicationHelper do context "Plain link" do subject { textilizable("document##{document.id}") } - it { should eq("
#{document_link}
") } + it { is_expected.to eq("#{document_link}
") } end context "Link with document name" do subject { textilizable("document##{document.id}") } - it { should eq("#{document_link}
") } + it { is_expected.to eq("#{document_link}
") } end context "Escaping plain link" do subject { textilizable("!document##{document.id}") } - it { should eq("document##{document.id}
") } + it { is_expected.to eq("document##{document.id}
") } end context "Escaping link with document name" do subject { textilizable('!document:"Test document"') } - it { should eq('document:"Test document"
') } + it { is_expected.to eq('document:"Test document"
') } end end @@ -95,25 +95,25 @@ describe ApplicationHelper do context "By name without project" do subject { textilizable("document:\"#{document.title}\"", :project => the_other_project) } - it { should eq('document:"Test document"
') } + it { is_expected.to eq('document:"Test document"
') } end context "By id and given project" do subject { textilizable("#{identifier}:document##{document.id}", :project => the_other_project) } - it { should eq("") } + it { is_expected.to eq("") } end context "By name and given project" do subject { textilizable("#{identifier}:document:\"#{document.title}\"", :project => the_other_project) } - it { should eq("") } + it { is_expected.to eq("") } end context "Invalid link" do subject { textilizable("invalid:document:\"Test document\"", :project => the_other_project) } - it { should eq('invalid:document:"Test document"
') } + it { is_expected.to eq('invalid:document:"Test document"
') } end end end diff --git a/spec/controllers/documents_controller_spec.rb b/spec/controllers/documents_controller_spec.rb index a140eaa01b..6b6f40253f 100644 --- a/spec/controllers/documents_controller_spec.rb +++ b/spec/controllers/documents_controller_spec.rb @@ -44,7 +44,7 @@ describe DocumentsController do before do - User.stub(:current).and_return admin + allow(User).to receive(:current).and_return admin end describe "index" do @@ -76,9 +76,9 @@ LOREM it "should render documents with long descriptions properly" do - response.body.should have_css('.wiki p') - response.body.should have_css('.wiki p', text: (document.description.split("\n").first + '...')) - response.body.should have_css('.wiki p', text: /EndOfLineHere.../) + expect(response.body).to have_css('.wiki p') + expect(response.body).to have_css('.wiki p', text: (document.description.split("\n").first + '...')) + expect(response.body).to have_css('.wiki p', text: /EndOfLineHere.../) end diff --git a/spec/lib/acts_as_journalized/journaled_spec.rb b/spec/lib/acts_as_journalized/journaled_spec.rb index 2cf04496b0..58241fefe8 100644 --- a/spec/lib/acts_as_journalized/journaled_spec.rb +++ b/spec/lib/acts_as_journalized/journaled_spec.rb @@ -36,7 +36,7 @@ describe "Journalized Objects" do @type ||= FactoryGirl.create(:type_feature) @project ||= FactoryGirl.create(:project_with_types) @current = FactoryGirl.create(:user, :login => "user1", :mail => "user1@users.com") - User.stub(:current).and_return @current + allow(User).to receive(:current).and_return @current end it 'should work with documents' do @@ -45,6 +45,6 @@ describe "Journalized Objects" do initial_journal = @document.journals.first recreated_journal = @document.recreate_initial_journal! - initial_journal.should be_identical(recreated_journal) + expect(initial_journal).to be_identical(recreated_journal) end end diff --git a/spec/models/document_observer_spec.rb b/spec/models/document_observer_spec.rb index 9be00ff95a..3004e74e66 100644 --- a/spec/models/document_observer_spec.rb +++ b/spec/models/document_observer_spec.rb @@ -38,7 +38,7 @@ describe DocumentObserver do let(:mail) do mock = Object.new - mock.stub(:deliver) + allow(mock).to receive(:deliver) mock end @@ -46,18 +46,18 @@ describe DocumentObserver do it "is triggered, when a document has been created" do document = FactoryGirl.build(:document) #observers are singletons, so any_instance exactly leaves out the singleton - DocumentObserver.instance.should_receive(:after_create) + expect(DocumentObserver.instance).to receive(:after_create) document.save! end it "calls the DocumentsMailer, when a new document has been added" do document = FactoryGirl.build(:document) # make sure, that we have actually someone to notify - document.stub(:recipients).and_return(user.mail) + allow(document).to receive(:recipients).and_return(user.mail) # ... and notifies are actually sent out - Notifier.stub(:notify?).and_return(true) + allow(Notifier).to receive(:notify?).and_return(true) - DocumentsMailer.should_receive(:document_added).and_return(mail) + expect(DocumentsMailer).to receive(:document_added).and_return(mail) document.save end diff --git a/spec/models/document_spec.rb b/spec/models/document_spec.rb index 23dd839d35..a8447b8c9b 100644 --- a/spec/models/document_spec.rb +++ b/spec/models/document_spec.rb @@ -40,9 +40,9 @@ describe Document do context "validation" do - it { should validate_presence_of :project} - it { should validate_presence_of :title} - it { should validate_presence_of :category} + it { is_expected.to validate_presence_of :project} + it { is_expected.to validate_presence_of :title} + it { is_expected.to validate_presence_of :category} end @@ -57,8 +57,8 @@ describe Document do end it "should send out email-notifications" do - valid_document.stub(:recipients).and_return([user.mail]) - Notifier.stub(:notify?).with(:document_added).and_return(true) + allow(valid_document).to receive(:recipients).and_return([user.mail]) + allow(Notifier).to receive(:notify?).with(:document_added).and_return(true) expect{ valid_document.save @@ -67,7 +67,7 @@ describe Document do end it "should send notifications to the recipients of the project" do - project.stub(:notified_users).and_return([admin]) + allow(project).to receive(:notified_users).and_return([admin]) document = FactoryGirl.create(:document, project: project) expect(document.recipients).not_to be_empty diff --git a/spec/routing/documents_routing_spec.rb b/spec/routing/documents_routing_spec.rb index 4414dc9c7b..3f4cc7ee6c 100644 --- a/spec/routing/documents_routing_spec.rb +++ b/spec/routing/documents_routing_spec.rb @@ -33,31 +33,31 @@ require 'spec_helper' describe DocumentsController do describe "routing" do - it { get('/projects/567/documents').should route_to(:controller => 'documents', + it { expect(get('/projects/567/documents')).to route_to(:controller => 'documents', :action => 'index', :project_id => '567' ) } - it { get('/projects/567/documents/new').should route_to(:controller => 'documents', + it { expect(get('/projects/567/documents/new')).to route_to(:controller => 'documents', :action => 'new', :project_id => '567' ) } - it { get('/documents/22').should route_to(:controller => 'documents', + it { expect(get('/documents/22')).to route_to(:controller => 'documents', :action => 'show', :id => '22') } - it { get('/documents/22/edit').should route_to(:controller => 'documents', + it { expect(get('/documents/22/edit')).to route_to(:controller => 'documents', :action => 'edit', :id => '22') } - it { post('/projects/567/documents').should route_to(:controller => 'documents', + it { expect(post('/projects/567/documents')).to route_to(:controller => 'documents', :action => 'create', :project_id => '567') } - it { put('/documents/567').should route_to(:controller => 'documents', + it { expect(put('/documents/567')).to route_to(:controller => 'documents', :action => 'update', :id => '567') } - it { delete('/documents/567').should route_to(:controller => 'documents', + it { expect(delete('/documents/567')).to route_to(:controller => 'documents', :action => 'destroy', :id => '567') } end