From df0bff653717b29f1952041a0c449f9697b65b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= <me@mrzyx.de> Date: Mon, 6 Jan 2014 18:02:40 +0100 Subject: [PATCH] replace stub! with stub --- spec/controllers/conversations_controller_spec.rb | 2 +- spec/controllers/invitations_controller_spec.rb | 2 +- spec/controllers/photos_controller_spec.rb | 4 ++-- spec/controllers/posts_controller_spec.rb | 2 +- spec/controllers/registrations_controller_spec.rb | 2 +- spec/controllers/services_controller_spec.rb | 6 +++--- spec/controllers/status_messages_controller_spec.rb | 2 +- spec/controllers/users_controller_spec.rb | 2 +- spec/helpers/notifications_helper_spec.rb | 6 +++--- spec/helpers/stream_helper_spec.rb | 10 +++++----- spec/lib/configuration_methods_spec.rb | 2 +- .../diaspora/federated/relayable_retraction_spec.rb | 2 +- spec/lib/diaspora/federated/signed_retraction_spec.rb | 2 +- spec/lib/diaspora/mentionable_spec.rb | 2 +- spec/lib/postzord/dispatcher_spec.rb | 10 +++++----- spec/lib/stream/multi_spec.rb | 2 +- spec/models/aspect_membership_spec.rb | 2 +- spec/models/notification_spec.rb | 2 +- spec/models/notifications/private_message_spec.rb | 4 ++-- spec/models/user/connecting_spec.rb | 8 ++++---- spec/models/user_spec.rb | 4 ++-- spec/shared_behaviors/relayable.rb | 2 +- spec/workers/delete_post_from_service_spec.rb | 2 +- spec/workers/fetch_profile_photo_spec.rb | 4 ++-- spec/workers/http_multi_spec.rb | 2 +- spec/workers/post_to_service_spec.rb | 4 ++-- 26 files changed, 46 insertions(+), 46 deletions(-) diff --git a/spec/controllers/conversations_controller_spec.rb b/spec/controllers/conversations_controller_spec.rb index 58e065fec6..3c220c1290 100644 --- a/spec/controllers/conversations_controller_spec.rb +++ b/spec/controllers/conversations_controller_spec.rb @@ -122,7 +122,7 @@ describe ConversationsController do ) p = Postzord::Dispatcher.build(alice, cnv) - p.class.stub!(:new).and_return(p) + p.class.stub(:new).and_return(p) p.should_receive(:post) post :create, @hash end diff --git a/spec/controllers/invitations_controller_spec.rb b/spec/controllers/invitations_controller_spec.rb index 2e07876df5..deff87b81d 100644 --- a/spec/controllers/invitations_controller_spec.rb +++ b/spec/controllers/invitations_controller_spec.rb @@ -15,7 +15,7 @@ describe InvitationsController do describe "#create" do before do sign_in :user, @user - @controller.stub!(:current_user).and_return(@user) + @controller.stub(:current_user).and_return(@user) @referer = 'http://test.host/cats/foo' request.env["HTTP_REFERER"] = @referer end diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 1bd70b20fa..a3eb76f040 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -43,7 +43,7 @@ describe PhotosController do describe '#create' do before do - @controller.stub!(:file_handler).and_return(uploaded_photo) + @controller.stub(:file_handler).and_return(uploaded_photo) @params = {:photo => {:user_file => uploaded_photo, :aspect_ids => "all"} } end @@ -128,7 +128,7 @@ describe PhotosController do end it 'sends a retraction on delete' do - @controller.stub!(:current_user).and_return(alice) + @controller.stub(:current_user).and_return(alice) alice.should_receive(:retract).with(@alices_photo) delete :destroy, :id => @alices_photo.id end diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index 20b2d8a1c3..581cef719e 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -148,7 +148,7 @@ describe PostsController do end it 'sends a retraction on delete' do - controller.stub!(:current_user).and_return alice + controller.stub(:current_user).and_return alice message = alice.post(:status_message, :text => "hey", :to => alice.aspects.first.id) alice.should_receive(:retract).with(message) delete :destroy, :format => :js, :id => message.id diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 055c01ec53..94f5b27bbc 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -59,7 +59,7 @@ describe RegistrationsController do before do AppConfig.settings.enable_registrations = true user = FactoryGirl.build(:user) - User.stub!(:build).and_return(user) + User.stub(:build).and_return(user) end it "creates a user" do diff --git a/spec/controllers/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb index c6dcac3bcf..1fb9237a9c 100644 --- a/spec/controllers/services_controller_spec.rb +++ b/spec/controllers/services_controller_spec.rb @@ -15,7 +15,7 @@ describe ServicesController do before do sign_in :user, user - @controller.stub!(:current_user).and_return(user) + @controller.stub(:current_user).and_return(user) end describe '#index' do @@ -110,7 +110,7 @@ describe ServicesController do end it 'does not queue a job if the profile photo is set' do - @controller.stub!(:no_profile_image?).and_return false + @controller.stub(:no_profile_image?).and_return false Workers::FetchProfilePhoto.should_not_receive(:perform_async) @@ -118,7 +118,7 @@ describe ServicesController do end it 'queues a job to save user photo if the photo does not exist' do - @controller.stub!(:no_profile_image?).and_return true + @controller.stub(:no_profile_image?).and_return true Workers::FetchProfilePhoto.should_receive(:perform_async).with(user.id, anything(), "https://service.com/fallback_lowres.jpg") diff --git a/spec/controllers/status_messages_controller_spec.rb b/spec/controllers/status_messages_controller_spec.rb index e78aa1f636..ea0443b670 100644 --- a/spec/controllers/status_messages_controller_spec.rb +++ b/spec/controllers/status_messages_controller_spec.rb @@ -10,7 +10,7 @@ describe StatusMessagesController do request.env["HTTP_REFERER"] = "" sign_in :user, alice - @controller.stub!(:current_user).and_return(alice) + @controller.stub(:current_user).and_return(alice) alice.reload end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 4aa1a32aca..551e1d7e16 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -102,7 +102,7 @@ describe UsersController do it "uses devise's update with password" do @user.should_receive(:update_with_password).with(hash_including(@password_params)) - @controller.stub!(:current_user).and_return(@user) + @controller.stub(:current_user).and_return(@user) put :update, :id => @user.id, :user => @password_params end end diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index 75b372f402..9a00e02b00 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -38,19 +38,19 @@ describe NotificationsHelper do end it 'with two, does not comma seperate two actors' do - @note.stub!(:actors).and_return([@max, @sarah]) + @note.stub(:actors).and_return([@max, @sarah]) output.scan(/,/).should be_empty output.scan(/and/).count.should be 1 end it 'with three, comma seperates the first two, and and the last actor' do - @note.stub!(:actors).and_return([@max, @sarah, @daniel]) + @note.stub(:actors).and_return([@max, @sarah, @daniel]) output.scan(/,/).count.should be 2 output.scan(/and/).count.should be 1 end it 'with more than three, lists the first three, then the others tag' do - @note.stub!(:actors).and_return([@max, @sarah, @daniel, @ilya]) + @note.stub(:actors).and_return([@max, @sarah, @daniel, @ilya]) output.scan(/,/).count.should be 3 output.scan(/and/).count.should be 2 end diff --git a/spec/helpers/stream_helper_spec.rb b/spec/helpers/stream_helper_spec.rb index fc674eb4d2..0606fe052c 100644 --- a/spec/helpers/stream_helper_spec.rb +++ b/spec/helpers/stream_helper_spec.rb @@ -10,19 +10,19 @@ describe StreamHelper do @stream = Stream::Base.new(alice, :max_time => Time.now) end it 'works for public page' do - stub!(:controller).and_return(PostsController.new) + stub(:controller).and_return(PostsController.new) next_page_path.should include '/public' end it 'works for stream page when current page is stream' do - self.stub!("current_page?").and_return(true) - stub!(:controller).and_return(StreamsController.new) + self.stub("current_page?").and_return(true) + stub(:controller).and_return(StreamsController.new) next_page_path.should include stream_path end it 'works for activity page when current page is not stream' do - self.stub!("current_page?").and_return(false) - stub!(:controller).and_return(StreamsController.new) + self.stub("current_page?").and_return(false) + stub(:controller).and_return(StreamsController.new) next_page_path.should include activity_stream_path end end diff --git a/spec/lib/configuration_methods_spec.rb b/spec/lib/configuration_methods_spec.rb index e1ba743f16..ef99fde55c 100644 --- a/spec/lib/configuration_methods_spec.rb +++ b/spec/lib/configuration_methods_spec.rb @@ -148,7 +148,7 @@ describe Configuration::Methods do context "with a relative log set" do it "joins that with Rails.root" do path = "/some/path/" - Rails.stub!(:root).and_return(stub(join: path)) + Rails.stub(:root).and_return(stub(join: path)) @settings.environment.sidekiq.log = "relative_path" @settings.sidekiq_log.should match path end diff --git a/spec/lib/diaspora/federated/relayable_retraction_spec.rb b/spec/lib/diaspora/federated/relayable_retraction_spec.rb index d7b42159cd..d45e295d68 100644 --- a/spec/lib/diaspora/federated/relayable_retraction_spec.rb +++ b/spec/lib/diaspora/federated/relayable_retraction_spec.rb @@ -85,7 +85,7 @@ describe RelayableRetraction do @retraction = described_class.allocate @retraction.sender = @remote_raphael @retraction.target = @comment - @retraction.stub!(:parent_author_signature_valid?).and_return(true) + @retraction.stub(:parent_author_signature_valid?).and_return(true) @recipient = @local_luke end diff --git a/spec/lib/diaspora/federated/signed_retraction_spec.rb b/spec/lib/diaspora/federated/signed_retraction_spec.rb index 64bd0e230d..3649d0f936 100644 --- a/spec/lib/diaspora/federated/signed_retraction_spec.rb +++ b/spec/lib/diaspora/federated/signed_retraction_spec.rb @@ -28,7 +28,7 @@ describe SignedRetraction do r.target_type = remote_post.type r.target_guid = remote_post.guid r.sender = remote_post.author - r.stub!(:target_author_signature_valid?).and_return(true) + r.stub(:target_author_signature_valid?).and_return(true) } remote_retraction.dup.perform(bob) diff --git a/spec/lib/diaspora/mentionable_spec.rb b/spec/lib/diaspora/mentionable_spec.rb index 8e7819d20f..d6c4121af7 100644 --- a/spec/lib/diaspora/mentionable_spec.rb +++ b/spec/lib/diaspora/mentionable_spec.rb @@ -96,7 +96,7 @@ STR @test_txt_C = "mentioning #{@mention_C}" @test_txt_BC = "mentioning #{@mention_B}} and #{@mention_C}" - Diaspora::Mentionable.stub!(:current_user).and_return(@user_A) + Diaspora::Mentionable.stub(:current_user).and_return(@user_A) end it 'filters mention, if contact is not in a given aspect' do diff --git a/spec/lib/postzord/dispatcher_spec.rb b/spec/lib/postzord/dispatcher_spec.rb index d5fc319e88..3f18de0c55 100644 --- a/spec/lib/postzord/dispatcher_spec.rb +++ b/spec/lib/postzord/dispatcher_spec.rb @@ -204,7 +204,7 @@ describe Postzord::Dispatcher do @remote_people << alice.person @mailman = Postzord::Dispatcher.build(alice, @sm) @hydra = mock() - Typhoeus::Hydra.stub!(:new).and_return(@hydra) + Typhoeus::Hydra.stub(:new).and_return(@hydra) end it 'should queue an HttpMultiJob for the remote people' do @@ -277,7 +277,7 @@ describe Postzord::Dispatcher do end it 'queues a job to notify the hub' do - Workers::PostToService.stub!(:perform_async).with(anything, anything, anything) + Workers::PostToService.stub(:perform_async).with(anything, anything, anything) Workers::PublishToHub.should_receive(:perform_async).with(alice.public_url) @zord.send(:deliver_to_services, nil, []) end @@ -297,8 +297,8 @@ describe Postzord::Dispatcher do alice.services << @s2 mailman = Postzord::Dispatcher.build(alice, FactoryGirl.create(:status_message), :url => "http://joindiaspora.com/p/123", :services => [@s1]) - Workers::PublishToHub.stub!(:perform_async).with(anything) - Workers::HttpMulti.stub!(:perform_async).with(anything, anything, anything) + Workers::PublishToHub.stub(:perform_async).with(anything) + Workers::HttpMulti.stub(:perform_async).with(anything, anything, anything) Workers::PostToService.should_receive(:perform_async).with(@s1.id, anything, anything) mailman.post end @@ -306,7 +306,7 @@ describe Postzord::Dispatcher do it 'does not push to services if none are specified' do mailman = Postzord::Dispatcher.build(alice, FactoryGirl.create(:status_message), :url => "http://joindiaspora.com/p/123") - Workers::PublishToHub.stub!(:perform_async).with(anything) + Workers::PublishToHub.stub(:perform_async).with(anything) Workers::PostToService.should_not_receive(:perform_async).with(anything, anything, anything) mailman.post end diff --git a/spec/lib/stream/multi_spec.rb b/spec/lib/stream/multi_spec.rb index 8b21673942..e3c648e7ac 100644 --- a/spec/lib/stream/multi_spec.rb +++ b/spec/lib/stream/multi_spec.rb @@ -16,7 +16,7 @@ describe Stream::Multi do .with(alice, 'updated_at', @stream.max_time, AppConfig.settings.community_spotlight.enable? && alice.show_community_spotlight_in_stream?) - .and_return(mock.tap { |m| m.stub!(:make_relation!)}) + .and_return(mock.tap { |m| m.stub(:make_relation!)}) @stream.posts end end diff --git a/spec/models/aspect_membership_spec.rb b/spec/models/aspect_membership_spec.rb index 3325b528bf..7f4bc65f33 100644 --- a/spec/models/aspect_membership_spec.rb +++ b/spec/models/aspect_membership_spec.rb @@ -12,7 +12,7 @@ describe AspectMembership do @contact = alice.contact_for(bob.person) @am = alice.aspects.where(:name => "generic").first.aspect_memberships.first - @am.stub!(:user).and_return(alice) + @am.stub(:user).and_return(alice) end it 'calls disconnect if its the last aspect for the contact' do diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index 779cdb7c66..a0ec2c6412 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -80,7 +80,7 @@ describe Notification do :recipient_id => @user.id} n = Notifications::StartedSharing.new(opts) - n.stub!(:recipient).and_return @user + n.stub(:recipient).and_return @user @user.should_receive(:mail) n.email_the_user(@request, @person) diff --git a/spec/models/notifications/private_message_spec.rb b/spec/models/notifications/private_message_spec.rb index 4ef1408d36..f9ccffd14c 100644 --- a/spec/models/notifications/private_message_spec.rb +++ b/spec/models/notifications/private_message_spec.rb @@ -33,9 +33,9 @@ describe Notifications::PrivateMessage do :recipient_id => @user2.id} n = Notifications::PrivateMessage.new(opts) - Notifications::PrivateMessage.stub!(:make_notification).and_return(n) + Notifications::PrivateMessage.stub(:make_notification).and_return(n) Notification.notify(@user2, @msg, @user1.person) - n.stub!(:recipient).and_return @user2 + n.stub(:recipient).and_return @user2 @user2.should_receive(:mail) n.email_the_user(@msg, @user1.person) diff --git a/spec/models/user/connecting_spec.rb b/spec/models/user/connecting_spec.rb index 6f8250d2f7..387ebc1bc1 100644 --- a/spec/models/user/connecting_spec.rb +++ b/spec/models/user/connecting_spec.rb @@ -113,7 +113,7 @@ describe User::Connecting do it 'adds a contact to an aspect' do contact = alice.contacts.create(:person => eve.person) - alice.contacts.stub!(:find_or_initialize_by_person_id).and_return(contact) + alice.contacts.stub(:find_or_initialize_by_person_id).and_return(contact) lambda { alice.share_with(eve.person, alice.aspects.first) @@ -128,7 +128,7 @@ describe User::Connecting do context 'dispatching' do it 'dispatches a request on initial request' do contact = alice.contacts.new(:person => eve.person) - alice.contacts.stub!(:find_or_initialize_by_person_id).and_return(contact) + alice.contacts.stub(:find_or_initialize_by_person_id).and_return(contact) contact.should_receive(:dispatch_request) alice.share_with(eve.person, alice.aspects.first) @@ -138,7 +138,7 @@ describe User::Connecting do eve.share_with(alice.person, eve.aspects.first) contact = alice.contact_for(eve.person) - alice.contacts.stub!(:find_or_initialize_by_person_id).and_return(contact) + alice.contacts.stub(:find_or_initialize_by_person_id).and_return(contact) contact.should_receive(:dispatch_request) alice.share_with(eve.person, alice.aspects.first) @@ -148,7 +148,7 @@ describe User::Connecting do a2 = alice.aspects.create(:name => "two") contact = alice.contacts.create(:person => eve.person, :receiving => true) - alice.contacts.stub!(:find_or_initialize_by_person_id).and_return(contact) + alice.contacts.stub(:find_or_initialize_by_person_id).and_return(contact) contact.should_not_receive(:dispatch_request) alice.share_with(eve.person, a2) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 7f203d1f61..ffc7f49364 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -870,14 +870,14 @@ describe User do describe "#send_reset_password_instructions" do it "generates a reset password token if it's supposed to" do user = User.new - user.stub!(:should_generate_reset_token?).and_return(true) + user.stub(:should_generate_reset_token?).and_return(true) user.should_receive(:generate_reset_password_token) user.send_reset_password_instructions end it "does not generate a reset password token if it's not supposed to" do user = User.new - user.stub!(:should_generate_reset_token?).and_return(false) + user.stub(:should_generate_reset_token?).and_return(false) user.should_not_receive(:generate_reset_password_token) user.send_reset_password_instructions end diff --git a/spec/shared_behaviors/relayable.rb b/spec/shared_behaviors/relayable.rb index f3afeee106..ed753e0031 100644 --- a/spec/shared_behaviors/relayable.rb +++ b/spec/shared_behaviors/relayable.rb @@ -106,7 +106,7 @@ describe Diaspora::Relayable do it 'dispatches when the person receiving is the parent author' do p = Postzord::Dispatcher.build(@local_luke, @object_by_recipient) p.should_receive(:post) - p.class.stub!(:new).and_return(p) + p.class.stub(:new).and_return(p) @object_by_recipient.receive(@local_luke, @local_leia.person) end diff --git a/spec/workers/delete_post_from_service_spec.rb b/spec/workers/delete_post_from_service_spec.rb index 0860308f14..221a86e432 100644 --- a/spec/workers/delete_post_from_service_spec.rb +++ b/spec/workers/delete_post_from_service_spec.rb @@ -10,7 +10,7 @@ describe Workers::DeletePostFromService do m = mock() url = "foobar" m.should_receive(:delete_post) - Service.stub!(:find_by_id).and_return(m) + Service.stub(:find_by_id).and_return(m) Workers::DeletePostFromService.new.perform("123", @post.id.to_s) end end diff --git a/spec/workers/fetch_profile_photo_spec.rb b/spec/workers/fetch_profile_photo_spec.rb index 6e4afcfb2b..cc1253b325 100644 --- a/spec/workers/fetch_profile_photo_spec.rb +++ b/spec/workers/fetch_profile_photo_spec.rb @@ -27,7 +27,7 @@ describe Workers::FetchProfilePhoto do context "service does not have a profile_photo_url" do it "does nothing without fallback" do - @service.stub!(:profile_photo_url).and_return(nil) + @service.stub(:profile_photo_url).and_return(nil) Photo.should_not_receive(:diaspora_initialize) Workers::FetchProfilePhoto.new.perform(@user.id, @service.id) @@ -35,7 +35,7 @@ describe Workers::FetchProfilePhoto do it "fetches fallback if it's provided" do @photo_stub.should_receive(:save!).and_return(true) - @service.stub!(:profile_photo_url).and_return(nil) + @service.stub(:profile_photo_url).and_return(nil) Photo.should_receive(:diaspora_initialize).with(hash_including(:author => @user.person, :image_url => "https://service.com/fallback_lowres.jpg", :pending => true)).and_return(@photo_stub) Workers::FetchProfilePhoto.new.perform(@user.id, @service.id, "https://service.com/fallback_lowres.jpg") diff --git a/spec/workers/http_multi_spec.rb b/spec/workers/http_multi_spec.rb index c0b42ab406..839e841cdd 100644 --- a/spec/workers/http_multi_spec.rb +++ b/spec/workers/http_multi_spec.rb @@ -16,7 +16,7 @@ describe Workers::HttpMulti do @post_xml = Base64.encode64 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH" @hydra = Typhoeus::Hydra.new - Typhoeus::Hydra.stub!(:new).and_return(@hydra) + Typhoeus::Hydra.stub(:new).and_return(@hydra) @salmon = Salmon::EncryptedSlap.create_by_user_and_activity bob, Base64.decode64(@post_xml) Salmon::EncryptedSlap.stub(:create_by_user_and_activity).and_return @salmon @body = "encrypted things" diff --git a/spec/workers/post_to_service_spec.rb b/spec/workers/post_to_service_spec.rb index 6f49a6f36f..8382437c89 100644 --- a/spec/workers/post_to_service_spec.rb +++ b/spec/workers/post_to_service_spec.rb @@ -5,11 +5,11 @@ describe Workers::PostToService do user = alice aspect = user.aspects.create(:name => "yeah") post = user.post(:status_message, :text => 'foo', :to => aspect.id) - User.stub!(:find_by_id).with(user.id.to_s).and_return(user) + User.stub(:find_by_id).with(user.id.to_s).and_return(user) m = mock() url = "foobar" m.should_receive(:post).with(anything, url) - Service.stub!(:find_by_id).and_return(m) + Service.stub(:find_by_id).and_return(m) Workers::PostToService.new.perform("123", post.id.to_s, url) end end -- GitLab