github_deprecations 0.0.1 → 0.0.2

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/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.0.2
2
+
3
+ * errors in configuration will warn, but not raise errors
@@ -1,3 +1,3 @@
1
1
  module GithubDeprecations
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -10,9 +10,19 @@ module GithubDeprecations
10
10
  config = Config.new(options)
11
11
  blk.call(config) if blk
12
12
  config
13
+ rescue ArgumentError => e
14
+ $stderr.puts "Missing config parameters for GithubDeprecations"
15
+ Noop.new
13
16
  end
14
17
  module_function :configure
15
18
 
19
+ # All methods are noop and returns itself
20
+ class Noop
21
+ def method_missing(name, *args, &block)
22
+ self
23
+ end
24
+ end
25
+
16
26
  class Config < Hashie::Dash # add Dash#verify! so that it's not checked on initialization
17
27
  property :login, :required => true
18
28
  property :oauth_token, :required => true
@@ -0,0 +1,42 @@
1
+ require 'test_helper'
2
+
3
+ class GithubDeprecations::WorkerTest < Test::Unit::TestCase
4
+ def setup
5
+ @worker = GithubDeprecations::Worker.new({
6
+ :login => 'jch',
7
+ :oauth_token => 'oauth2token',
8
+ :repo => 'org/repo-name',
9
+ :labels => []
10
+ })
11
+ # name, start, ending, transaction_id, payload. see ActiveSupport::Notifications::Event
12
+ @event = [
13
+ 'deprecation.rails',
14
+ '2012-07-27 20:33:56 -0700',
15
+ '2012-07-27 20:34:03 -0700',
16
+ '13',
17
+ {
18
+ :message => "DEPRECATION WARNING: Ooga Booga. (called from irb_binding at (irb):1)",
19
+ :callstack => ['stack1', 'stack2']
20
+ }
21
+ ]
22
+ end
23
+
24
+ def test_create_issue
25
+ # name, start, ending, transaction_id, payload
26
+ @worker.stubs(:find_issue).returns(nil)
27
+ @worker.expects(:create_issue)
28
+ @worker.submit_issue!(@event)
29
+ end
30
+
31
+ def test_update_existing_issue
32
+ issue = stub(:number => '5')
33
+ @worker.stubs(:find_issue).returns(issue)
34
+ @worker.expects(:update_issue).with('5', any_parameters, any_parameters)
35
+ @worker.submit_issue!(@event)
36
+ end
37
+
38
+ def test_title_normalization
39
+ normalized = @worker.normalize_title("DEPRECATION WARNING: Ooga Booga. (called from irb_binding at (irb):1)")
40
+ assert_equal "Ooga Booga.", normalized
41
+ end
42
+ end
@@ -1,42 +1,25 @@
1
1
  require 'test_helper'
2
+ require 'stringio'
2
3
 
3
- class GithubDeprecations::WorkerTest < Test::Unit::TestCase
4
- def setup
5
- @worker = GithubDeprecations::Worker.new({
6
- :login => 'jch',
7
- :oauth_token => 'oauth2token',
8
- :repo => 'org/repo-name',
9
- :labels => []
10
- })
11
- # name, start, ending, transaction_id, payload. see ActiveSupport::Notifications::Event
12
- @event = [
13
- 'deprecation.rails',
14
- '2012-07-27 20:33:56 -0700',
15
- '2012-07-27 20:34:03 -0700',
16
- '13',
17
- {
18
- :message => "DEPRECATION WARNING: Ooga Booga. (called from irb_binding at (irb):1)",
19
- :callstack => ['stack1', 'stack2']
20
- }
21
- ]
4
+ class GithubDeprecationsTest < Test::Unit::TestCase
5
+ def capture_stderr(&blk)
6
+ io = StringIO.new
7
+ old_io, $stderr = $stderr, io
8
+ blk.call
9
+ $stderr.string
10
+ ensure
11
+ $stderr = old_io
22
12
  end
23
13
 
24
- def test_create_issue
25
- # name, start, ending, transaction_id, payload
26
- @worker.stubs(:find_issue).returns(nil)
27
- @worker.expects(:create_issue)
28
- @worker.submit_issue!(@event)
14
+ def test_configure_fails_silently
15
+ output = capture_stderr do
16
+ GithubDeprecations.configure
17
+ end
18
+ assert_equal output, "Missing config parameters for GithubDeprecations\n"
29
19
  end
30
20
 
31
- def test_update_existing_issue
32
- issue = stub(:number => '5')
33
- @worker.stubs(:find_issue).returns(issue)
34
- @worker.expects(:update_issue).with('5', any_parameters, any_parameters)
35
- @worker.submit_issue!(@event)
36
- end
37
-
38
- def test_title_normalization
39
- normalized = @worker.normalize_title("DEPRECATION WARNING: Ooga Booga. (called from irb_binding at (irb):1)")
40
- assert_equal "Ooga Booga.", normalized
21
+ def test_configure_fails_noop
22
+ # shouldn't raise no method error
23
+ GithubDeprecations.configure.register!
41
24
  end
42
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_deprecations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -115,6 +115,7 @@ extensions: []
115
115
  extra_rdoc_files: []
116
116
  files:
117
117
  - .gitignore
118
+ - CHANGELOG.md
118
119
  - Gemfile
119
120
  - LICENSE.txt
120
121
  - README.md
@@ -122,6 +123,7 @@ files:
122
123
  - github_deprecations.gemspec
123
124
  - lib/github_deprecations.rb
124
125
  - lib/github_deprecations/version.rb
126
+ - test/github_deprecations/worker_test.rb
125
127
  - test/github_deprecations_test.rb
126
128
  - test/integration_test.rb
127
129
  - test/test_helper.rb
@@ -150,6 +152,7 @@ signing_key:
150
152
  specification_version: 3
151
153
  summary: Create GitHub issues based on ActiveSupport deprecation errors
152
154
  test_files:
155
+ - test/github_deprecations/worker_test.rb
153
156
  - test/github_deprecations_test.rb
154
157
  - test/integration_test.rb
155
158
  - test/test_helper.rb