git-issue 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,78 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe GitIssue::Base do
4
+
5
+ class SampleIts < GitIssue::Base
6
+ def show(options = {});end
7
+ def guess_ticket; 6789 end
8
+ end
9
+
10
+ describe '#initialize' do
11
+ context 'specified unknown g ' do
12
+ let(:args) { ["homuhomu", "1234"] }
13
+ it { lambda{ SampleIts.new(args) }.should raise_error }
14
+ end
15
+
16
+ context 'specified known g ' do
17
+ let(:args) { ["show", "1234"] }
18
+
19
+ subject{ SampleIts.new(args) }
20
+
21
+ it { subject.command.name.should == :show }
22
+ its(:tickets) { should == [1234] }
23
+ end
24
+
25
+ context 'args is blank' do
26
+ let (:args) { [] }
27
+
28
+ subject { SampleIts.new(args) }
29
+
30
+ it { subject.command.name.should == :show }
31
+ its(:tickets) { should == [6789]}
32
+ end
33
+
34
+ context 'specified number only' do
35
+ let (:args) {["9876"] }
36
+
37
+ subject { SampleIts.new(args) }
38
+
39
+ it { subject.command.name.should == :show }
40
+ its(:tickets) { should == [9876]}
41
+ end
42
+
43
+ context 'specified multipul numbers ' do
44
+ let(:args) { ["1234", "5678", "9999"] }
45
+
46
+ subject { SampleIts.new(args) }
47
+
48
+ it { subject.command.name.should == :show }
49
+ its(:tickets) { should == [1234, 5678, 9999]}
50
+ end
51
+ end
52
+
53
+ describe '#execute' do
54
+
55
+ context 'one ticket_id specified' do
56
+ let(:args) { ["show", "1234"] }
57
+ let(:its) { SampleIts.new(args) }
58
+
59
+ it { its.should_receive(:show).with(its.options.merge(:ticket_id => 1234)).once }
60
+ after { its.execute }
61
+ end
62
+
63
+ context 'three ticket_ids specified' do
64
+ let(:args) { ["show", "1234", "5678", "9999"] }
65
+ let(:its) { SampleIts.new(args) }
66
+
67
+ it {
68
+ its.should_receive(:show).with(its.options.merge(:ticket_id => 1234)).once
69
+ its.should_receive(:show).with(its.options.merge(:ticket_id => 5678)).once
70
+ its.should_receive(:show).with(its.options.merge(:ticket_id => 9999)).once
71
+ }
72
+ after { its.execute }
73
+ end
74
+
75
+ end
76
+
77
+
78
+ end
@@ -0,0 +1,186 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe GitIssue::Github do
4
+
5
+ let(:apikey) { "ABCDEFG1234567890" }
6
+ let(:user) { "yuroyoro" }
7
+ let(:repo) { "gitterb" }
8
+
9
+ describe '#initialize' do
10
+ context 'ginve no apikey ' do
11
+ let(:args) { ["show", "1234"] }
12
+ it { lambda{ GitIssue::Github.new(args) }.should raise_error }
13
+ end
14
+
15
+ context 'given no user' do
16
+ let(:args) { ["show", "1234"] }
17
+ it { lambda{ GitIssue::Github.new(args, :apikey => apikey) }.should raise_error }
18
+ end
19
+
20
+ context 'given no repo' do
21
+ let(:args) { ["show", "1234"] }
22
+ it { lambda{ GitIssue::Github.new(args, :apikey => apikey, :user => user) }.should raise_error }
23
+ end
24
+
25
+ context 'given apikey, user and repo ' do
26
+ let(:args) { ["show", "1234"] }
27
+ it { lambda{ GitIssue::Github.new(args, :apikey => apikey, :user => user, :repo => repo) }.should_not raise_error }
28
+ end
29
+ end
30
+
31
+ describe '#show' do
32
+ let(:args) { ["show", "1234"] }
33
+ let(:sysout) { StringIO.new }
34
+ let(:syserr) { StringIO.new }
35
+ let(:github) { GitIssue::Github.new(args, :apikey => apikey, :user => user, :repo => repo, :sysout => sysout, :syserr => syserr) }
36
+
37
+ let(:json) {{"issue"=>
38
+ {"body" =>"change diff views like github.",
39
+ "closed_at" =>"2011/07/20 01:48:05 -0700",
40
+ "comments" =>1,
41
+ "created_at" =>"2011/07/14 04:14:12 -0700",
42
+ "gravatar_id"=>"bd3590aaffe8948079d27795cb6f7388",
43
+ "html_url" =>"https://github.com/yuroyoro/gitterb/issues/1",
44
+ "labels" =>[],
45
+ "number" =>1,
46
+ "position" =>1.0,
47
+ "state" =>"closed",
48
+ "title" =>"improve diff views",
49
+ "updated_at" =>"2011/07/20 01:48:05 -0700",
50
+ "user" =>"yuroyoro",
51
+ "votes" =>0}}
52
+ }
53
+
54
+ let(:comments) { [
55
+ { "user"=>"yuroyoro", "gravatar_id"=>"bd3590aaffe8948079d27795cb6f7388",
56
+ "updated_at"=>"2011/07/20 01:48:05 -0700", "body"=>"completed.", "id"=>1613903,
57
+ "created_at"=>"2011/07/20 01:48:05 -0700"},
58
+ { "user"=>"foolesa", "gravatar_id"=>"bd3590aaffe8948079d27795cb6f7388",
59
+ "updated_at"=>"2011/07/22 03:50:05 -0700",
60
+ "body"=>"らめぇぁ…あ!!!あひゃぴー?ひぃぱぎぃっうふふ?", "id"=>1613904,
61
+ "created_at"=>"2011/07/23 04:48:05 -0700"}
62
+ ]
63
+ }
64
+
65
+ context 'given no ticket_id' do
66
+ it { lambda {github.show() }.should raise_error( 'ticket_id is required.') }
67
+ end
68
+
69
+ context 'given ticket_id' do
70
+
71
+ before {
72
+ github.should_receive(:fetch_json).and_return(json)
73
+ github.show(:ticket_id => 1234)
74
+ }
75
+ subject { github.sysout.rewind; github.sysout.read }
76
+
77
+ it { sysout.length.should_not be_zero }
78
+ it { syserr.length.should be_zero }
79
+
80
+ it { should include '[closed] #1 improve diff views' }
81
+ it { should include 'yuroyoro opened this issue Thu Jul 14 20:14:12 +0900 2011' }
82
+ it { should include 'change diff views like github.' }
83
+
84
+ end
85
+
86
+ context 'given ticket_id with --comments' do
87
+
88
+ before {
89
+ github.should_receive(:fetch_json).and_return(json)
90
+ github.should_receive(:fetch_comments).and_return(comments)
91
+ github.show(:ticket_id => 1234, :comments=> true)
92
+ }
93
+ subject { github.sysout.rewind; github.sysout.read }
94
+
95
+ it { sysout.length.should_not be_zero }
96
+ it { syserr.length.should be_zero }
97
+
98
+ it { should include '[closed] #1 improve diff views' }
99
+
100
+ end
101
+ end
102
+
103
+ describe '#list' do
104
+ let(:args) { ["list","--status=closed"] }
105
+ let(:sysout) { StringIO.new }
106
+ let(:syserr) { StringIO.new }
107
+ let(:github) { GitIssue::Github.new(args, :apikey => apikey, :user => user, :repo => repo, :sysout => sysout, :syserr => syserr) }
108
+
109
+ let(:issues) {
110
+ {"issues" =>
111
+ [{"body" => "It appeared two commit has same SHA-1.\r\nThat's maybe branch's commit.",
112
+ "closed_at" =>"2011/07/20 05:28:42 -0700", "comments" =>1,
113
+ "created_at" =>"2011/07/20 04:18:23 -0700", "gravatar_id"=>"bd3590aaffe8948079d27795cb6f7388",
114
+ "html_url" =>"https://github.com/yuroyoro/gitterb/issues/5",
115
+ "labels" =>["foo","bar"], "number" =>5, "position" =>1.0,
116
+ "state" =>"closed", "title" =>"Rendered duplicate commit node.",
117
+ "updated_at" =>"2011/07/20 05:28:51 -0700", "user" =>"yuroyoro", "votes" =>0},
118
+ {"body" => "if the 'all' checked ,it will be rendered all other branches that reach from selected branch's commit.\r\nif selected branch is near from first commit, it will be rendered all most commits and branches.\r\nit's too slow and rendered diagram to be large.",
119
+ "closed_at" =>"2011/07/20 00:06:27 -0700", "comments" =>1,
120
+ "created_at" =>"2011/07/19 23:21:20 -0700", "gravatar_id"=>"bd3590aaffe8948079d27795cb6f7388",
121
+ "html_url" =>"https://github.com/yuroyoro/gitterb/issues/4",
122
+ "labels" =>["bar"], "number" =>4, "position" =>1.0, "state" =>"closed",
123
+ "title" => "related branche's commit are too many and rendering are too slow.",
124
+ "updated_at" =>"2011/07/20 01:46:10 -0700", "user" =>"yuroyoro", "votes" =>0},
125
+ {"body" => "cytoscapeweb's swf generate javascripts for calling event listener \r\nwhen click event fired. but generated javascripts doesn't escaped\r\ndouble quote, then it's to be a invalid syntax and syntax error occurred.\r\n",
126
+ "closed_at" =>"2011/07/20 01:47:42 -0700", "comments" =>1,
127
+ "created_at" =>"2011/07/19 23:02:33 -0700", "gravatar_id"=>"bd3590aaffe8948079d27795cb6f7388",
128
+ "html_url" =>"https://github.com/yuroyoro/gitterb/issues/3",
129
+ "labels" =>[], "number" =>3, "position" =>1.0, "state" =>"closed",
130
+ "title" => "script error occurred when commit message includes double quote.",
131
+ "updated_at" =>"2011/07/20 01:47:42 -0700", "user" =>"yuroyoro", "votes" =>0},
132
+ {"body" =>"upgrade to rails3.1.0.rc4. use coffeescript and scss.",
133
+ "closed_at" =>"2011/07/20 01:47:53 -0700", "comments" =>1,
134
+ "created_at" =>"2011/07/14 04:16:23 -0700", "gravatar_id"=>"bd3590aaffe8948079d27795cb6f7388",
135
+ "html_url" =>"https://github.com/yuroyoro/gitterb/issues/2",
136
+ "labels" =>[], "number" =>2, "position" =>1.0, "state" =>"closed",
137
+ "title" =>"upgrade to rails3.1.0", "updated_at" =>"2011/07/20 01:47:53 -0700",
138
+ "user" =>"yuroyoro", "votes" =>0},
139
+ {"body" =>"change diff views like github.",
140
+ "closed_at" =>"2011/07/20 01:48:05 -0700", "comments" =>1,
141
+ "created_at" =>"2011/07/14 04:14:12 -0700",
142
+ "gravatar_id"=>"bd3590aaffe8948079d27795cb6f7388",
143
+ "html_url" =>"https://github.com/yuroyoro/gitterb/issues/1",
144
+ "labels" =>[], "number" =>1, "position" =>1.0, "state" =>"closed",
145
+ "title" =>"improve diff views",
146
+ "updated_at" =>"2011/09/12 04:30:41 -0700", "user" =>"yuroyoro", "votes" =>0}]}
147
+ }
148
+
149
+ context 'given no status' do
150
+
151
+ before {
152
+ github.should_receive(:fetch_json).with( URI.join(GitIssue::Github::ROOT, 'issues/list/yuroyoro/gitterb/open')).and_return(issues)
153
+
154
+ github.list()
155
+ }
156
+ subject { github.sysout.rewind; github.sysout.read }
157
+
158
+ it { sysout.length.should_not be_zero }
159
+ it { syserr.length.should be_zero }
160
+
161
+ it { should include "#5 closed Rendered duplicate commit node. yuroyoro foo,bar comments:1 votes:0 position:1.0 2011/07/20"}
162
+ it { should include "#4 closed related branche's commit are too many and rendering are too slow. yuroyoro bar comments:1 votes:0 position:1.0 2011/07/19"}
163
+ it { should include "#3 closed script error occurred when commit message includes double quote. yuroyoro comments:1 votes:0 position:1.0 2011/07/19"}
164
+ it { should include "#2 closed upgrade to rails3.1.0 yuroyoro comments:1 votes:0 position:1.0 2011/07/14"}
165
+ it { should include "#1 closed improve diff views yuroyoro comments:1 votes:0 position:1.0 2011/07/14"}
166
+
167
+
168
+ end
169
+
170
+ context 'given status' do
171
+
172
+ before {
173
+ github.should_receive(:fetch_json).with( URI.join(GitIssue::Github::ROOT, 'issues/list/yuroyoro/gitterb/closed')).and_return(issues)
174
+
175
+ github.list(:status => 'closed')
176
+ }
177
+ subject { github.sysout.rewind; github.sysout.read }
178
+
179
+ it { sysout.length.should_not be_zero }
180
+ it { syserr.length.should be_zero }
181
+ end
182
+ end
183
+
184
+
185
+
186
+ end
@@ -0,0 +1,70 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe GitIssue::Redmine do
4
+
5
+ let(:apikey) { "ABCDEFG1234567890" }
6
+ let(:url) { "http://example.com/redmine" }
7
+
8
+ describe '#initialize' do
9
+ context 'ginve no apikey ' do
10
+ let(:args) { ["show", "1234"] }
11
+ it { lambda{ GitIssue::Redmine.new(args) }.should raise_error }
12
+ end
13
+
14
+ context 'given no url' do
15
+ let(:args) { ["show", "1234"] }
16
+ it { lambda{ GitIssue::Redmine.new(args, :apikey => apikey) }.should raise_error }
17
+ end
18
+
19
+ context 'given apikey and url' do
20
+ let(:args) { ["show", "1234"] }
21
+ it { lambda{ GitIssue::Redmine.new(args, :apikey => apikey, :url => url) }.should_not raise_error }
22
+ end
23
+ end
24
+
25
+ describe '#show' do
26
+ let(:args) { ["show", "1234"] }
27
+ let(:sysout) { StringIO.new }
28
+ let(:syserr) { StringIO.new }
29
+ let(:redmine) { GitIssue::Redmine.new(args, :apikey => apikey, :url => url, :sysout => sysout, :syserr => syserr) }
30
+
31
+ context 'given no ticket_id' do
32
+ it { lambda {redmine.show() }.should raise_error }
33
+ end
34
+
35
+ context 'given ticket_id' do
36
+ let(:json) {{
37
+ 'issue' => {
38
+ 'id' => 1234,
39
+ 'status'=>{'name'=>'新規', 'id'=>1},
40
+ 'category'=>{'name'=>'カテゴリ', 'id'=>3},
41
+ 'assigned_to'=>{'name'=>'Tomohito Ozaki', 'id'=>13},
42
+ 'project' => {'name' => 'Testプロジェクト', 'id' => 9},
43
+ 'priority'=>{'name'=>'通常', 'id'=>4},
44
+ 'author' => {'name' => 'author hoge', 'id' => 3},
45
+ 'committer' => {'name' => 'committer fuga', 'id' => 4},
46
+ 'tracker' => {'name' => 'Bug', 'id' => 5},
47
+ 'subject' => 'new演算子が乳演算子だったらプログラマもっと増えてた',
48
+ 'description'=>'( ゚∀゚)o彡°おっぱい!おっぱい!',
49
+ 'created_on'=>'2008/08/03 04:08:39 +0900',
50
+ 'updated_on'=>'2011/03/02 23:22:49 +0900',
51
+ 'done_ratio'=>0,
52
+ 'custom_fields'=>
53
+ [{'name'=>'Complete', 'id'=>1, 'value'=>'0'},
54
+ {'name'=>'Due assign', 'id'=>2, 'value'=>'yyyy/mm/dd'},
55
+ {'name'=>'Due close', 'id'=>3, 'value'=>'yyyy/mm/dd'},
56
+ {'name'=>'Resolution', 'id'=>4, 'value'=>''}
57
+ ]
58
+ }
59
+ }}
60
+
61
+ it {
62
+ redmine.should_receive(:fetch_json).and_return(json)
63
+ redmine.show(:ticket_id => 1234)
64
+ sysout.length.should_not be_zero
65
+ syserr.length.should be_zero
66
+ }
67
+
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,39 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe GitIssue do
4
+ describe '#main' do
5
+ context 'config issue.type does not configured' do
6
+ it{
7
+ GitIssue::Helper.should_receive(:configured_value).with("type").and_return("")
8
+ GitIssue::Helper.should_receive(:configured_value).with("apikey").and_return("some value")
9
+ GitIssue::Helper.should_receive(:configure_error).with( "type (redmine | github)", "git config issue.type redmine")
10
+ lambda { GitIssue.main([]) }.should raise_error(SystemExit)
11
+ }
12
+ end
13
+
14
+ context 'invalid issue.type' do
15
+ it{
16
+ GitIssue::Helper.should_receive(:configured_value).with("type").and_return("unknown-type")
17
+ GitIssue::Helper.should_receive(:configured_value).with("apikey").and_return("some value")
18
+ lambda { GitIssue.main([]) }.should raise_error(SystemExit)
19
+ }
20
+ end
21
+ end
22
+
23
+ describe '#its_klass_of' do
24
+ context 'unknown type' do
25
+ specify { lambda { GitIssue::Helper.its_klass_of("unknown_type") }.should raise_error }
26
+ end
27
+
28
+ context 'type is redmine' do
29
+ subject { GitIssue::Helper.its_klass_of("redmine") }
30
+ it { should == GitIssue::Redmine }
31
+ end
32
+
33
+ context 'type is github' do
34
+ subject { GitIssue::Helper.its_klass_of("github") }
35
+ it { should == GitIssue::Github}
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,5 @@
1
+ --colour
2
+ --format specdoc
3
+ --loadby mtime
4
+ --backtrace
5
+ --reverse
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'git_issue'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git-issue
3
+ version: !ruby/object:Gem::Version
4
+ hash: 3
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 7
9
+ - 0
10
+ version: 0.7.0
11
+ platform: ruby
12
+ authors:
13
+ - Tomohito Ozaki
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-02-23 00:00:00 +09:00
19
+ default_executable: git-issue
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: activesupport
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id002
49
+ description: git extention command for issue tracker system.
50
+ email: ozaki@yuroyoro.com
51
+ executables:
52
+ - git-issue
53
+ extensions: []
54
+
55
+ extra_rdoc_files:
56
+ - LICENSE
57
+ - README.markdown
58
+ files:
59
+ - .document
60
+ - LICENSE
61
+ - README.markdown
62
+ - Rakefile
63
+ - VERSION
64
+ - bin/git-issue
65
+ - git-issue.gemspec
66
+ - images/git-issue_screenshot-1.png
67
+ - images/git-issue_screenshot-2.png
68
+ - lib/git_issue.rb
69
+ - lib/git_issue/base.rb
70
+ - lib/git_issue/github.rb
71
+ - lib/git_issue/redmine.rb
72
+ - spec/git_issue/base_spec.rb
73
+ - spec/git_issue/github_spec.rb
74
+ - spec/git_issue/redmine_spec.rb
75
+ - spec/git_issue_spec.rb
76
+ - spec/spec.opts
77
+ - spec/spec_helper.rb
78
+ has_rdoc: true
79
+ homepage: http://github.com/yuroyoro/git-issue
80
+ licenses: []
81
+
82
+ post_install_message:
83
+ rdoc_options: []
84
+
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ hash: 3
102
+ segments:
103
+ - 0
104
+ version: "0"
105
+ requirements: []
106
+
107
+ rubyforge_project:
108
+ rubygems_version: 1.5.2
109
+ signing_key:
110
+ specification_version: 3
111
+ summary: git extention command for issue tracker system.
112
+ test_files: []
113
+