diff --git a/spec/controllers/admins_controller_spec.rb b/spec/controllers/admins_controller_spec.rb index 7c824ce6d15d599e77c28efe697c51438fa0cd9e..1ec8d2b41dbf53ff3f4d96e952330350aec02387 100644 --- a/spec/controllers/admins_controller_spec.rb +++ b/spec/controllers/admins_controller_spec.rb @@ -95,7 +95,7 @@ describe AdminsController do end it 'invites a new user' do - EmailInviter.should_receive(:new).and_return(stub.as_null_object) + EmailInviter.should_receive(:new).and_return(double.as_null_object) get :admin_inviter, :identifier => 'bob@moms.com' response.should redirect_to user_search_path flash.notice.should include("invitation sent") diff --git a/spec/controllers/invitations_controller_spec.rb b/spec/controllers/invitations_controller_spec.rb index deff87b81d0600e6a39737fd0704959ce46b6609..852181ada57d46486ce4403916613d1a29419a3b 100644 --- a/spec/controllers/invitations_controller_spec.rb +++ b/spec/controllers/invitations_controller_spec.rb @@ -48,7 +48,7 @@ describe InvitationsController do end it 'creates an InviteEmail worker' do - inviter = stub(:emails => [@emails], :send! => true) + inviter = double(:emails => [@emails], :send! => true) Workers::Mail::InviteEmail.should_receive(:perform_async).with(@invite['email_inviter']['emails'], @user.id, @invite['email_inviter']) post :create, @invite end @@ -98,7 +98,7 @@ describe InvitationsController do end it 'creates an InviteEmail worker' do - inviter = stub(:emails => [@emails], :send! => true) + inviter = double(:emails => [@emails], :send! => true) Workers::Mail::InviteEmail.should_receive(:perform_async).with(@valid_emails, @user.id, @invite['email_inviter']) post :create, @invite end diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb index 12abb67267e67a40f10968f1c8f1a0651e3fcc9e..d136aebb9c302d8a2b8d74fa2f8a0e1f47ae1a97 100644 --- a/spec/controllers/profiles_controller_spec.rb +++ b/spec/controllers/profiles_controller_spec.rb @@ -11,7 +11,7 @@ describe ProfilesController do describe '#show' do let(:mock_person) {mock_model(User)} - let(:mock_presenter) { mock(:as_json => {:rock_star => "Jamie Cai"})} + let(:mock_presenter) { double(:as_json => {:rock_star => "Jamie Cai"})} it "returns a post Presenter" do Person.should_receive(:find_by_guid!).with("12345").and_return(mock_person) @@ -22,7 +22,7 @@ describe ProfilesController do end end - describe '#edit' do + describe '#edit' do it 'succeeds' do get :edit response.should be_success @@ -77,12 +77,12 @@ describe ProfilesController do put :update, params eve.person(true).profile.tag_list.to_set.should == ['apples', 'oranges'].to_set end - + it 'sets plaintext tags' do params = { :id => eve.person.id, :tags => ',#apples,#oranges,', :profile => {:tag_string => '#pears'} } - + put :update, params eve.person(true).profile.tag_list.to_set.should == ['apples', 'oranges', 'pears'].to_set end @@ -91,7 +91,7 @@ describe ProfilesController do params = { :id => eve.person.id, :tags => ',#apples,#oranges,', :profile => {:tag_string => 'bananas'} } - + put :update, params eve.person(true).profile.tag_list.to_set.should == ['apples', 'oranges', 'bananas'].to_set end diff --git a/spec/controllers/share_visibilities_controller_spec.rb b/spec/controllers/share_visibilities_controller_spec.rb index 56e05609410673195e1f02523e99d36bc53771c7..fce516f7b0a184f33dba932b3b50c92347ecfa7f 100644 --- a/spec/controllers/share_visibilities_controller_spec.rb +++ b/spec/controllers/share_visibilities_controller_spec.rb @@ -30,7 +30,7 @@ describe ShareVisibilitiesController do @controller.params[:post_id] = id @controller.params[:shareable_type] = 'Post' - Post.should_receive(:where).with(hash_including(:id => id)).once.and_return(stub.as_null_object) + Post.should_receive(:where).with(hash_including(:id => id)).once.and_return(double.as_null_object) 2.times do |n| @controller.send(:accessible_post) end diff --git a/spec/helpers/interim_stream_hackiness_helper_spec.rb b/spec/helpers/interim_stream_hackiness_helper_spec.rb index 9830a505feab1c18bb5135147e5a34b9847428c4..2212976f429f514675a8fc912aca78a19b789489 100644 --- a/spec/helpers/interim_stream_hackiness_helper_spec.rb +++ b/spec/helpers/interim_stream_hackiness_helper_spec.rb @@ -14,19 +14,19 @@ describe InterimStreamHackinessHelper do def user_signed_in? false end - commenting_disabled?(stub).should == true + commenting_disabled?(double).should == true end it 'returns true if @commenting_disabled is set' do @commenting_disabled = true - commenting_disabled?(stub).should == true + commenting_disabled?(double).should == true @commenting_disabled = false - commenting_disabled?(stub).should == false + commenting_disabled?(double).should == false end it 'returns @stream.can_comment? if @stream is set' do - post = stub - @stream = stub + post = double + @stream = double @stream.should_receive(:can_comment?).with(post).and_return(true) commenting_disabled?(post).should == false diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index 9a00e02b0025a39c17017de316061b698ebd20bd..1015818eb58ab98c01785b8ef76cc7afbe6ac7e1 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -34,7 +34,7 @@ describe NotificationsHelper do @ilya = FactoryGirl.create(:person) @ilya.profile.first_name = 'ilya' @ilya.profile.last_name = 'zhit' - @note = mock() + @note = double() end it 'with two, does not comma seperate two actors' do diff --git a/spec/helpers/posts_helper_spec.rb b/spec/helpers/posts_helper_spec.rb index b8be45c972c49bffb82305a9889eca60d68bd8ac..3d31563ccce1faaf4506a7d15a07d9bc9341786c 100644 --- a/spec/helpers/posts_helper_spec.rb +++ b/spec/helpers/posts_helper_spec.rb @@ -14,7 +14,7 @@ describe PostsHelper do context 'with posts with text' do context 'when :length is passed in parameters' do it 'returns string of size less or equal to :length' do - @sm = stub(:text => "## My title\n Post content...") + @sm = double(:text => "## My title\n Post content...") string_size = 12 post_page_title(@sm, :length => string_size ).size.should <= string_size end @@ -22,17 +22,17 @@ describe PostsHelper do context 'when :length is not passed in parameters' do context 'with a Markdown header of less than 200 characters on first line'do it 'returns atx style header' do - @sm = stub(:text => "## My title\n Post content...") + @sm = double(:text => "## My title\n Post content...") post_page_title(@sm).should == "## My title" end it 'returns setext style header' do - @sm = stub(:text => "My title \n======\n Post content...") + @sm = double(:text => "My title \n======\n Post content...") post_page_title(@sm).should == "My title \n======" end end context 'without a Markdown header of less than 200 characters on first line 'do it 'truncates posts to the 20 first characters' do - @sm = stub(:text => "Very, very, very long post") + @sm = double(:text => "Very, very, very long post") post_page_title(@sm).should == "Very, very, very ..." end end diff --git a/spec/integration/dispatching_spec.rb b/spec/integration/dispatching_spec.rb index 76a275f862e66f98f45c6f36d4660cf4124c6687..af967a66c087ce08122f54cb22ac88fcd9d2c19f 100644 --- a/spec/integration/dispatching_spec.rb +++ b/spec/integration/dispatching_spec.rb @@ -12,7 +12,7 @@ describe "Dispatching" do inlined_jobs do # Luke now retracts his comment Postzord::Dispatcher::Public.should_not_receive(:new) - Postzord::Dispatcher::Private.should_receive(:new).and_return(stub(:post => true)) + Postzord::Dispatcher::Private.should_receive(:new).and_return(double(:post => true)) luke.retract(comment) end end diff --git a/spec/integration/receiving_spec.rb b/spec/integration/receiving_spec.rb index bc9b3c7659c28b619ac14e18f97b44e942777e32..231d92d7c44ea3115abdd9da5d77a01caaad2e70 100644 --- a/spec/integration/receiving_spec.rb +++ b/spec/integration/receiving_spec.rb @@ -225,7 +225,7 @@ describe 'a user receives a post' do Profile.where(:person_id => remote_person.id).delete_all remote_person.attributes.delete(:id) # leaving a nil id causes it to try to save with id set to NULL in postgres - m = mock() + m = double() Webfinger.should_receive(:new).twice.with(eve.person.diaspora_handle).and_return(m) m.should_receive(:fetch).twice.and_return{ remote_person.save(:validate => false) diff --git a/spec/lib/account_deleter_spec.rb b/spec/lib/account_deleter_spec.rb index d8137fa97d2e22ae41ff281e5dc09e343a1bd6b3..6554bbeec96bae6f8f08707e6e2c1ecbd29e80ac 100644 --- a/spec/lib/account_deleter_spec.rb +++ b/spec/lib/account_deleter_spec.rb @@ -72,9 +72,9 @@ describe AccountDeleter do describe "#delete_standard_user_associations" do it 'removes all standard user associaltions' do @account_deletion.normal_ar_user_associates_to_delete.each do |asso| - association_mock = mock - association_mock.should_receive(:delete) - bob.should_receive(asso).and_return([association_mock]) + association_double = double + association_double.should_receive(:delete) + bob.should_receive(asso).and_return([association_double]) end @account_deletion.delete_standard_user_associations @@ -87,9 +87,9 @@ describe AccountDeleter do end it 'removes all standard person associaltions' do @account_deletion.normal_ar_person_associates_to_delete.each do |asso| - association_mock = mock - association_mock.should_receive(:delete_all) - bob.person.should_receive(asso).and_return(association_mock) + association_double = double + association_double.should_receive(:delete_all) + bob.person.should_receive(asso).and_return(association_double) end @account_deletion.delete_standard_person_associations @@ -98,7 +98,7 @@ describe AccountDeleter do describe "#disassociate_invitations" do it "sets invitations_from_me to be admin invitations" do - invites = [mock] + invites = [double] bob.stub(:invitations_from_me).and_return(invites) invites.first.should_receive(:convert_to_admin!) @account_deletion.disassociate_invitations @@ -115,7 +115,7 @@ describe AccountDeleter do describe '#delete_contacts_of_me' do it 'deletes all the local contact objects where deleted account is the person' do - contacts = mock + contacts = double Contact.should_receive(:all_contacts_of_person).with(bob.person).and_return(contacts) contacts.should_receive(:destroy_all) @account_deletion.delete_contacts_of_me @@ -135,7 +135,7 @@ describe AccountDeleter do end describe "#remove_conversation_visibilities" do it "removes the conversation visibility for the deleted user" do - vis = stub + vis = double ConversationVisibility.should_receive(:where).with(hash_including(:person_id => bob.person.id)).and_return(vis) vis.should_receive(:destroy_all) @account_deletion.remove_conversation_visibilities @@ -145,7 +145,7 @@ describe AccountDeleter do describe "#remove_person_share_visibilities" do it 'removes the share visibilities for a person ' do - @s_vis = stub + @s_vis = double ShareVisibility.should_receive(:for_contacts_of_a_person).with(bob.person).and_return(@s_vis) @s_vis.should_receive(:destroy_all) @@ -155,7 +155,7 @@ describe AccountDeleter do describe "#remove_share_visibilities_by_contacts_of_user" do it 'removes the share visibilities for a user' do - @s_vis = stub + @s_vis = double ShareVisibility.should_receive(:for_a_users_contacts).with(bob).and_return(@s_vis) @s_vis.should_receive(:destroy_all) diff --git a/spec/lib/configuration_methods_spec.rb b/spec/lib/configuration_methods_spec.rb index ef99fde55c70305d7d983c20b0fb00a04cfac6ee..654dc4933f1bcb468a5367454cf38a2be1e268c5 100644 --- a/spec/lib/configuration_methods_spec.rb +++ b/spec/lib/configuration_methods_spec.rb @@ -44,7 +44,7 @@ describe Configuration::Methods do describe "#bare_pod_uri" do it 'is #pod_uri.authority stripping www.' do - pod_uri = mock + pod_uri = double @settings.stub(:pod_uri).and_return(pod_uri) pod_uri.should_receive(:authority).and_return("www.example.org") @settings.bare_pod_uri.should == 'example.org' @@ -53,10 +53,10 @@ describe Configuration::Methods do describe "#configured_services" do it "includes the enabled services only" do - services = mock - enabled = mock + services = double + enabled = double enabled.stub(:enable?).and_return(true) - disabled = mock + disabled = double disabled.stub(:enable?).and_return(false) services.stub(:twitter).and_return(enabled) services.stub(:tumblr).and_return(enabled) @@ -72,7 +72,7 @@ describe Configuration::Methods do describe "#version_string" do before do - @version = mock + @version = double @version.stub(:number).and_return("0.0.0.0") @version.stub(:release?).and_return(true) @settings.stub(:version).and_return(@version) @@ -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(double(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 d45e295d680c2e6975e4eec41cf8797b8fbb5fc3..ad9888e3c659d388fa74dfc343d615b5bd71170e 100644 --- a/spec/lib/diaspora/federated/relayable_retraction_spec.rb +++ b/spec/lib/diaspora/federated/relayable_retraction_spec.rb @@ -34,7 +34,7 @@ describe RelayableRetraction do describe '#subscribers' do it 'delegates it to target' do - arg = mock() + arg = double() @retraction.target.should_receive(:subscribers).with(arg) @retraction.subscribers(arg) end @@ -67,7 +67,7 @@ describe RelayableRetraction do end it 'dispatches' do - zord = mock() + zord = double() zord.should_receive(:post) Postzord::Dispatcher.should_receive(:build).with(@local_luke, @retraction).and_return zord @retraction.receive(@recipient, @comment.author) diff --git a/spec/lib/diaspora/federated/signed_retraction_spec.rb b/spec/lib/diaspora/federated/signed_retraction_spec.rb index 3649d0f93660839660662eee20e67738b5fcb4cd..f6391c8b03f3118a6d4765d01c908cdf0e847d7a 100644 --- a/spec/lib/diaspora/federated/signed_retraction_spec.rb +++ b/spec/lib/diaspora/federated/signed_retraction_spec.rb @@ -13,7 +13,7 @@ describe SignedRetraction do onward_retraction = retraction.dup retraction.should_receive(:dup).and_return(onward_retraction) - dis = mock + dis = double Postzord::Dispatcher.should_receive(:build).with(@resharer, onward_retraction).and_return(dis) dis.should_receive(:post) @@ -34,7 +34,7 @@ describe SignedRetraction do remote_retraction.dup.perform(bob) Post.exists?(:id => remote_post.id).should be_false - dis = mock + dis = double Postzord::Dispatcher.should_receive(:build){ |sender, retraction| sender.should == alice retraction.sender.should == alice.person diff --git a/spec/lib/email_inviter_spec.rb b/spec/lib/email_inviter_spec.rb index 2de1282872d95dc700d2f502729ea0f1eff485c1..1b6ae002e185a091c062cac2a9805fe5f00f7440 100644 --- a/spec/lib/email_inviter_spec.rb +++ b/spec/lib/email_inviter_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe EmailInviter do before do - @user = stub(:invitation_code => 'coolcodebro', :present? => true, + @user = double(:invitation_code => 'coolcodebro', :present? => true, :email => 'foo@bar.com') @emails = "mbs333@gmail.com, foo1@bar.com maxwell@dude.com" end diff --git a/spec/lib/hydra_wrapper_spec.rb b/spec/lib/hydra_wrapper_spec.rb index 0e0b2344fbe4172bc90b17d2b7733627a2db7184..c40752535f30bd10708ba5ff3822866989e2d356 100644 --- a/spec/lib/hydra_wrapper_spec.rb +++ b/spec/lib/hydra_wrapper_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe HydraWrapper do before do @people = ["person", "person2", "person3"] - @wrapper = HydraWrapper.new stub, @people, "<encoded_xml>", stub + @wrapper = HydraWrapper.new double, @people, "<encoded_xml>", double end describe 'initialize' do @@ -25,7 +25,7 @@ describe HydraWrapper do describe '#run' do it 'delegates #run to the @hydra' do - hydra = stub.as_null_object + hydra = double.as_null_object @wrapper.instance_variable_set :@hydra, hydra hydra.should_receive :run @wrapper.run @@ -58,7 +58,7 @@ describe HydraWrapper do it 'inserts a job for every group of people' do Base64.stub(:decode64) - @wrapper.dispatcher_class = stub salmon: stub(xml_for: "<XML>") + @wrapper.dispatcher_class = double salmon: double(xml_for: "<XML>") @wrapper.stub(:grouped_people).and_return('https://foo.com' => @wrapper.people) @wrapper.people.should_receive(:first).once @wrapper.should_receive(:insert_job).with('https://foo.com', "<XML>", @wrapper.people).once @@ -67,8 +67,8 @@ describe HydraWrapper do it 'does not insert a job for a person whos xml returns false' do Base64.stub(:decode64) - @wrapper.stub(:grouped_people).and_return('https://foo.com' => [stub]) - @wrapper.dispatcher_class = stub salmon: stub(xml_for: false) + @wrapper.stub(:grouped_people).and_return('https://foo.com' => [double]) + @wrapper.dispatcher_class = double salmon: double(xml_for: false) @wrapper.should_not_receive :insert_job @wrapper.enqueue_batch end @@ -77,15 +77,15 @@ describe HydraWrapper do describe '#redirecting_to_https?!' do it 'does not execute unless response has a 3xx code' do - resp = stub code: 200 + resp = double code: 200 @wrapper.send(:redirecting_to_https?, resp).should be_false end it "returns true if just the protocol is different" do host = "the-same.com/" - resp = stub( - request: stub(url: "http://#{host}"), - code: 302, + resp = double( + request: double(url: "http://#{host}"), + code: 302, headers_hash: { 'Location' => "https://#{host}" } @@ -96,8 +96,8 @@ describe HydraWrapper do it "returns false if not just the protocol is different" do host = "the-same.com/" - resp = stub( - request: stub(url: "http://#{host}"), + resp = double( + request: double(url: "http://#{host}"), code: 302, headers_hash: { 'Location' => "https://not-the-same/" diff --git a/spec/lib/postzord/dispatcher_spec.rb b/spec/lib/postzord/dispatcher_spec.rb index 3f18de0c55760cbcf5be16b2d733b859cc1c105d..06e45c0ea4202b71c255711c00699c1a8b168661 100644 --- a/spec/lib/postzord/dispatcher_spec.rb +++ b/spec/lib/postzord/dispatcher_spec.rb @@ -203,7 +203,7 @@ describe Postzord::Dispatcher do @remote_people = [] @remote_people << alice.person @mailman = Postzord::Dispatcher.build(alice, @sm) - @hydra = mock() + @hydra = double() Typhoeus::Hydra.stub(:new).and_return(@hydra) end @@ -318,7 +318,7 @@ describe Postzord::Dispatcher do Workers::DeletePostFromService.should_receive(:perform_async).with(anything, anything) mailman.post end - + end describe '#and_notify_local_users' do diff --git a/spec/lib/postzord/receiver/private_spec.rb b/spec/lib/postzord/receiver/private_spec.rb index 4b2bb653cdc1817df01742d55f00b005d9db2379..352c91d40c944396b7f31cbb2df715895f703457 100644 --- a/spec/lib/postzord/receiver/private_spec.rb +++ b/spec/lib/postzord/receiver/private_spec.rb @@ -23,12 +23,12 @@ describe Postzord::Receiver::Private do end it 'valid for remote' do - salmon_mock = mock() - web_mock = mock() - web_mock.should_receive(:fetch).and_return true - salmon_mock.should_receive(:author_id).and_return(true) - Salmon::EncryptedSlap.should_receive(:from_xml).with(@salmon_xml, bob).and_return(salmon_mock) - Webfinger.should_receive(:new).and_return(web_mock) + salmon_double = double() + web_double = double() + web_double.should_receive(:fetch).and_return true + salmon_double.should_receive(:author_id).and_return(true) + Salmon::EncryptedSlap.should_receive(:from_xml).with(@salmon_xml, bob).and_return(salmon_double) + Webfinger.should_receive(:new).and_return(web_double) zord = Postzord::Receiver::Private.new(bob, :salmon_xml => @salmon_xml) zord.instance_variable_get(:@user).should_not be_nil diff --git a/spec/lib/postzord/receiver/public_spec.rb b/spec/lib/postzord/receiver/public_spec.rb index e94886dccfb60be175b2b495702bf9d43e3b72f2..c291b14c5c30275ca8f9cbf3fbf0f69c3204dfcb 100644 --- a/spec/lib/postzord/receiver/public_spec.rb +++ b/spec/lib/postzord/receiver/public_spec.rb @@ -84,7 +84,7 @@ describe Postzord::Receiver::Public do describe '#recipient_user_ids' do it 'calls User.all_sharing_with_person' do - User.should_receive(:all_sharing_with_person).and_return(stub(:select => [])) + User.should_receive(:all_sharing_with_person).and_return(double(:select => [])) receiver = Postzord::Receiver::Public.new(@xml) receiver.perform! end @@ -101,7 +101,7 @@ describe Postzord::Receiver::Public do end it 'receives only for the parent author if he is local to the pod' do - comment = stub.as_null_object + comment = double.as_null_object @receiver.instance_variable_set(:@object, comment) comment.should_receive(:receive) @@ -109,10 +109,10 @@ describe Postzord::Receiver::Public do end it 'calls notifiy_users' do - comment = stub.as_null_object + comment = double.as_null_object @receiver.instance_variable_set(:@object, comment) - local_batch_receiver = stub.as_null_object + local_batch_receiver = double.as_null_object Postzord::Receiver::LocalBatch.stub(:new).and_return(local_batch_receiver) local_batch_receiver.should_receive(:notify_users) @receiver.receive_relayable diff --git a/spec/lib/rake_helper_spec.rb b/spec/lib/rake_helper_spec.rb index 58039173c380d5f5cc6554380e5d808729bb12b0..1f8001fbdb5749cb388e1311d908e3093a3bd9ec 100644 --- a/spec/lib/rake_helper_spec.rb +++ b/spec/lib/rake_helper_spec.rb @@ -23,7 +23,7 @@ describe RakeHelpers do it 'should send emails to each email' do - EmailInviter.should_receive(:new).exactly(3).times.and_return(stub.as_null_object) + EmailInviter.should_receive(:new).exactly(3).times.and_return(double.as_null_object) process_emails(@csv, 100, 1, false) end end diff --git a/spec/lib/stream/aspect_spec.rb b/spec/lib/stream/aspect_spec.rb index 1fcbefd7ced7e9002f483cba7d0a586c38d9e5bd..1ec82d1bd9e2f010afb8661b6ffccd8b6272329a 100644 --- a/spec/lib/stream/aspect_spec.rb +++ b/spec/lib/stream/aspect_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe Stream::Aspect do describe '#aspects' do it 'queries the user given initialized aspect ids' do - alice = stub.as_null_object + alice = double.as_null_object stream = Stream::Aspect.new(alice, [1,2,3]) alice.aspects.should_receive(:where) @@ -15,7 +15,7 @@ describe Stream::Aspect do end it "returns all the user's aspects if no aspect ids are specified" do - alice = stub.as_null_object + alice = double.as_null_object stream = Stream::Aspect.new(alice, []) alice.aspects.should_not_receive(:where) @@ -23,7 +23,7 @@ describe Stream::Aspect do end it 'filters aspects given a user' do - alice = stub(:aspects => [stub(:id => 1)]) + alice = double(:aspects => [double(:id => 1)]) alice.aspects.stub(:where).and_return(alice.aspects) stream = Stream::Aspect.new(alice, [1,2,3]) @@ -33,8 +33,8 @@ describe Stream::Aspect do describe '#aspect_ids' do it 'maps ids from aspects' do - alice = stub.as_null_object - aspects = stub.as_null_object + alice = double.as_null_object + aspects = double.as_null_object stream = Stream::Aspect.new(alice, [1,2]) @@ -46,39 +46,39 @@ describe Stream::Aspect do describe '#posts' do before do - @alice = stub.as_null_object + @alice = double.as_null_object end it 'calls visible posts for the given user' do stream = Stream::Aspect.new(@alice, [1,2]) - @alice.should_receive(:visible_shareables).and_return(stub.as_null_object) + @alice.should_receive(:visible_shareables).and_return(double.as_null_object) stream.posts end it 'is called with 2 types' do stream = Stream::Aspect.new(@alice, [1,2], :order => 'created_at') - @alice.should_receive(:visible_shareables).with(Post, hash_including(:type=> ['StatusMessage', 'Reshare'])).and_return(stub.as_null_object) + @alice.should_receive(:visible_shareables).with(Post, hash_including(:type=> ['StatusMessage', 'Reshare'])).and_return(double.as_null_object) stream.posts end it 'respects ordering' do stream = Stream::Aspect.new(@alice, [1,2], :order => 'created_at') - @alice.should_receive(:visible_shareables).with(Post, hash_including(:order => 'created_at DESC')).and_return(stub.as_null_object) + @alice.should_receive(:visible_shareables).with(Post, hash_including(:order => 'created_at DESC')).and_return(double.as_null_object) stream.posts end it 'respects max_time' do stream = Stream::Aspect.new(@alice, [1,2], :max_time => 123) - @alice.should_receive(:visible_shareables).with(Post, hash_including(:max_time => instance_of(Time))).and_return(stub.as_null_object) + @alice.should_receive(:visible_shareables).with(Post, hash_including(:max_time => instance_of(Time))).and_return(double.as_null_object) stream.posts end it 'passes for_all_aspects to visible posts' do stream = Stream::Aspect.new(@alice, [1,2], :max_time => 123) - all_aspects = mock + all_aspects = double stream.stub(:for_all_aspects?).and_return(all_aspects) - @alice.should_receive(:visible_shareables).with(Post, hash_including(:all_aspects? => all_aspects)).and_return(stub.as_null_object) + @alice.should_receive(:visible_shareables).with(Post, hash_including(:all_aspects? => all_aspects)).and_return(double.as_null_object) stream.posts end end @@ -87,19 +87,19 @@ describe Stream::Aspect do it 'should call Person.all_from_aspects' do class Person ; end - alice = stub.as_null_object + alice = double.as_null_object aspect_ids = [1,2,3] stream = Stream::Aspect.new(alice, []) stream.stub(:aspect_ids).and_return(aspect_ids) - Person.should_receive(:unique_from_aspects).with(stream.aspect_ids, alice).and_return(stub(:includes => :profile)) + Person.should_receive(:unique_from_aspects).with(stream.aspect_ids, alice).and_return(double(:includes => :profile)) stream.people end end describe '#aspect' do before do - alice = stub.as_null_object + alice = double.as_null_object @stream = Stream::Aspect.new(alice, [1,2]) end @@ -116,7 +116,7 @@ describe Stream::Aspect do describe 'for_all_aspects?' do before do - alice = stub.as_null_object + alice = double.as_null_object alice.aspects.stub(:size).and_return(2) @stream = Stream::Aspect.new(alice, [1,2]) end diff --git a/spec/lib/stream/base_spec.rb b/spec/lib/stream/base_spec.rb index 104e3699d37f8bc61fc21cf008ebf422bb348f6b..584c15c7d962f82ee44aacac3a46548312432a2f 100644 --- a/spec/lib/stream/base_spec.rb +++ b/spec/lib/stream/base_spec.rb @@ -14,7 +14,7 @@ describe Stream::Base do describe '#stream_posts' do it "should returns the posts.for_a_stream" do - posts = mock + posts = double @stream.stub(:posts).and_return(posts) @stream.stub(:like_posts_for_stream!) @@ -70,7 +70,7 @@ describe Stream::Base do describe '#people' do it 'excludes blocked people' do - @stream.should_receive(:stream_posts).and_return(stub.as_null_object) + @stream.should_receive(:stream_posts).and_return(double.as_null_object) @stream.people end end diff --git a/spec/lib/stream/multi_spec.rb b/spec/lib/stream/multi_spec.rb index e3c648e7ac0ae67b674e4d238d1c1e3369c5473b..6b13c046f4f2b75bb943b37a3ffa47761d257403 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(double.tap { |m| m.stub(:make_relation!)}) @stream.posts end end diff --git a/spec/lib/webfinger_spec.rb b/spec/lib/webfinger_spec.rb index 7d247814d7748c72e2f0b487a958abbdc10e254e..4535350209fdafa86972d95b7a7768812e1bc5cc 100644 --- a/spec/lib/webfinger_spec.rb +++ b/spec/lib/webfinger_spec.rb @@ -104,7 +104,7 @@ describe Webfinger do describe 'cached_person' do it 'sets the person by looking up the account from Person.by_account_identifier' do - person = stub + person = double Person.should_receive(:by_account_identifier).with(account).and_return(person) finger.cached_person.should == person finger.person.should == person diff --git a/spec/models/account_deletion_spec.rb b/spec/models/account_deletion_spec.rb index 0b97b6db9c7fb43a2d68fff194014f4c1d9c197d..9515e3794f9a68c4317c74ab4dba298b583bbd57 100644 --- a/spec/models/account_deletion_spec.rb +++ b/spec/models/account_deletion_spec.rb @@ -22,7 +22,7 @@ describe AccountDeletion do end it 'creates a deleter' do - AccountDeleter.should_receive(:new).with(alice.person.diaspora_handle).and_return(stub(:perform! => true)) + AccountDeleter.should_receive(:new).with(alice.person.diaspora_handle).and_return(double(:perform! => true)) @ad.perform! end @@ -45,7 +45,7 @@ describe AccountDeletion do end it 'creates a public postzord' do - Postzord::Dispatcher::Public.should_receive(:new).and_return(stub.as_null_object) + Postzord::Dispatcher::Public.should_receive(:new).and_return(double.as_null_object) @ad = AccountDeletion.new(:person => alice.person) @ad.send(:dispatch) end diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index 76d51dca973c21ad94e2bcf90203bcc6f0d92bea..6facf6492def3b29a8dc53efc98bfdf326fbd6fa 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -186,7 +186,7 @@ describe Contact do describe '#dispatch_request' do it 'pushes to people' do @contact.stub(:user).and_return(@user) - m = mock() + m = double() m.should_receive(:post) Postzord::Dispatcher.should_receive(:build).and_return(m) @contact.dispatch_request diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index c5104ae54ea2281d24def74b1dcc19f1c1b56cdb..ca74fbd724301ea1273069f0583f1ac91623b029 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -492,7 +492,7 @@ describe Person do describe '.url_batch_update' do it "calls #update_person_url given an array of users and a url" do - people = [stub.as_null_object, stub.as_null_object, stub.as_null_object] + people = [double.as_null_object, double.as_null_object, double.as_null_object] people.each do |person| person.should_receive(:update_url).with(@url) end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 3b71e2b6eb5866de061af21ab76bf90004993e5f..aa7cdf19204ebebed77a48c4addcd36b6ad5f5f0 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -54,9 +54,9 @@ describe Photo do end it 'sets the random prefix' do - photo_stub = stub.as_null_object - photo_stub.should_receive(:random_string=) - Photo.stub(:new).and_return(photo_stub) + photo_double = double.as_null_object + photo_double.should_receive(:random_string=) + Photo.stub(:new).and_return(photo_double) Photo.diaspora_initialize( :author => @user.person, :user_file => @image) @@ -73,9 +73,9 @@ describe Photo do it 'saves the photo' do url = "https://service.com/user/profile_image" - photo_stub = stub.as_null_object - photo_stub.should_receive(:remote_unprocessed_image_url=).with(url) - Photo.stub(:new).and_return(photo_stub) + photo_double = double.as_null_object + photo_double.should_receive(:remote_unprocessed_image_url=).with(url) + Photo.stub(:new).and_return(photo_double) Photo.diaspora_initialize( :author => @user.person, :image_url => url) diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 0721ffe625b18e122dfa15c08f8e1e7fd098911c..9d9f5f7b7dedc9798388544c2f47f5c217bfd846 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -50,19 +50,19 @@ describe Post do describe '.for_a_stream' do it 'calls #for_visible_shareable_sql' do - time, order = stub, stub + time, order = double, double Post.should_receive(:for_visible_shareable_sql).with(time, order).and_return(Post) Post.for_a_stream(time, order) end it 'calls includes_for_a_stream' do Post.should_receive(:includes_for_a_stream) - Post.for_a_stream(stub, stub) + Post.for_a_stream(double, double) end it 'calls excluding_blocks if a user is present' do Post.should_receive(:excluding_blocks).with(alice).and_return(Post) - Post.for_a_stream(stub, stub, alice) + Post.for_a_stream(double, double, alice) end end @@ -141,7 +141,7 @@ describe Post do end it 'defaults to 15 posts' do - chain = stub.as_null_object + chain = double.as_null_object Post.stub(:by_max_time).and_return(chain) chain.should_receive(:limit).with(15).and_return(Post) @@ -255,7 +255,7 @@ describe Post do before do @post = FactoryGirl.create(:status_message, :author => bob.person) @known_post = Post.new - bob.stub(:contact_for).with(eve.person).and_return(stub(:receive_shareable => true)) + bob.stub(:contact_for).with(eve.person).and_return(double(:receive_shareable => true)) end context "user knows about the post" do @@ -287,7 +287,7 @@ describe Post do end it 'notifies the user if they are mentioned' do - bob.stub(:contact_for).with(eve.person).and_return(stub(:receive_shareable => true)) + bob.stub(:contact_for).with(eve.person).and_return(double(:receive_shareable => true)) bob.should_receive(:notify_if_mentioned).and_return(true) @post.send(:receive_persisted, bob, eve.person, @known_post).should == true @@ -304,12 +304,12 @@ describe Post do end it "it receives the post from the contact of the author" do - bob.should_receive(:contact_for).with(eve.person).and_return(stub(:receive_shareable => true)) + bob.should_receive(:contact_for).with(eve.person).and_return(double(:receive_shareable => true)) @post.send(:receive_non_persisted, bob, eve.person).should == true end it 'notifies the user if they are mentioned' do - bob.stub(:contact_for).with(eve.person).and_return(stub(:receive_shareable => true)) + bob.stub(:contact_for).with(eve.person).and_return(double(:receive_shareable => true)) bob.should_receive(:notify_if_mentioned).and_return(true) @post.send(:receive_non_persisted, bob, eve.person).should == true @@ -383,20 +383,20 @@ describe Post do it "looks up on the passed user object if it's non-nil" do post = FactoryGirl.create :status_message - user = mock + user = double user.should_receive(:find_visible_shareable_by_id).with(Post, post.id, key: :id).and_return(post) Post.find_by_guid_or_id_with_user post.id, user end it "raises ActiveRecord::RecordNotFound with a non-existing id and a user" do - user = stub(find_visible_shareable_by_id: nil) + user = double(find_visible_shareable_by_id: nil) expect { Post.find_by_guid_or_id_with_user 123, user }.to raise_error ActiveRecord::RecordNotFound end it "raises Diaspora::NonPublic for a non-existing id without a user" do - Post.stub where: stub(includes: stub(first: nil)) + Post.stub where: double(includes: double(first: nil)) expect { Post.find_by_guid_or_id_with_user 123 }.to raise_error Diaspora::NonPublic diff --git a/spec/models/reshare_spec.rb b/spec/models/reshare_spec.rb index 0d99a7923705754f956b149c623bba762c53c5b3..52a484785495b0a7f83cdac38488c75ef6ec98a8 100644 --- a/spec/models/reshare_spec.rb +++ b/spec/models/reshare_spec.rb @@ -143,7 +143,7 @@ describe Reshare do before do @root_object = @reshare.root @root_object.delete - @response = mock + @response = double @response.stub(:status).and_return(200) @response.stub(:success?).and_return(true) end @@ -156,9 +156,9 @@ describe Reshare do @original_author.profile = @original_profile - wf_prof_mock = mock - wf_prof_mock.should_receive(:fetch).and_return(@original_author) - Webfinger.should_receive(:new).and_return(wf_prof_mock) + wf_prof_double = double + wf_prof_double.should_receive(:fetch).and_return(@original_author) + Webfinger.should_receive(:new).and_return(wf_prof_double) @response.stub(:body).and_return(@root_object.to_diaspora_xml) @@ -216,9 +216,9 @@ describe Reshare do different_person = FactoryGirl.build(:person) - wf_prof_mock = mock - wf_prof_mock.should_receive(:fetch).and_return(different_person) - Webfinger.should_receive(:new).and_return(wf_prof_mock) + wf_prof_double = double + wf_prof_double.should_receive(:fetch).and_return(different_person) + Webfinger.should_receive(:new).and_return(wf_prof_double) different_person.stub(:url).and_return(@original_author.url) diff --git a/spec/models/services/facebook_spec.rb b/spec/models/services/facebook_spec.rb index 493170cbb2e4349fa3f1a49407790d45575080e0..2c1d9d882c6051f2ec87f678aab07ac0bf1bee38 100644 --- a/spec/models/services/facebook_spec.rb +++ b/spec/models/services/facebook_spec.rb @@ -26,14 +26,14 @@ describe Services::Facebook do it 'removes text formatting markdown from post text' do message = "Text with some **bolded** and _italic_ parts." - post = stub(:text => message, :photos => []) + post = double(:text => message, :photos => []) post_params = @service.create_post_params(post) post_params[:message].should match "Text with some bolded and italic parts." end it 'does not add post link when no photos' do message = "Text with some **bolded** and _italic_ parts." - post = stub(:text => message, :photos => []) + post = double(:text => message, :photos => []) post_params = @service.create_post_params(post) post_params[:message].should match "Text with some bolded and italic parts." end diff --git a/spec/models/services/tumblr_spec.rb b/spec/models/services/tumblr_spec.rb index 6e58092c764f24ea0d0ae1de7919320d16414f47..f60c2c32a9f6889d20f15c02fffcd0f07defa0e1 100644 --- a/spec/models/services/tumblr_spec.rb +++ b/spec/models/services/tumblr_spec.rb @@ -11,12 +11,12 @@ describe Services::Tumblr do describe '#post' do it 'posts a status message to tumblr and saves the returned ids' do - response = mock(body: '{"response": {"user": {"blogs": [{"url": "http://foo.tumblr.com"}]}}}') + response = double(body: '{"response": {"user": {"blogs": [{"url": "http://foo.tumblr.com"}]}}}') OAuth::AccessToken.any_instance.should_receive(:get) .with("/v2/user/info") .and_return(response) - response = mock(code: "201", body: '{"response": {"id": "bla"}}') + response = double(code: "201", body: '{"response": {"id": "bla"}}') OAuth::AccessToken.any_instance.should_receive(:post) .with("/v2/blog/foo.tumblr.com/post", @service.build_tumblr_post(@post, '')) .and_return(response) diff --git a/spec/models/services/twitter_spec.rb b/spec/models/services/twitter_spec.rb index 316d3524073bc9da44c65c5c81d2011e8c9618b7..463ae89577a56580951540e0f170fc95d471c879 100644 --- a/spec/models/services/twitter_spec.rb +++ b/spec/models/services/twitter_spec.rb @@ -39,7 +39,7 @@ describe Services::Twitter do it 'removes text formatting markdown from post text' do message = "Text with some **bolded** and _italic_ parts." - post = stub(:text => message, :photos => []) + post = double(:text => message, :photos => []) @service.send(:build_twitter_post, post).should match "Text with some bolded and italic parts." end @@ -53,19 +53,19 @@ describe Services::Twitter do it "should not truncate a short message" do short_message = SecureRandom.hex(20) - short_post = stub(:text => short_message, :photos => []) + short_post = double(:text => short_message, :photos => []) @service.send(:build_twitter_post, short_post).should match short_message end it "should truncate a long message" do long_message = SecureRandom.hex(220) - long_post = stub(:text => long_message, :id => 1, :photos => []) + long_post = double(:text => long_message, :id => 1, :photos => []) @service.send(:build_twitter_post, long_post).length.should be < long_message.length end it "should not truncate a long message with an http url" do long_message = " http://joindiaspora.com/a-very-long-url-name-that-will-be-shortened.html " + @long_message_end - long_post = stub(:text => long_message, :id => 1, :photos => []) + long_post = double(:text => long_message, :id => 1, :photos => []) @post.text = long_message answer = @service.send(:build_twitter_post, @post) @@ -74,7 +74,7 @@ describe Services::Twitter do it "should not cut links when truncating a post" do long_message = SecureRandom.hex(40) + " http://joindiaspora.com/a-very-long-url-name-that-will-be-shortened.html " + SecureRandom.hex(55) - long_post = stub(:text => long_message, :id => 1, :photos => []) + long_post = double(:text => long_message, :id => 1, :photos => []) answer = @service.send(:build_twitter_post, long_post) answer.should match /\.\.\./ @@ -83,7 +83,7 @@ describe Services::Twitter do it "should append the otherwise-cut link when truncating a post" do long_message = "http://joindiaspora.com/a-very-long-decoy-url.html " + SecureRandom.hex(20) + " http://joindiaspora.com/a-very-long-url-name-that-will-be-shortened.html " + SecureRandom.hex(55) + " http://joindiaspora.com/a-very-long-decoy-url-part-2.html" - long_post = stub(:text => long_message, :id => 1, :photos => []) + long_post = double(:text => long_message, :id => 1, :photos => []) answer = @service.send(:build_twitter_post, long_post) answer.should match /\.\.\./ @@ -99,7 +99,7 @@ describe Services::Twitter do it "should truncate a long message with an ftp url" do long_message = @long_message_start + " ftp://joindiaspora.com/a-very-long-url-name-that-will-be-shortened.html " + @long_message_end - long_post = stub(:text => long_message, :id => 1, :photos => []) + long_post = double(:text => long_message, :id => 1, :photos => []) answer = @service.send(:build_twitter_post, long_post) answer.should match /\.\.\./ @@ -107,7 +107,7 @@ describe Services::Twitter do it "should not truncate a message of maximum length" do exact_size_message = SecureRandom.hex(70) - exact_size_post = stub(:text => exact_size_message, :id => 1, :photos => []) + exact_size_post = double(:text => exact_size_message, :id => 1, :photos => []) answer = @service.send(:build_twitter_post, exact_size_post) answer.should match exact_size_message @@ -138,9 +138,9 @@ describe Services::Twitter do describe "#profile_photo_url" do it 'returns the original profile photo url' do - user_stub = stub - user_stub.should_receive(:profile_image_url_https).with("original").and_return("http://a2.twimg.com/profile_images/uid/avatar.png") - Twitter::Client.any_instance.should_receive(:user).with("joindiaspora").and_return(user_stub) + user_double = double + user_double.should_receive(:profile_image_url_https).with("original").and_return("http://a2.twimg.com/profile_images/uid/avatar.png") + Twitter::Client.any_instance.should_receive(:user).with("joindiaspora").and_return(user_double) @service.nickname = "joindiaspora" @service.profile_photo_url.should == "http://a2.twimg.com/profile_images/uid/avatar.png" diff --git a/spec/models/user/connecting_spec.rb b/spec/models/user/connecting_spec.rb index 387ebc1bc12aaa727dc35c1531ebe7190bd77e05..e01e679e8619c9b32824e9b8db878bf126119405 100644 --- a/spec/models/user/connecting_spec.rb +++ b/spec/models/user/connecting_spec.rb @@ -63,7 +63,7 @@ describe User::Connecting do end it 'dispatches a retraction' do - p = mock() + p = double() Postzord::Dispatcher.should_receive(:build).and_return(p) p.should_receive(:post) @@ -155,7 +155,7 @@ describe User::Connecting do end it 'posts profile' do - m = mock() + m = double() Postzord::Dispatcher.should_receive(:build).twice.and_return(m) m.should_receive(:post).twice alice.share_with(eve.person, alice.aspects.first) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index ffc7f49364beb2ac0a3ad1278308e2e17c325da3..6af10f13ab40f8645257d4c610a65be6fe02a0ac 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -94,7 +94,7 @@ describe User do User.daily_actives.should_not include(user) end end - + describe 'halfyear_actives' do it 'returns list which includes users who latest signed in within half a year' do user = FactoryGirl.build(:user) @@ -835,7 +835,7 @@ describe User do describe '#retract' do before do - @retraction = mock + @retraction = double @post = FactoryGirl.build(:status_message, :author => bob.person, :public => true) end @@ -846,7 +846,7 @@ describe User do end it 'sends a retraction' do - dispatcher = mock + dispatcher = double Postzord::Dispatcher.should_receive(:build).with(bob, @retraction, anything()).and_return(dispatcher) dispatcher.should_receive(:post) @@ -858,7 +858,7 @@ describe User do reshare = FactoryGirl.create(:reshare, :root => @post, :author => person) @post.reshares << reshare - dispatcher = mock + dispatcher = double Postzord::Dispatcher.should_receive(:build).with(bob, @retraction, {:additional_subscribers => [person], :services => anything}).and_return(dispatcher) dispatcher.should_receive(:post) @@ -925,9 +925,9 @@ describe User do AppConfig.settings.autofollow_on_join = true AppConfig.settings.autofollow_on_join_user = 'one' - wf_mock = mock - wf_mock.should_receive(:fetch) - Webfinger.should_receive(:new).with('one').and_return(wf_mock) + wf_double = double + wf_double.should_receive(:fetch) + Webfinger.should_receive(:new).with('one').and_return(wf_double) user.seed_aspects end diff --git a/spec/presenters/post_presenter_spec.rb b/spec/presenters/post_presenter_spec.rb index 0d4cbe6b776de51f03ace8d39d8f72ada3c481d0..dca62936eef13847d9377b8cad0811e97d238b29 100644 --- a/spec/presenters/post_presenter_spec.rb +++ b/spec/presenters/post_presenter_spec.rb @@ -67,13 +67,13 @@ describe PostPresenter do context 'with posts with text' do context 'with a Markdown header of less than 200 characters on first line'do it 'returns atx style header' do - @sm = stub(:text => "## My title\n Post content...") + @sm = double(:text => "## My title\n Post content...") @presenter.post = @sm @presenter.title.should == "## My title" end it 'returns setext style header' do - @sm = stub(:text => "My title \n======\n Post content...") + @sm = double(:text => "My title \n======\n Post content...") @presenter.post = @sm @presenter.title.should == "My title \n======" end @@ -81,7 +81,7 @@ describe PostPresenter do context 'without a Markdown header of less than 200 characters on first line 'do it 'truncates post to the 20 first characters' do - @sm = stub(:text => "Very, very, very long post") + @sm = double(:text => "Very, very, very long post") @presenter.post = @sm @presenter.title.should == "Very, very, very ..." end @@ -90,7 +90,7 @@ describe PostPresenter do context 'with posts without text' do it ' displays a messaage with the post class' do - @sm = stub(:text => "", :author => bob.person, :author_name => bob.person.name) + @sm = double(:text => "", :author => bob.person, :author_name => bob.person.name) @presenter.post = @sm @presenter.title.should == "A post from #{@sm.author.name}" end diff --git a/spec/presenters/service_presenter_spec.rb b/spec/presenters/service_presenter_spec.rb index fe3c8a418f95b77fdeb2569530f6b62741060830..62c959af9e0cdd32d551d9cdecca1f28cde98ac7 100644 --- a/spec/presenters/service_presenter_spec.rb +++ b/spec/presenters/service_presenter_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe ServicePresenter do describe '#as_json' do it 'includes the provider name of the json' do - presenter = ServicePresenter.new(stub(:provider => "fakebook")) + presenter = ServicePresenter.new(double(:provider => "fakebook")) presenter.as_json[:provider].should == 'fakebook' end end diff --git a/spec/presenters/user_presenter_spec.rb b/spec/presenters/user_presenter_spec.rb index 38720dcb3a8499941982c14ae1a302ff99b4714f..04b57b4c17dd4d66bf3ca94cfa2fe5f2f27086b8 100644 --- a/spec/presenters/user_presenter_spec.rb +++ b/spec/presenters/user_presenter_spec.rb @@ -21,7 +21,7 @@ describe UserPresenter do describe '#services' do it 'provides an array of jsonifed services' do - fakebook = stub(:provider => 'fakebook') + fakebook = double(:provider => 'fakebook') bob.stub(:services).and_return([fakebook]) @presenter.services.should include(:provider => 'fakebook') end @@ -29,7 +29,7 @@ describe UserPresenter do describe '#configured_services' do it 'displays a list of the users configured services' do - fakebook = stub(:provider => 'fakebook') + fakebook = double(:provider => 'fakebook') bob.stub(:services).and_return([fakebook]) @presenter.configured_services.should include("fakebook") end diff --git a/spec/workers/delete_account_spec.rb b/spec/workers/delete_account_spec.rb index fd6c98a6b347ae73e19f8633e301dfe365369564..5f374cfd3e570748e28440c73d372dee3dbb7b81 100644 --- a/spec/workers/delete_account_spec.rb +++ b/spec/workers/delete_account_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe Workers::DeleteAccount do describe '#perform' do it 'performs the account deletion' do - account_deletion = stub + account_deletion = double AccountDeletion.stub(:find).and_return(account_deletion) account_deletion.should_receive(:perform!) diff --git a/spec/workers/delete_post_from_service_spec.rb b/spec/workers/delete_post_from_service_spec.rb index 221a86e432144ab1eb88d96463edbe68a6cff0ec..b941335c1021d6698d4b26239edc934db742c5ee 100644 --- a/spec/workers/delete_post_from_service_spec.rb +++ b/spec/workers/delete_post_from_service_spec.rb @@ -7,7 +7,7 @@ describe Workers::DeletePostFromService do end it 'calls service#delete_post with given service' do - m = mock() + m = double() url = "foobar" m.should_receive(:delete_post) Service.stub(:find_by_id).and_return(m) diff --git a/spec/workers/fetch_profile_photo_spec.rb b/spec/workers/fetch_profile_photo_spec.rb index cc1253b3251e44d98238d0567b64e85b46b103ef..24afa1d705775f9dc50a592ba4364cd7e5eded53 100644 --- a/spec/workers/fetch_profile_photo_spec.rb +++ b/spec/workers/fetch_profile_photo_spec.rb @@ -13,14 +13,14 @@ describe Workers::FetchProfilePhoto do User.stub(:find).and_return(@user) Service.stub(:find).and_return(@service) - @photo_stub = stub - @photo_stub.stub(:save!).and_return(true) - @photo_stub.stub(:url).and_return("image.jpg") + @photo_double = double + @photo_double.stub(:save!).and_return(true) + @photo_double.stub(:url).and_return("image.jpg") end it 'saves the profile image' do - @photo_stub.should_receive(:save!).and_return(true) - Photo.should_receive(:diaspora_initialize).with(hash_including(:author => @user.person, :image_url => @url, :pending => true)).and_return(@photo_stub) + @photo_double.should_receive(:save!).and_return(true) + Photo.should_receive(:diaspora_initialize).with(hash_including(:author => @user.person, :image_url => @url, :pending => true)).and_return(@photo_double) Workers::FetchProfilePhoto.new.perform(@user.id, @service.id) end @@ -34,19 +34,19 @@ describe Workers::FetchProfilePhoto do end it "fetches fallback if it's provided" do - @photo_stub.should_receive(:save!).and_return(true) + @photo_double.should_receive(:save!).and_return(true) @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) + Photo.should_receive(:diaspora_initialize).with(hash_including(:author => @user.person, :image_url => "https://service.com/fallback_lowres.jpg", :pending => true)).and_return(@photo_double) Workers::FetchProfilePhoto.new.perform(@user.id, @service.id, "https://service.com/fallback_lowres.jpg") end end - it 'updates the profile' do - @photo_stub.stub(:url).and_return("large.jpg", "medium.jpg", "small.jpg") + it 'updates the profile' do + @photo_double.stub(:url).and_return("large.jpg", "medium.jpg", "small.jpg") - Photo.should_receive(:diaspora_initialize).and_return(@photo_stub) + Photo.should_receive(:diaspora_initialize).and_return(@photo_double) @user.should_receive(:update_profile).with(hash_including({ :image_url => "large.jpg", :image_url_medium => "medium.jpg", diff --git a/spec/workers/mail/mentioned_spec.rb b/spec/workers/mail/mentioned_spec.rb index d643ad28ece6e7817c2e4b1c1184c4e655a7b3ff..332f8cddafb61e74b743fdee3e8ffe22b145537a 100644 --- a/spec/workers/mail/mentioned_spec.rb +++ b/spec/workers/mail/mentioned_spec.rb @@ -11,9 +11,9 @@ describe Workers::Mail::Mentioned do sm = FactoryGirl.build(:status_message) m = Mention.new(:person => user.person, :post=> sm) - mail_mock = mock() - mail_mock.should_receive(:deliver) - Notifier.should_receive(:mentioned).with(user.id, sm.author.id, m.id).and_return(mail_mock) + mail_double = double() + mail_double.should_receive(:deliver) + Notifier.should_receive(:mentioned).with(user.id, sm.author.id, m.id).and_return(mail_double) Workers::Mail::Mentioned.new.perform(user.id, sm.author.id, m.id) end diff --git a/spec/workers/mail/private_message_spec.rb b/spec/workers/mail/private_message_spec.rb index 36a50716b9ab6f412f1521a7333c7eb9813bf6c3..3fa271342a75fd19adb4343845e57a814fe29f98 100644 --- a/spec/workers/mail/private_message_spec.rb +++ b/spec/workers/mail/private_message_spec.rb @@ -17,9 +17,9 @@ describe Workers::Mail::PrivateMessage do cnv = Conversation.create(create_hash) message = cnv.messages.first - mail_mock = mock() - mail_mock.should_receive(:deliver) - Notifier.should_receive(:mentioned).with(user2.id, user1.person.id, message.id).and_return(mail_mock) + mail_double = double() + mail_double.should_receive(:deliver) + Notifier.should_receive(:mentioned).with(user2.id, user1.person.id, message.id).and_return(mail_double) Workers::Mail::Mentioned.new.perform(user2.id, user1.person.id, message.id) end diff --git a/spec/workers/mail/reshared_spec.rb b/spec/workers/mail/reshared_spec.rb index 291682991385c601485bb2dc296dd288c3ef2b55..478cd5a96799cedbf907a79cb75fb5b90cae20bc 100644 --- a/spec/workers/mail/reshared_spec.rb +++ b/spec/workers/mail/reshared_spec.rb @@ -10,9 +10,9 @@ describe Workers::Mail::Reshared do sm = FactoryGirl.build(:status_message, :author => bob.person, :public => true) reshare = FactoryGirl.build(:reshare, :author => alice.person, :root=> sm) - mail_mock = mock() - mail_mock.should_receive(:deliver) - Notifier.should_receive(:reshared).with(bob.id, reshare.author.id, reshare.id).and_return(mail_mock) + mail_double = double() + mail_double.should_receive(:deliver) + Notifier.should_receive(:reshared).with(bob.id, reshare.author.id, reshare.id).and_return(mail_double) Workers::Mail::Reshared.new.perform(bob.id, reshare.author.id, reshare.id) end diff --git a/spec/workers/post_to_service_spec.rb b/spec/workers/post_to_service_spec.rb index 8382437c897e909003acd7e9c10972357dc97cb9..4ba8c476765049f5397d956dabb112ecfb2555cf 100644 --- a/spec/workers/post_to_service_spec.rb +++ b/spec/workers/post_to_service_spec.rb @@ -6,7 +6,7 @@ describe Workers::PostToService do 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) - m = mock() + m = double() url = "foobar" m.should_receive(:post).with(anything, url) Service.stub(:find_by_id).and_return(m) diff --git a/spec/workers/publish_to_hub_spec.rb b/spec/workers/publish_to_hub_spec.rb index 571b2a88498b1dda59e83166c7f0d7ee58e2437e..47cb4a9a4ae0f3dd1c841e1cab44667bc0f97d71 100644 --- a/spec/workers/publish_to_hub_spec.rb +++ b/spec/workers/publish_to_hub_spec.rb @@ -8,7 +8,7 @@ describe Workers::PublishToHub do describe '.perform' do it 'calls pubsubhubbub' do url = "http://publiczone.com/" - m = mock() + m = double() m.should_receive(:publish).with(url+'.atom') Pubsubhubbub.should_receive(:new).with(AppConfig.environment.pubsub_server).and_return(m) diff --git a/spec/workers/receive_salmon_spec.rb b/spec/workers/receive_salmon_spec.rb index b3dcafb9784106ca258821138420bbe97d3a12df..84e598e33cbaa14cef5aab6860d69cdcb3c2afdf 100644 --- a/spec/workers/receive_salmon_spec.rb +++ b/spec/workers/receive_salmon_spec.rb @@ -13,7 +13,7 @@ describe Workers::ReceiveEncryptedSalmon do } end it 'calls receive_salmon' do - zord = mock + zord = double zord.should_receive(:perform!) Postzord::Receiver::Private.should_receive(:new).with(@user, hash_including(:salmon_xml => @xml)).and_return(zord) diff --git a/spec/workers/receive_spec.rb b/spec/workers/receive_spec.rb index 0972079c46a5eb00b421d37820604669b44b60fb..dda95c8906e7ed0b1276ed94135d175ca8241f08 100644 --- a/spec/workers/receive_spec.rb +++ b/spec/workers/receive_spec.rb @@ -15,9 +15,9 @@ describe Workers::Receive do end it 'calls receive' do - zord_mock = mock() - zord_mock.should_receive(:parse_and_receive).with(@xml) - Postzord::Receiver::Private.should_receive(:new).with(@user, anything).and_return(zord_mock) + zord_double = double() + zord_double.should_receive(:parse_and_receive).with(@xml) + Postzord::Receiver::Private.should_receive(:new).with(@user, anything).and_return(zord_double) Workers::Receive.new.perform(@user.id, @xml, @person.id) end end