jqr-github 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +18 -0
- data/Manifest +23 -0
- data/README +164 -0
- data/bin/gh +8 -0
- data/bin/github +8 -0
- data/github-gem.gemspec +26 -0
- data/lib/commands/commands.rb +205 -0
- data/lib/commands/helpers.rb +397 -0
- data/lib/commands/network.rb +113 -0
- data/lib/github/command.rb +129 -0
- data/lib/github/extensions.rb +39 -0
- data/lib/github/helper.rb +4 -0
- data/lib/github.rb +173 -0
- data/spec/command_spec.rb +82 -0
- data/spec/extensions_spec.rb +36 -0
- data/spec/github_spec.rb +85 -0
- data/spec/helper_spec.rb +280 -0
- data/spec/spec_helper.rb +138 -0
- data/spec/ui_spec.rb +604 -0
- data/spec/windoze_spec.rb +36 -0
- metadata +94 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spec'
|
3
|
+
|
4
|
+
require File.dirname(__FILE__) + '/../lib/github'
|
5
|
+
|
6
|
+
class Module
|
7
|
+
def metaclass
|
8
|
+
class << self;self;end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Spec::NextInstanceProxy
|
13
|
+
def initialize
|
14
|
+
@deferred = []
|
15
|
+
end
|
16
|
+
|
17
|
+
def method_missing(sym, *args)
|
18
|
+
proxy = Spec::NextInstanceProxy.new
|
19
|
+
@deferred << [sym, args, proxy]
|
20
|
+
proxy
|
21
|
+
end
|
22
|
+
|
23
|
+
def should_receive(*args)
|
24
|
+
method_missing(:should_receive, *args)
|
25
|
+
end
|
26
|
+
alias stub! should_receive
|
27
|
+
|
28
|
+
def invoke(obj)
|
29
|
+
@deferred.each do |(sym, args, proxy)|
|
30
|
+
result = obj.send(sym, *args)
|
31
|
+
proxy.invoke(result)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class Class
|
37
|
+
def next_instance
|
38
|
+
meth = metaclass.instance_method(:new)
|
39
|
+
proxy = Spec::NextInstanceProxy.new
|
40
|
+
metaclass.send :define_method, :new do |*args|
|
41
|
+
instance = meth.bind(self).call(*args)
|
42
|
+
proxy.invoke(instance)
|
43
|
+
metaclass.send :define_method, :new, meth
|
44
|
+
instance
|
45
|
+
end
|
46
|
+
proxy
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
module Spec::Example::ExampleGroupSubclassMethods
|
51
|
+
def add_guard(klass, name, is_class = false)
|
52
|
+
guarded = nil # define variable now for scoping
|
53
|
+
target = (is_class ? klass.metaclass : klass)
|
54
|
+
sep = (is_class ? "." : "#")
|
55
|
+
target.class_eval do
|
56
|
+
guarded = instance_method(name)
|
57
|
+
define_method name do |*args|
|
58
|
+
raise "Testing guards violated: Cannot call #{klass}#{sep}#{name}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
@guards ||= []
|
62
|
+
@guards << [klass, name, is_class, guarded]
|
63
|
+
end
|
64
|
+
|
65
|
+
def add_class_guard(klass, name)
|
66
|
+
add_guard(klass, name, true)
|
67
|
+
end
|
68
|
+
|
69
|
+
def unguard(klass, name, is_class = false)
|
70
|
+
row = @guards.find { |(k,n,i)| k == klass and n == name and i == is_class }
|
71
|
+
raise "#{klass}#{is_class ? "." : "#"}#{name} is not guarded" if row.nil?
|
72
|
+
(is_class ? klass.metaclass : klass).class_eval do
|
73
|
+
define_method name, row.last
|
74
|
+
end
|
75
|
+
@guards.delete row
|
76
|
+
end
|
77
|
+
|
78
|
+
def class_unguard(klass, name)
|
79
|
+
unguard(klass, name, true)
|
80
|
+
end
|
81
|
+
|
82
|
+
def unguard_all
|
83
|
+
@guards ||= []
|
84
|
+
@guards.each do |klass, name, is_class, guarded|
|
85
|
+
(is_class ? klass.metaclass : klass).class_eval do
|
86
|
+
define_method name, guarded
|
87
|
+
end
|
88
|
+
end
|
89
|
+
@guards.clear
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# prevent the use of `` in tests
|
94
|
+
Spec::Runner.configure do |configuration|
|
95
|
+
# load this here so it's covered by the `` guard
|
96
|
+
configuration.prepend_before(:all) do
|
97
|
+
module GitHub
|
98
|
+
load 'helpers.rb'
|
99
|
+
load 'commands.rb'
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
configuration.prepend_after(:each) do
|
104
|
+
GitHub.instance_variable_set :'@options', nil
|
105
|
+
GitHub.instance_variable_set :'@debug', nil
|
106
|
+
end
|
107
|
+
|
108
|
+
configuration.prepend_before(:all) do
|
109
|
+
self.class.send :include, Spec::Example::ExampleGroupSubclassMethods
|
110
|
+
end
|
111
|
+
|
112
|
+
configuration.prepend_before(:each) do
|
113
|
+
add_guard Kernel, :`
|
114
|
+
add_guard Kernel, :system
|
115
|
+
add_guard Kernel, :fork
|
116
|
+
add_guard Kernel, :exec
|
117
|
+
add_class_guard Process, :fork
|
118
|
+
end
|
119
|
+
|
120
|
+
configuration.append_after(:each) do
|
121
|
+
unguard_all
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# include this in any example group that defines @helper
|
126
|
+
module SetupMethods
|
127
|
+
def setup_user_and_branch(user = :user, branch = :master)
|
128
|
+
@helper.should_receive(:user_and_branch).any_number_of_times.and_return([user, branch])
|
129
|
+
end
|
130
|
+
|
131
|
+
def setup_url_for(remote = :origin, user = nil, project = :project)
|
132
|
+
if user.nil?
|
133
|
+
user = remote
|
134
|
+
user = "user" if remote == :origin
|
135
|
+
end
|
136
|
+
@helper.should_receive(:url_for).any_number_of_times.with(remote).and_return("git://github.com/#{user}/#{project}.git")
|
137
|
+
end
|
138
|
+
end
|