Commit ec33cde4 authored by Samuel E. Giddins's avatar Samuel E. Giddins

Ensure that we raise when attempting to stub an undefined method

parent 87d622c3
...@@ -40,6 +40,8 @@ module Pod ...@@ -40,6 +40,8 @@ module Pod
# #
attr_reader :update_mode attr_reader :update_mode
alias_method :update_mode?, :update_mode
# @return [Lockfile] The lockfile of the installation as a fall-back if # @return [Lockfile] The lockfile of the installation as a fall-back if
# there is no sandbox manifest. This is indented as a temporary # there is no sandbox manifest. This is indented as a temporary
# solution to prevent the full re-installation from users which # solution to prevent the full re-installation from users which
......
...@@ -42,9 +42,9 @@ module Pod ...@@ -42,9 +42,9 @@ module Pod
it 'prints a list of podspecs in the yaml format and prints it to STDOUT' do it 'prints a list of podspecs in the yaml format and prints it to STDOUT' do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
set = Specification.new('BananaLib') set = Specification::Set.new('BananaLib', [])
set.stubs(:specification).returns(spec) set.stubs(:specification).returns(spec)
SourcesManager.stubs(:all_sets).returns([set]) Source.any_instance.stubs(:pod_sets).returns([set])
out = run_command('ipc', 'list') out = run_command('ipc', 'list')
out.should.include('---') out.should.include('---')
......
...@@ -7,7 +7,7 @@ module Pod ...@@ -7,7 +7,7 @@ module Pod
before do before do
@test_source = Source.new(fixture('spec-repos/test_repo')) @test_source = Source.new(fixture('spec-repos/test_repo'))
Source::Aggregate.any_instance.stubs(:all).returns([@test_source]) SourcesManager.stubs(:all).returns([@test_source])
SourcesManager.updated_search_index = nil SourcesManager.updated_search_index = nil
end end
......
...@@ -92,6 +92,8 @@ module Bacon ...@@ -92,6 +92,8 @@ module Bacon
end end
end end
Mocha::Configuration.prevent(:stubbing_non_existent_method)
module SpecHelper module SpecHelper
def self.temporary_directory def self.temporary_directory
ROOT + 'tmp' ROOT + 'tmp'
......
...@@ -136,7 +136,7 @@ module Pod ...@@ -136,7 +136,7 @@ module Pod
workspace = Xcodeproj::Workspace.new(file_references) workspace = Xcodeproj::Workspace.new(file_references)
workspace_path = @integrator.send(:workspace_path) workspace_path = @integrator.send(:workspace_path)
workspace.save_as(workspace_path) workspace.save_as(workspace_path)
Xcodeproj::Workspace.expects(:save_as).never Xcodeproj::Workspace.any_instance.expects(:save_as).never
@integrator.send(:create_workspace) @integrator.send(:create_workspace)
end end
......
...@@ -74,7 +74,6 @@ module Pod ...@@ -74,7 +74,6 @@ module Pod
@installer.stubs(:run_pre_install_hooks) @installer.stubs(:run_pre_install_hooks)
@installer.stubs(:install_file_references) @installer.stubs(:install_file_references)
@installer.stubs(:install_libraries) @installer.stubs(:install_libraries)
@installer.stubs(:link_aggregate_target)
@installer.stubs(:write_lockfiles) @installer.stubs(:write_lockfiles)
@installer.stubs(:aggregate_targets).returns([]) @installer.stubs(:aggregate_targets).returns([])
@installer.unstub(:generate_pods_project) @installer.unstub(:generate_pods_project)
......
...@@ -38,13 +38,13 @@ module Pod ...@@ -38,13 +38,13 @@ module Pod
describe 'In general' do describe 'In general' do
before do before do
Source::Aggregate.any_instance.stubs(:all).returns([@test_source]) SourcesManager.stubs(:all).returns([@test_source])
end end
#--------------------------------------# #--------------------------------------#
it 'returns all the sources' do it 'returns all the sources' do
Source::Aggregate.any_instance.unstub(:all) SourcesManager.unstub(:all)
SourcesManager.all.map(&:name).should == %w(master test_repo) SourcesManager.all.map(&:name).should == %w(master test_repo)
end end
...@@ -66,21 +66,21 @@ module Pod ...@@ -66,21 +66,21 @@ module Pod
end end
it 'can perform a full text search of the sets' do it 'can perform a full text search of the sets' do
Source::Aggregate.any_instance.stubs(:all).returns([@test_source]) SourcesManager.stubs(:all).returns([@test_source])
sets = SourcesManager.search_by_name('Chunky', true) sets = SourcesManager.search_by_name('Chunky', true)
sets.all? { |s| s.class == Specification::Set }.should.be.true sets.all? { |s| s.class == Specification::Set }.should.be.true
sets.any? { |s| s.name == 'BananaLib' }.should.be.true sets.any? { |s| s.name == 'BananaLib' }.should.be.true
end end
it 'can perform a full text regexp search of the sets' do it 'can perform a full text regexp search of the sets' do
Source::Aggregate.any_instance.stubs(:all).returns([@test_source]) SourcesManager.stubs(:all).returns([@test_source])
sets = SourcesManager.search_by_name('Ch[aeiou]nky', true) sets = SourcesManager.search_by_name('Ch[aeiou]nky', true)
sets.all? { |s| s.class == Specification::Set }.should.be.true sets.all? { |s| s.class == Specification::Set }.should.be.true
sets.any? { |s| s.name == 'BananaLib' }.should.be.true sets.any? { |s| s.name == 'BananaLib' }.should.be.true
end end
it "generates the search index before performing a search if it doesn't exits" do it "generates the search index before performing a search if it doesn't exits" do
Source::Aggregate.any_instance.stubs(:all).returns([@test_source]) SourcesManager.stubs(:all).returns([@test_source])
Source::Aggregate.any_instance.expects(:generate_search_index).returns('BananaLib' => {}) Source::Aggregate.any_instance.expects(:generate_search_index).returns('BananaLib' => {})
Source::Aggregate.any_instance.expects(:update_search_index).never Source::Aggregate.any_instance.expects(:update_search_index).never
SourcesManager.updated_search_index = nil SourcesManager.updated_search_index = nil
...@@ -89,7 +89,7 @@ module Pod ...@@ -89,7 +89,7 @@ module Pod
it 'updates the search index before performing a search if it exits' do it 'updates the search index before performing a search if it exits' do
File.open(SourcesManager.search_index_path, 'w') { |file| file.write("---\nBananaLib:\n version: 0.0.1") } File.open(SourcesManager.search_index_path, 'w') { |file| file.write("---\nBananaLib:\n version: 0.0.1") }
Source::Aggregate.any_instance.stubs(:all).returns([@test_source]) SourcesManager.stubs(:all).returns([@test_source])
Source::Aggregate.any_instance.expects(:generate_search_index).never Source::Aggregate.any_instance.expects(:generate_search_index).never
Source::Aggregate.any_instance.expects(:update_search_index).returns('BananaLib' => {}) Source::Aggregate.any_instance.expects(:update_search_index).returns('BananaLib' => {})
SourcesManager.updated_search_index = nil SourcesManager.updated_search_index = nil
......
...@@ -202,7 +202,7 @@ module Pod ...@@ -202,7 +202,7 @@ module Pod
end end
it 'checks if the social media URL is valid' do it 'checks if the social media URL is valid' do
Specification.any_instance.stubs(:social_media_urlon_url).returns('http://banana-corp.local/') Specification.any_instance.stubs(:social_media_url).returns('http://banana-corp.local/')
WebMock::API.stub_request(:head, /banana-corp.local/).to_return(:status => 200) WebMock::API.stub_request(:head, /banana-corp.local/).to_return(:status => 200)
@sut.validate @sut.validate
@sut.results.should.be.empty? @sut.results.should.be.empty?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment