Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 126 lines (115 sloc) 4.691 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
require File.expand_path('../../spec_helper', __FILE__)

describe "Pod::Command" do
  extend SpecHelper::Git
  extend SpecHelper::TemporaryDirectory

  before do
    fixture('spec-repos/master') # ensure the archive is unpacked
  end

  it "creates the local spec-repos directory and creates a clone of the `master' repo" do
    command = Pod::Command.parse('setup', '--silent')
    def command.master_repo_url; SpecHelper.fixture('spec-repos/master'); end
    command.run
    git_config('master', 'remote.origin.url').should == fixture('spec-repos/master').to_s
  end

  it "adds a spec-repo" do
    add_repo('private', fixture('spec-repos/master'))
    git_config('private', 'remote.origin.url').should == fixture('spec-repos/master').to_s
  end

  it "updates a spec-repo" do
    repo1 = add_repo('repo1', fixture('spec-repos/master'))
    repo2 = add_repo('repo2', repo1.dir)
    make_change(repo1, 'repo1')
    command('repo', 'update', 'repo2')
    (repo2.dir + 'README').read.should.include 'Added!'
  end

  it "updates all the spec-repos" do
    repo1 = add_repo('repo1', fixture('spec-repos/master'))
    repo2 = add_repo('repo2', repo1.dir)
    repo3 = add_repo('repo3', repo1.dir)
    make_change(repo1, 'repo1')
    command('repo', 'update')
    (repo2.dir + 'README').read.should.include 'Added!'
    (repo3.dir + 'README').read.should.include 'Added!'
  end

  it "creates a new podspec stub file" do
    Dir.chdir(temporary_directory) do
      command('spec', 'create', 'Bananas')
    end
    path = temporary_directory + 'Bananas.podspec'
    spec = Pod::Specification.from_file(path)
    spec.name.should == 'Bananas'
    spec.version.should == Pod::Version.new('1.0.0')
    spec.summary.should == 'A short description of Bananas.'
    spec.homepage.should == 'http://example.com/Bananas'
    spec.authors.should == { `git config --get user.name`.strip => `git config --get user.email`.strip }
    spec.source.should == { :git => 'http://example.com/Bananas.git', :tag => '1.0.0' }
    spec.description.should == 'An optional longer description of Bananas.'
    spec.source_files.should == ['Classes', 'Classes/**/*.{h,m}']
    spec.xcconfig.to_hash.should == { 'OTHER_LDFLAGS' => '-framework SomeRequiredFramework' }
    spec.dependencies.should == [Pod::Dependency.new('SomeLibraryThatBananasDependsOn', '>= 1.0.0')]
  end

  before do
    config.repos_dir = fixture('spec-repos')
  end

  after do
    config.repos_dir = tmp_repos_path
  end

  it "searches for a pod with name matching the given query ignoring case" do
    [
      [
        ' s ',
        "==> ASIHTTPRequest (1.8.1)\n" \
        " Easy to use CFNetwork wrapper for HTTP requests, Objective-C, " \
        "Mac OS X and iPhone\n\n" \
        "==> ASIWebPageRequest (1.8.1)\n" \
        " The ASIWebPageRequest class included with ASIHTTPRequest lets you " \
        "download\n complete webpages, including external resources like " \
        "images and stylesheets.\n\n" \
        "==> JSONKit (1.4)\n" \
        " A Very High Performance Objective-C JSON Library.\n\n" \
        "==> SSZipArchive (0.1.0)\n" \
        " Utility class for unzipping files on iOS and Mac.\n\n"
      ],
      [
        'json',
        "==> JSONKit (1.4)\n" \
        " A Very High Performance Objective-C JSON Library.\n\n",
      ]
    ].each do |query, result|
      command = Pod::Command.parse('search', '--silent', query)
      def command.puts(msg = '')
        (@printed ||= '') << "#{msg}\n"
      end
      command.run
      printed = command.instance_variable_get(:@printed)
      result.split("\n\n").each { |pod| printed.should.include? pod }
    end
  end

  it "searches for a pod with name, summary, or description matching the given query ignoring case" do
    [
      [
        'systemCONfiguration',
        "==> Reachability (2.0.4)\n" \
        " A wrapper for the SystemConfiguration Reachablity APIs.\n\n",
      ],
      [
        'is',
        "==> ASIHTTPRequest (1.8.1)\n" \
        " Easy to use CFNetwork wrapper for HTTP requests, Objective-C, " \
        "Mac OS X and iPhone\n\n" \
        "==> Reachability (2.0.4)\n" \
        " A wrapper for the SystemConfiguration Reachablity APIs.\n\n" \
        "==> SSZipArchive (0.1.0)\n" \
        " Utility class for unzipping files on iOS and Mac.\n\n"
      ]
    ].each do |query, result|
      command = Pod::Command.parse('search', '--silent', '--full', query)
      def command.puts(msg = '')
        (@printed ||= '') << "#{msg}\n"
      end
      command.run
      printed = command.instance_variable_get(:@printed)
      result.split("\n\n").each { |pod| printed.should.include? pod }
    end
  end
end
Something went wrong with that request. Please try again.