Convert specs to RSpec 3.2.0 syntax with Transpec

This conversion is done by Transpec 3.1.0 with the following command:
    transpec -sf

* 11 conversions
    from: it { should ... }
      to: it { is_expected.to ... }

* 11 conversions
    from: obj.should
      to: expect(obj).to

* 9 conversions
    from: obj.stub(:message)
      to: allow(obj).to receive(:message)

* 2 conversions
    from: obj.should_receive(:message)
      to: expect(obj).to receive(:message)

* 1 conversion
    from: obj.unstub(:message)
      to: allow(obj).to receive(:message).and_call_original

For more details: https://github.com/yujinakayama/transpec#supported-conversions
pull/6827/head
Alex Coles 10 years ago
parent e6ce1199e8
commit 124e905c58
  1. 20
      spec/application_helper_spec.rb
  2. 8
      spec/controllers/documents_controller_spec.rb
  3. 4
      spec/lib/acts_as_journalized/journaled_spec.rb
  4. 10
      spec/models/document_observer_spec.rb
  5. 12
      spec/models/document_spec.rb
  6. 14
      spec/routing/documents_routing_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("<p>#{document_link}</p>") }
it { is_expected.to eq("<p>#{document_link}</p>") }
end
context "Link with document name" do
subject { textilizable("document##{document.id}") }
it { should eq("<p>#{document_link}</p>") }
it { is_expected.to eq("<p>#{document_link}</p>") }
end
context "Escaping plain link" do
subject { textilizable("!document##{document.id}") }
it { should eq("<p>document##{document.id}</p>") }
it { is_expected.to eq("<p>document##{document.id}</p>") }
end
context "Escaping link with document name" do
subject { textilizable('!document:"Test document"') }
it { should eq('<p>document:"Test document"</p>') }
it { is_expected.to eq('<p>document:"Test document"</p>') }
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('<p>document:"Test document"</p>') }
it { is_expected.to eq('<p>document:"Test document"</p>') }
end
context "By id and given project" do
subject { textilizable("#{identifier}:document##{document.id}", :project => the_other_project) }
it { should eq("<p><a href=\"/documents/#{document.id}\" class=\"document\">Test document</a></p>") }
it { is_expected.to eq("<p><a href=\"/documents/#{document.id}\" class=\"document\">Test document</a></p>") }
end
context "By name and given project" do
subject { textilizable("#{identifier}:document:\"#{document.title}\"", :project => the_other_project) }
it { should eq("<p><a href=\"/documents/#{document.id}\" class=\"document\">Test document</a></p>") }
it { is_expected.to eq("<p><a href=\"/documents/#{document.id}\" class=\"document\">Test document</a></p>") }
end
context "Invalid link" do
subject { textilizable("invalid:document:\"Test document\"", :project => the_other_project) }
it { should eq('<p>invalid:document:"Test document"</p>') }
it { is_expected.to eq('<p>invalid:document:"Test document"</p>') }
end
end
end

@ -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

@ -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

@ -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

@ -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

@ -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

Loading…
Cancel
Save