require File.expand_path('../spec_helper', __FILE__) describe SourceHelper do describe 'behaviour' do it 'should group the private specs from the differents private sources' do SourceHelper.instance.specs = [] # Avoid a non-empty SourceHelper private_sources = [ "git@github.com:mercadolibre/mobile-ios_specs.git", "git@github.com:testable/testable_specs.git" ] private_meli_specs = ["MyMELIPod1", "MyMELIPod2", "MyMELIPod3"] meli_mock = mock() meli_mock.stubs(:url).returns("git@github.com:mercadolibre/mobile-ios_specs.git") meli_mock.stubs(:pods).returns(private_meli_specs) private_cocoapods_cdn_specs = ["MyPublicPod1", "MyPublicPod2", "MyPublicPod2"] cocoapods_cdn_mock = mock() cocoapods_cdn_mock.stubs(:url).returns("https://cdn.cocoapods.org/") cocoapods_cdn_mock.stubs(:pods).returns(private_cocoapods_cdn_specs) private_testable_specs = ["MyTestablePod1", "MyTestablePod2", "MyTestablePod2"] testable_mock = mock() testable_mock.stubs(:url).returns("git@github.com:testable/testable_specs.git") testable_mock.stubs(:pods).returns(private_testable_specs) sources = [meli_mock, cocoapods_cdn_mock, testable_mock] expected_result = [ "MyMELIPod1", "MyMELIPod2", "MyMELIPod3", "MyTestablePod1", "MyTestablePod2", "MyTestablePod2" ] validator = SourceHelper.instance.setup(sources, private_sources) SourceHelper.instance.specs.size.should.equal 6 SourceHelper.instance.is_filled.should.be.true SourceHelper.instance.specs.should.equal expected_result end it 'should not be filled if not specs been added' do SourceHelper.instance.specs = [] # Avoid a non-empty SourceHelper private_sources = [ "git@github.com:mercadolibre/mobile-ios_specs.git", "git@github.com:testable/testable_specs.git" ] private_meli_specs = [] meli_mock = mock() meli_mock.stubs(:url).returns("git@github.com:mercadolibre/mobile-ios_specs.git") meli_mock.stubs(:pods).returns(private_meli_specs) private_cocoapods_cdn_specs = [] cocoapods_cdn_mock = mock() cocoapods_cdn_mock.stubs(:url).returns("https://cdn.cocoapods.org/") cocoapods_cdn_mock.stubs(:pods).returns(private_cocoapods_cdn_specs) private_testable_specs = [] testable_mock = mock() testable_mock.stubs(:url).returns("git@github.com:testable/testable_specs.git") testable_mock.stubs(:pods).returns(private_testable_specs) sources = [meli_mock, cocoapods_cdn_mock, testable_mock] validator = SourceHelper.instance.setup(sources, private_sources) SourceHelper.instance.specs.size.should.equal 0 SourceHelper.instance.is_filled.should.not.be.true end end end