omg_pull_request 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/.gitignore +47 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +68 -0
  4. data/LICENSE +22 -0
  5. data/README.md +66 -0
  6. data/Rakefile +12 -0
  7. data/bin/omg_pull_request +13 -0
  8. data/lib/omg_pull_request.rb +32 -0
  9. data/lib/omg_pull_request/aws/store.rb +30 -0
  10. data/lib/omg_pull_request/configuration.rb +55 -0
  11. data/lib/omg_pull_request/context.rb +29 -0
  12. data/lib/omg_pull_request/git_client.rb +31 -0
  13. data/lib/omg_pull_request/github_wrapper.rb +50 -0
  14. data/lib/omg_pull_request/lolcommits.rb +39 -0
  15. data/lib/omg_pull_request/notifications.rb +66 -0
  16. data/lib/omg_pull_request/prowl.rb +77 -0
  17. data/lib/omg_pull_request/test_logger.rb +20 -0
  18. data/lib/omg_pull_request/test_runner.rb +22 -0
  19. data/lib/omg_pull_request/test_runner/base.rb +128 -0
  20. data/lib/omg_pull_request/test_runner/rails.rb +19 -0
  21. data/lib/omg_pull_request/test_runner/ruby.rb +9 -0
  22. data/lib/omg_pull_request/version.rb +3 -0
  23. data/locales/en.yml +23 -0
  24. data/locales/omg.yml +20 -0
  25. data/omg_pull_request.gemspec +26 -0
  26. data/test/fixtures/comments +431 -0
  27. data/test/fixtures/config.yml +20 -0
  28. data/test/fixtures/create_comment +24 -0
  29. data/test/fixtures/github_commits +183 -0
  30. data/test/fixtures/kenmazaika +30 -0
  31. data/test/fixtures/pull_requests +151 -0
  32. data/test/mocks/git_client.rb +6 -0
  33. data/test/mocks/pull_request.rb +38 -0
  34. data/test/omg_pull_request/.gitkeep +0 -0
  35. data/test/test_helper.rb +53 -0
  36. data/test/units/omg_pull_request/aws/store_test.rb +22 -0
  37. data/test/units/omg_pull_request/github_wrapper_test.rb +43 -0
  38. data/test/units/omg_pull_request/lolcommits_test.rb +42 -0
  39. data/test/units/omg_pull_request/notifications_test.rb +125 -0
  40. data/test/units/omg_pull_request/prowl_test.rb +51 -0
  41. data/test/units/omg_pull_request/test_runner/base_test.rb +58 -0
  42. metadata +183 -0
@@ -0,0 +1,22 @@
1
+ require './test/test_helper.rb'
2
+
3
+ module OmgPullRequest
4
+ module Aws
5
+ class StoreTest < MiniTest::Unit::TestCase
6
+ def test_store
7
+ FakeWeb.register_uri(:put, "http://s3.amazonaws.com/rofl/omg", :body => 'mmmkay')
8
+ storage.store("omg", "omg")
9
+ end
10
+
11
+ protected
12
+
13
+ def storage
14
+ @store ||= Store.new(:storage_config => {
15
+ :access_token => 'omg',
16
+ :secret_token => 'lol',
17
+ :bucket => 'rofl'
18
+ })
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,43 @@
1
+ require './test/test_helper.rb'
2
+
3
+ module OmgPullRequest
4
+ class GithubWrapperTest < MiniTest::Unit::TestCase
5
+ def test_author_logins
6
+ fakeweb_kenmazaika
7
+ logins = github_wrapper.author_logins(MockPullRequest.new)
8
+ assert_equal ["kenmazaika", "kenmazaika@gmail.com"], logins
9
+ end
10
+
11
+ def test_all_logins
12
+ fakeweb_comments
13
+ assert_equal ['kenmazaika', 'wherebot'], github_wrapper.all_logins(MockPullRequest.new)
14
+ end
15
+
16
+ def test_commit_shas
17
+ fakeweb_get_pull_request_commits
18
+ expected = ["c129a13a1c6", "dcc1e9847ff", "c204cee08e0", "ad0a65aeeca"]
19
+ assert_equal expected, github_wrapper.commit_shas(MockPullRequest.new)
20
+ end
21
+
22
+ def test_make_comment
23
+ fakeweb_create_comment
24
+ github_wrapper.make_comment(MockPullRequest.new.number, "omg")
25
+ end
26
+
27
+ def test_pull_requests
28
+ fakeweb_pull_requests
29
+ prs = github_wrapper.pull_requests
30
+ assert_equal 1, prs.count
31
+ pr = prs.first
32
+ assert_equal Hashie::Mash, pr.class
33
+ assert_equal "Omg", pr.title
34
+ end
35
+
36
+ protected
37
+
38
+ def github_wrapper
39
+ @github_wrapper ||= GithubWrapper.new(:configuration => CONFIGURATION)
40
+ end
41
+ end
42
+
43
+ end
@@ -0,0 +1,42 @@
1
+ require './test/test_helper.rb'
2
+
3
+ module OmgPullRequest
4
+ class LolcommitsTest < MiniTest::Unit::TestCase
5
+ def setup
6
+ fakeweb_get_pull_request_commits
7
+ end
8
+
9
+ def test_get_animation_url_success
10
+ shas = ['lol', 'rofl']
11
+
12
+ url = fakeweb_create_animation
13
+
14
+ assert_equal url, lolcommits_client.send(:get_animation_url, shas)
15
+ end
16
+
17
+ def test_get_animation_url_no_animations
18
+ assert_nil lolcommits_client.send(:get_animation_url, [])
19
+ assert_nil lolcommits_client.send(:get_animation_url, nil)
20
+ end
21
+
22
+ def test_animation_url
23
+ expected_url = fakeweb_create_animation
24
+ returned_url = lolcommits_client.animation_url
25
+ assert_equal expected_url, returned_url
26
+ end
27
+
28
+
29
+ private
30
+
31
+ def fakeweb_create_animation
32
+ url = "http://lolcommits.com/omg"
33
+ FakeWeb.register_uri(:post, "#{Lolcommits::LOLCOMMITS_URL}#{Lolcommits::LOLCOMMITS_PATH}", :body => {:image => {:url => url} }.to_json)
34
+ url
35
+ end
36
+
37
+ def lolcommits_client
38
+ @lolcommits_client ||= Lolcommits.new(:context => CONTEXT, :github_wrapper => GITHUB_WRAPPER,
39
+ :runner => TestRunner::Base.new(:pull_request => MockPullRequest.new))
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,125 @@
1
+ require './test/test_helper.rb'
2
+
3
+ module OmgPullRequest
4
+ class NotificationsTest < MiniTest::Unit::TestCase
5
+ def test_runner_hash
6
+ expected = {
7
+ :omg => "omg",
8
+ :abbr_from_sha => "abbr_from_sha",
9
+ :abbr_to_sha => "abbr_to_sha",
10
+ :minutes => 1,
11
+ :seconds => 3.45,
12
+ :issue_number => 10,
13
+ :title => "Omg"
14
+ }
15
+
16
+ assert_equal expected, mock_runner.send(:runner_hash, {:omg => 'omg'})
17
+ end
18
+
19
+ def test_github_comment
20
+ fakeweb_create_comment
21
+ mock_runner.send(:github_comment, "omg")
22
+ end
23
+
24
+ def test_prowl_alert_failure
25
+ mock_runner.prowl_client.expects(:alert_author!).with(
26
+ "Sad face to the max, homie.\nPull request #10\nOmg\nTests took 1 minutes, 3.45 seconds.",
27
+ :failure
28
+ )
29
+ mock_runner.send(:prowl_alert_failure!)
30
+ end
31
+
32
+ def test_prowl_alert_success
33
+ mock_runner.prowl_client.expects(:alert_all_relevant_people!).with(
34
+ "Thumbs up, bro.\nPull request #10\nOmg\nTests took 1 minutes, 3.45 seconds.",
35
+ :success
36
+ )
37
+ mock_runner.send(:prowl_alert_success!)
38
+ end
39
+
40
+ def test_make_comment_test_running
41
+ mock_runner.expects(:github_comment).with(
42
+ ":trollface: Running tests: `abbr_from_sha` to `abbr_to_sha\n\nThis is what hard work looks like\n![Pretty Pictures](http://lolcommits.com/omg)"
43
+ )
44
+ mock_runner.send(:make_comment_test_running!)
45
+ end
46
+
47
+ def test_make_comment_conflict
48
+ mock_runner.expects(:github_comment).with(
49
+ "### Unable To Run \nA conflict prevented the test suite from being run. Please manually resolve the conflict and the tests will be rerun.\nFrom `abbr_from_sha` to `abbr_to_sha`"
50
+ )
51
+
52
+ mock_runner.send(:make_comment_conflict!)
53
+ end
54
+
55
+ def test_make_comment_failure
56
+ mock_runner.expects(:github_comment).with(
57
+ ":thumbsdown: :fire: :broken_heart: \n### Tests Failed \n `abbr_from_sha` to `abbr_to_sha`\nTests too 1 minutes, 3.45 seconds.\n[results](url)"
58
+ )
59
+ mock_runner.send(:make_comment_failure!, "url")
60
+ end
61
+
62
+ def test_make_comment_success
63
+ mock_runner.expects(:github_comment).with(
64
+ ":thumbsup: :shipit: \n### Tests Passed \nFrom `abbr_from_sha` to `abbr_to_sha`\nTests took 1 minutes, 3.45 seconds.\n[results](url)"
65
+ )
66
+ mock_runner.send(:make_comment_success!, "url")
67
+ end
68
+
69
+ protected
70
+
71
+ def mock_runner
72
+ @mock_runner ||= MockRunner.new
73
+ end
74
+
75
+ end
76
+
77
+ class MockRunner
78
+ include Notifications
79
+
80
+ def abbr_from_sha
81
+ "abbr_from_sha"
82
+ end
83
+
84
+ def abbr_to_sha
85
+ "abbr_to_sha"
86
+ end
87
+
88
+ def runtime_minutes
89
+ 1
90
+ end
91
+
92
+ def runtime_seconds
93
+ 3.45
94
+ end
95
+
96
+ def issue_number
97
+ pull_request.number
98
+ end
99
+
100
+ def pull_request
101
+ @pr ||= MockPullRequest.new
102
+ end
103
+
104
+ def prowl_client
105
+ @prowl ||= Prowl.new
106
+ end
107
+
108
+ def t(key, options={})
109
+ I18n.t(key, options)
110
+ end
111
+
112
+ def lolcommits_client
113
+ MockLolcommits.new
114
+ end
115
+
116
+ def log(omg)
117
+ end
118
+
119
+ class MockLolcommits
120
+ def animation_url
121
+ "http://lolcommits.com/omg"
122
+ end
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,51 @@
1
+ require './test/test_helper.rb'
2
+
3
+ module OmgPullRequest
4
+ class ProwlTest < MiniTest::Unit::TestCase
5
+ def test_notify_users
6
+ message = "omg"
7
+ keys = ['lol', 'rofl']
8
+
9
+ FakeWeb.register_uri(:post, "#{Prowl::PROWL_URL}#{Prowl::PROWL_PATH}", :body => "OK")
10
+
11
+ prowl_client.notify_users(message, keys)
12
+ end
13
+
14
+ def test_keys_for_users
15
+ assert_equal ['OMG_OMG'],
16
+ prowl_client.send(:keys_for_users, ['kenmazaika','kenmazaika@gmail.com', 'omg'])
17
+ end
18
+
19
+ def test_alert_author
20
+ fakeweb_kenmazaika
21
+
22
+ prowl_client.expects(:notify_users).with(
23
+ 'omg', ['OMG_OMG'],
24
+ {:url => 'http://omg.com/html_url', :event => :success}
25
+ )
26
+
27
+ prowl_client.alert_author!("omg", :success)
28
+ end
29
+
30
+ def test_alert_all_relevant_people
31
+ fakeweb_comments
32
+
33
+ prowl_client.expects(:notify_users).with(
34
+ 'omg', ['OMG_OMG', "REG_DUDE"],
35
+ {:url => 'http://omg.com/html_url', :event => :failure}
36
+ )
37
+
38
+ prowl_client.alert_all_relevant_people!("omg", :failure)
39
+ end
40
+
41
+ private
42
+
43
+ def prowl_client
44
+ runner = TestRunner::Base.new(:pull_request => MockPullRequest.new)
45
+ runner.expects(:git_client).returns(MockGitClient.new).at_least(0)
46
+ @prowl_client ||= OmgPullRequest::Prowl.new(:configuration => CONFIGURATION,
47
+ :runner => runner,
48
+ :github_wrapper => GITHUB_WRAPPER)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,58 @@
1
+ require './test/test_helper.rb'
2
+
3
+ module OmgPullRequest
4
+ module TestRunner
5
+ class BaseTest < MiniTest::Unit::TestCase
6
+ def test_request_sha
7
+ expected = "BASE_SHA:HEAD_SHA"
8
+ assert_equal expected, runner.request_sha
9
+ end
10
+
11
+ def test_initialize
12
+ # regardless of if success is told be true, it's false on initialize
13
+ runner = Base.new(:success => true)
14
+ assert_equal false, runner.success
15
+ assert_equal false, runner.success?
16
+
17
+ runner.success = true
18
+ assert_equal true, runner.success
19
+ assert_equal true, runner.success?
20
+ end
21
+
22
+ def test_runtime
23
+ runner.runtime = 63.12345
24
+ assert_equal 1, runner.runtime_minutes
25
+ assert_equal 3.123, runner.runtime_seconds
26
+ end
27
+
28
+ def test_run_success
29
+ runner.expects(:log_test_details!).once
30
+ runner.expects(:make_comment_test_running!).once
31
+ runner.git_client.expects(:checkout!).once
32
+ runner.git_client.expects(:merge!).once.returns(:success)
33
+ runner.expects(:make_comment_conflict!).never
34
+ runner.expects(:process_output!).once
35
+
36
+ runner.run
37
+ end
38
+
39
+ def test_run_conflict
40
+ runner.expects(:log_test_details!).once
41
+ runner.expects(:make_comment_test_running!).once
42
+ runner.git_client.expects(:checkout!).once
43
+ runner.git_client.expects(:merge!).once.returns(:conflict)
44
+ runner.expects(:make_comment_conflict!).once
45
+ runner.expects(:process_output!).never
46
+
47
+ runner.run
48
+ end
49
+
50
+
51
+ protected
52
+
53
+ def runner
54
+ @runner ||= Base.new(:pull_request => MockPullRequest.new)
55
+ end
56
+ end
57
+ end
58
+ end
metadata ADDED
@@ -0,0 +1,183 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omg_pull_request
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ken Mazaika
9
+ - Jean Charles Sisk
10
+ - Master William Desmarais
11
+ - Ian Asaff
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+ date: 2012-08-27 00:00:00.000000000Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: aws-s3
19
+ requirement: &70268856902280 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
24
+ version: 0.6.3
25
+ type: :runtime
26
+ prerelease: false
27
+ version_requirements: *70268856902280
28
+ - !ruby/object:Gem::Dependency
29
+ name: faraday
30
+ requirement: &70268856901600 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: 0.8.4
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: *70268856901600
39
+ - !ruby/object:Gem::Dependency
40
+ name: github_api
41
+ requirement: &70268856900880 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: 0.6.5
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: *70268856900880
50
+ - !ruby/object:Gem::Dependency
51
+ name: uuid
52
+ requirement: &70268856899660 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: 2.3.5
58
+ type: :runtime
59
+ prerelease: false
60
+ version_requirements: *70268856899660
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: &70268856898380 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.9.2.2
69
+ type: :runtime
70
+ prerelease: false
71
+ version_requirements: *70268856898380
72
+ - !ruby/object:Gem::Dependency
73
+ name: activesupport
74
+ requirement: &70268856897400 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: 3.2.8
80
+ type: :runtime
81
+ prerelease: false
82
+ version_requirements: *70268856897400
83
+ - !ruby/object:Gem::Dependency
84
+ name: i18n
85
+ requirement: &70268856887140 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: 0.6.0
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: *70268856887140
94
+ description: Have tests run automatically for your Github Pull Request
95
+ email:
96
+ - kenmazaika@gmail.com
97
+ executables:
98
+ - omg_pull_request
99
+ extensions: []
100
+ extra_rdoc_files: []
101
+ files:
102
+ - .gitignore
103
+ - Gemfile
104
+ - Gemfile.lock
105
+ - LICENSE
106
+ - README.md
107
+ - Rakefile
108
+ - bin/omg_pull_request
109
+ - lib/omg_pull_request.rb
110
+ - lib/omg_pull_request/aws/store.rb
111
+ - lib/omg_pull_request/configuration.rb
112
+ - lib/omg_pull_request/context.rb
113
+ - lib/omg_pull_request/git_client.rb
114
+ - lib/omg_pull_request/github_wrapper.rb
115
+ - lib/omg_pull_request/lolcommits.rb
116
+ - lib/omg_pull_request/notifications.rb
117
+ - lib/omg_pull_request/prowl.rb
118
+ - lib/omg_pull_request/test_logger.rb
119
+ - lib/omg_pull_request/test_runner.rb
120
+ - lib/omg_pull_request/test_runner/base.rb
121
+ - lib/omg_pull_request/test_runner/rails.rb
122
+ - lib/omg_pull_request/test_runner/ruby.rb
123
+ - lib/omg_pull_request/version.rb
124
+ - locales/en.yml
125
+ - locales/omg.yml
126
+ - omg_pull_request.gemspec
127
+ - test/fixtures/comments
128
+ - test/fixtures/config.yml
129
+ - test/fixtures/create_comment
130
+ - test/fixtures/github_commits
131
+ - test/fixtures/kenmazaika
132
+ - test/fixtures/pull_requests
133
+ - test/mocks/git_client.rb
134
+ - test/mocks/pull_request.rb
135
+ - test/omg_pull_request/.gitkeep
136
+ - test/test_helper.rb
137
+ - test/units/omg_pull_request/aws/store_test.rb
138
+ - test/units/omg_pull_request/github_wrapper_test.rb
139
+ - test/units/omg_pull_request/lolcommits_test.rb
140
+ - test/units/omg_pull_request/notifications_test.rb
141
+ - test/units/omg_pull_request/prowl_test.rb
142
+ - test/units/omg_pull_request/test_runner/base_test.rb
143
+ homepage: http://github.com/where/omg_pull_request
144
+ licenses: []
145
+ post_install_message:
146
+ rdoc_options: []
147
+ require_paths:
148
+ - lib
149
+ required_ruby_version: !ruby/object:Gem::Requirement
150
+ none: false
151
+ requirements:
152
+ - - ! '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ none: false
157
+ requirements:
158
+ - - ! '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ requirements: []
162
+ rubyforge_project:
163
+ rubygems_version: 1.8.10
164
+ signing_key:
165
+ specification_version: 3
166
+ summary: Have tests run automatically for your Github Pull Request
167
+ test_files:
168
+ - test/fixtures/comments
169
+ - test/fixtures/config.yml
170
+ - test/fixtures/create_comment
171
+ - test/fixtures/github_commits
172
+ - test/fixtures/kenmazaika
173
+ - test/fixtures/pull_requests
174
+ - test/mocks/git_client.rb
175
+ - test/mocks/pull_request.rb
176
+ - test/omg_pull_request/.gitkeep
177
+ - test/test_helper.rb
178
+ - test/units/omg_pull_request/aws/store_test.rb
179
+ - test/units/omg_pull_request/github_wrapper_test.rb
180
+ - test/units/omg_pull_request/lolcommits_test.rb
181
+ - test/units/omg_pull_request/notifications_test.rb
182
+ - test/units/omg_pull_request/prowl_test.rb
183
+ - test/units/omg_pull_request/test_runner/base_test.rb