Sha256: 0ebdbbd99349837403f4a1bfa07a73127fd362ce1181bf869e83c83d37035549

Contents?: true

Size: 1.72 KB

Versions: 5

Compression:

Stored size: 1.72 KB

Contents

$LOAD_PATH << 'lib'
require 'git_reflow'
require 'github_api'
require File.expand_path('../web_mocks', __FILE__)
require File.expand_path('../fixtures', __FILE__)

module GithubHelpers
  def stub_github_with(options = {})
    github = Github.new
    user = options[:user] || 'reenhanced'
    repo = options[:repo] || 'repo'
    branch = options[:branch] || 'new-feature'
    pull = options[:pull]

    Github.stub :new => github
    GitReflow.stub(:push_current_branch).and_return(true)
    GitReflow.stub(:github).and_return(github)
    GitReflow.stub(:current_branch).and_return(branch)
    GitReflow.stub(:remote_repo_name).and_return(repo)
    GitReflow.stub(:remote_user).and_return(user)
    GitReflow.stub(:fetch_destination).and_return(true)
    GitReflow.stub(:update_destination).and_return(true)

    if pull
      # Stubbing review
      github.pull_requests.stub(:create).with(user, repo, pull.except('state')).and_return(Hashie::Mash.new(:number => '1', :title => pull['title'], :html_url => "http://github.com/#{user}/#{repo}/pulls/1"))
      stub_post("/repos/#{user}/#{repo}/pulls").
        to_return(:body => fixture('pull_requests/pull_request.json'), :status => 201, :headers => {:content_type => "application/json\; charset=utf-8"})

      # Stubbing pull request finder
      stub_get("/repos/#{user}/#{repo}/pulls").with(:query => {'state' => 'open'}).
        to_return(:body => fixture('pull_requests/pull_requests.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
    end
  end
end

# the github_api gem does some overrides to Hash so we have to make sure
# this still works here...
class Hash
  def except(*keys)
    cpy = self.dup
    keys.each { |key| cpy.delete(key) }
    cpy
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
git_reflow-0.2.5 spec/support/github_helpers.rb
git_reflow-0.2.4 spec/support/github_helpers.rb
git_reflow-0.2.2 spec/support/github_helpers.rb
git_reflow-0.2.1 spec/support/github_helpers.rb
git_reflow-0.2 spec/support/github_helpers.rb