summaryrefslogtreecommitdiff
path: root/spec/githubrepo_spec.rb
blob: 9b509e43b0c41fccab18ad7c19a34a517d223709 (plain)
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
require 'spec_helper'
require 'rugged'
require 'oxidized/hook/githubrepo'

describe Oxidized::Node do
  before(:each) do
    asetus = Asetus.new
    asetus.cfg.output.git.repo = 'foo.git'
    asetus.cfg.hooks.github_repo_hook.remote_repo = 'https://github.com/blah/blah.git'
    asetus.cfg.hooks.github_repo_hook.username = 'username'
    asetus.cfg.hooks.github_repo_hook.password = 'password'
    GithubRepo.any_instance.stubs(:cfg).returns(asetus.cfg.hooks.github_repo_hook)
    Oxidized.stubs(:asetus).returns(asetus)
    repo = mock()
    remote = mock()
    remote.expects(:url).returns('github.com/foo.git')
    remote.expects(:push).returns(true)
    repo.expects(:remotes).returns({'origin' => remote})
    repo.expects(:path).returns('foo.git')
    repo_head = mock()
    repo_head.expects(:name).returns('origin/master')
    repo.expects(:head).returns(repo_head)
    repo.expects(:branches).returns({})
    Rugged::Repository.expects(:new).with('foo.git').returns(repo)
  end

  describe "#run_hook" do
    it "will push to the remote repository" do
      gr = GithubRepo.new
      gr.run_hook(nil).must_equal true
    end
  end
end