errbit_plugin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9e2cd7db132aa98db005fcd6110d4c7229522a9e
4
+ data.tar.gz: 3764d2ebacc1341c2f0ad09631fbd16d74ca2a51
5
+ SHA512:
6
+ metadata.gz: 57ae4835d1c758f6a7f124963ead230512e2fe78909bdf89843d49ff60bf8d429f726d373982b26a42ac8fbee79c486ff8e33b5ee81450103b5a8964351ae416
7
+ data.tar.gz: da3dd64c99018bc73d7fedbc312be9b10cb1d8ecd89de7116b8f28baec724a709431e1bd57223792d70b518a8ce6d850a4665aca653c61959801b5747c410831
data/.coveralls.yml ADDED
@@ -0,0 +1,2 @@
1
+ service_name: travis-pro
2
+ repo_token: gNB8KeAdYQKNW2YC4uut6Zh2ToBnPyMqB
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
19
+ # YARD artifacts
20
+ .yardoc
21
+ _yardoc
22
+ doc/
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ env:
3
+ - COVERAGE=true
4
+ script: bundle exec rspec spec
5
+ rvm:
6
+ - 2.0.0
7
+ - 1.9.3
8
+ - rbx-19mode
9
+ - ruby-head
10
+ matrix:
11
+ allow_failures:
12
+ - rvm: rbx-19mode
13
+ - rvm: ruby-head
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in errbit_plugin.gemspec
4
+ gemspec
5
+
6
+ gem 'rspec'
7
+ gem 'guard'
8
+ gem 'guard-rspec'
9
+ gem 'coveralls', :require => false
data/Guardfile ADDED
@@ -0,0 +1,8 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Errbit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Cyril Mougel
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # ErrbitPlugin
2
+ ErrbitPlugin provides a set of base classes that you can extend to create
3
+ Errbit plugins.
4
+
5
+ ## Creating plugins
6
+ ErrbitPlugins are Ruby gems that extend the functionality of Errbit. To get
7
+ started, create a Ruby gem and add 'errbit_plugin' as a dependency in your
8
+ gem's gemspec.
9
+
10
+ Now you can start adding plugins. At the moment, there is only one kind of
11
+ plugin you can create, and that is the issue tracker.
12
+
13
+ ### Issue Trackers
14
+ An issue tracker plugin is a Ruby class that enables you to link errors within
15
+ errbit to an issue in an external issue tracker like Github. An app within
16
+ errbit can be associated an issue tracker or not. When there is an association,
17
+ errbit users can choose 'create issue' from an error page which will both
18
+ create an issue on the external issue tracker out of the given error and link
19
+ that issue to the errbit error.
20
+
21
+ Your issue tracker plugin is responsible for providing the interface defined by
22
+ ErrbitPlugin::IssueTracker. All of the required methods must be implemented and
23
+ the class must extend ErrbitPlugin::IssueTracker. Here's an example:
24
+ ```ruby
25
+ class MyIssueTracker < ErrbitPlugin::IssueTracker
26
+
27
+ # A unique label for your tracker plugin used internally by errbit
28
+ def self.label
29
+ 'my-tracker'
30
+ end
31
+
32
+ def self.note
33
+ 'a note about this tracker that users will see'
34
+ end
35
+
36
+ # Form fields that will be presented to the administrator when setting up
37
+ # or editing the errbit app. The values we collect will be availble for use
38
+ # later when we have an instance of this class.
39
+ def self.fields
40
+ {
41
+ :field_one => {:label => 'Field One'},
42
+ :field_two => {:label => 'Field Two'}
43
+ }
44
+ end
45
+
46
+ # If this tracker can be in a configured or non-configured state, you can let
47
+ # errbit know by returning a Boolean here
48
+ def configured?
49
+ # In this case, we'll say this issue tracker is configured when field_one
50
+ # is set
51
+ !!params['field_one']
52
+ end
53
+
54
+ # Called to validate user input. Just return a hash of errors if there are
55
+ # any
56
+ def check_params
57
+ if @params['field_one']
58
+ {}
59
+ else
60
+ { :field_one, 'Field One must be present' }
61
+ end
62
+ end
63
+
64
+ # This is where you actually go create the issue on the external issue
65
+ # tracker. You get access to everything in params, a problem resource and a
66
+ # user resource (reported_by). Once you've created an external issue, save
67
+ # its type and url on the problem resource.
68
+ def create_issue(problem, reported_by = nil)
69
+ # Create an issue! Then update the problem to link it.
70
+ problem.update_attributes(
71
+ :issue_type => 'bug',
72
+ :issue_link => 'http://some-remote-tracker.com/mynewissue'
73
+ )
74
+ end
75
+
76
+ # The URL for your remote issue tracker
77
+ def url
78
+ 'http://some-remote-tracker.com'
79
+ end
80
+
81
+ # If you return false here, errbit will not show the built-in error comment
82
+ # interface
83
+ def comments_allowed?
84
+ false
85
+ end
86
+ end
87
+ ```
88
+
89
+ ## Contributing
90
+
91
+ 1. Fork it
92
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
93
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
94
+ 4. Push to the branch (`git push origin my-new-feature`)
95
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'errbit_plugin/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "errbit_plugin"
8
+ spec.version = ErrbitPlugin::VERSION
9
+ spec.authors = ["Stephen Crosby"]
10
+ spec.email = ["stevecrozz@gmail.com"]
11
+ spec.description = %q{Base to create an errbit plugin}
12
+ spec.summary = %q{Base to create an errbit plugin}
13
+ spec.homepage = "http://github.com/errbit/errbit"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,19 @@
1
+ module ErrbitPlugin
2
+ class IssueTracker
3
+ def initialize(app, params)
4
+ @app = app
5
+ @params = params
6
+ end
7
+ attr_reader :app, :params
8
+
9
+ def add_error(key, msg)
10
+ @errors ||= {}
11
+ @errors[key] ||= []
12
+ @errors[key] << msg
13
+ end
14
+
15
+ def issue_title(problem)
16
+ "[#{ problem.environment }][#{ problem.where }] #{problem.message.to_s.truncate(100)}"
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,27 @@
1
+ module ErrbitPlugin
2
+ class FakeIssueTracker < IssueTracker
3
+ def self.label; 'fake'; end
4
+ def self.note; 'A fake issue tracker to help in testing purpose'; end
5
+ def self.fields
6
+ {
7
+ :foo => {:label => 'foo'},
8
+ :bar => {:label => 'bar'}
9
+ }
10
+ end
11
+ ##
12
+ # The NoneIssueTracker is mark like configured? false because it not valid
13
+ # like a real IssueTracker
14
+ def configured?; check_params; end
15
+ def check_params
16
+ params[:foo] && params[:bar]
17
+ end
18
+ def create_issue; true; end
19
+ def url; ''; end
20
+ def comments_allowed?; false; end
21
+ end
22
+ end
23
+
24
+ ErrbitPlugin::Register.add_issue_tracker(
25
+ 'fake',
26
+ ErrbitPlugin::FakeIssueTracker
27
+ )
@@ -0,0 +1,23 @@
1
+ module ErrbitPlugin
2
+ class NoneIssueTracker < IssueTracker
3
+ def self.label; 'none'; end
4
+ def self.note
5
+ 'When no issue tracker has been configured, you will be able to ' <<
6
+ 'leave comments on errors.'
7
+ end
8
+ def self.fields; {}; end
9
+ ##
10
+ # The NoneIssueTracker is mark like configured? false because it not valid
11
+ # like a real IssueTracker
12
+ def configured?; false; end
13
+ def check_params; true; end
14
+ def create_issue; true; end
15
+ def url; ''; end
16
+ def comments_allowed?; true; end
17
+ end
18
+ end
19
+
20
+ ErrbitPlugin::Register.add_issue_tracker(
21
+ 'IssueTracker::None',
22
+ ErrbitPlugin::NoneIssueTracker
23
+ )
@@ -0,0 +1,8 @@
1
+ if defined?(Rails)
2
+ module ErrbitPlugin
3
+ module Rails
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,29 @@
1
+ module ErrbitPlugin
2
+ class IncompatibilityError < Exception; end
3
+
4
+ module Register
5
+ def self.add_issue_tracker(key, klass)
6
+ @issue_trackers ||= {}
7
+ raise IncompatibilityError.new('issue_tracker already registered') if @issue_trackers.key?(key)
8
+ validate = ValidateIssueTracker.new(klass)
9
+
10
+ if validate.valid?
11
+ @issue_trackers[key] = klass
12
+ else
13
+ raise IncompatibilityError.new(validate.errors.join('; '))
14
+ end
15
+ end
16
+
17
+ def self.issue_trackers
18
+ @issue_trackers
19
+ end
20
+
21
+ def self.issue_tracker(key)
22
+ @issue_trackers[key]
23
+ end
24
+
25
+ def self.clear
26
+ @issue_trackers = {}
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,56 @@
1
+ module ErrbitPlugin
2
+ class ValidateIssueTracker
3
+ def initialize(klass)
4
+ @klass = klass
5
+ @errors = []
6
+ end
7
+ attr_reader :errors
8
+
9
+ def valid?
10
+ good_inherit? &&
11
+ implements_instance_methods? &&
12
+ implements_class_methods?
13
+ end
14
+
15
+ private
16
+
17
+ def good_inherit?
18
+ unless @klass.ancestors.include?(ErrbitPlugin::IssueTracker)
19
+ add_errors(:not_inherited)
20
+ false
21
+ else
22
+ true
23
+ end
24
+ end
25
+
26
+ def implements_instance_methods?
27
+ [:comments_allowed?, :configured?, :check_params, :create_issue, :url].all? do |method|
28
+ if instance.respond_to?(method)
29
+ true
30
+ else
31
+ add_errors(:instance_method_missing, method)
32
+ false
33
+ end
34
+ end
35
+ end
36
+
37
+ def implements_class_methods?
38
+ [:label, :fields, :note].all? do |method|
39
+ if @klass.respond_to?(method)
40
+ true
41
+ else
42
+ add_errors(:class_method_missing, method)
43
+ false
44
+ end
45
+ end
46
+ end
47
+
48
+ def instance
49
+ @instance ||= @klass.new(Object.new, {})
50
+ end
51
+
52
+ def add_errors(key, value=nil)
53
+ @errors << [key, value].compact
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,3 @@
1
+ module ErrbitPlugin
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "errbit_plugin/version"
2
+ require "errbit_plugin/register_plugin"
3
+ require "errbit_plugin/issue_tracker"
4
+ require "errbit_plugin/validate_issue_tracker"
5
+ require "errbit_plugin/issue_trackers/none"
6
+ require "errbit_plugin/rails"
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe ErrbitPlugin::Register do
4
+ before do
5
+ ErrbitPlugin::Register.clear
6
+ end
7
+
8
+ describe ".add_issue_tracker" do
9
+ context "with issue_tracker class valid" do
10
+ before do
11
+ allow(ErrbitPlugin::ValidateIssueTracker)
12
+ .to receive(:new)
13
+ .with(ErrbitPlugin::IssueTracker)
14
+ .and_return(double(:valid? => true, :message => ''))
15
+ end
16
+ it 'add new issue_tracker plugin' do
17
+ ErrbitPlugin::Register.add_issue_tracker('foo', ErrbitPlugin::IssueTracker)
18
+ expect(ErrbitPlugin::Register.issue_trackers).to eq({
19
+ 'foo' => ErrbitPlugin::IssueTracker
20
+ })
21
+ end
22
+ context "with already issue_tracker with this key" do
23
+ it 'raise ErrbitPlugin::IncompatibilityError' do
24
+ ErrbitPlugin::Register.add_issue_tracker('foo', ErrbitPlugin::IssueTracker)
25
+ expect {
26
+ ErrbitPlugin::Register.add_issue_tracker('foo', ErrbitPlugin::IssueTracker)
27
+ }.to raise_error(ErrbitPlugin::IncompatibilityError)
28
+ end
29
+ end
30
+ end
31
+
32
+ context "with an IssueTracker not valid" do
33
+ it 'raise an IncompatibilityError' do
34
+ allow(ErrbitPlugin::ValidateIssueTracker)
35
+ .to receive(:new)
36
+ .with(ErrbitPlugin::IssueTracker)
37
+ .and_return(double(:valid? => false, :message => 'foo', :errors => []))
38
+ expect {
39
+ ErrbitPlugin::Register.add_issue_tracker('foo', ErrbitPlugin::IssueTracker)
40
+ }.to raise_error(ErrbitPlugin::IncompatibilityError)
41
+ end
42
+
43
+ it 'puts the errors in the exception message' do
44
+ allow(ErrbitPlugin::ValidateIssueTracker)
45
+ .to receive(:new)
46
+ .with(ErrbitPlugin::IssueTracker)
47
+ .and_return(double(:valid? => false, :message => 'foo', :errors => ['one', 'two']))
48
+
49
+ begin
50
+ ErrbitPlugin::Register.add_issue_tracker('foo', ErrbitPlugin::IssueTracker)
51
+ rescue ErrbitPlugin::IncompatibilityError => e
52
+ expect(e.message).to eq('one; two')
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,222 @@
1
+ require 'spec_helper'
2
+
3
+ describe ErrbitPlugin::ValidateIssueTracker do
4
+ describe "#valid?" do
5
+
6
+ context "with a complete class" do
7
+ class Foo < ErrbitPlugin::IssueTracker
8
+ def self.label; 'foo'; end
9
+ def self.note; 'foo'; end
10
+ def self.fields; ['foo']; end
11
+ def configured?; true; end
12
+ def check_params; true; end
13
+ def create_issue; 'http'; end
14
+ def url; 'http'; end
15
+ def comments_allowed?; false; end
16
+ end
17
+
18
+ it 'valid' do
19
+ expect(ErrbitPlugin::ValidateIssueTracker.new(Foo).valid?).to be true
20
+ end
21
+ end
22
+
23
+ context "with class not inherit from ErrbitPlugin::IssueTracker" do
24
+
25
+ class Bar
26
+ def self.label; 'foo'; end
27
+ def self.note; 'foo'; end
28
+ def self.fields; ['foo']; end
29
+ def configured?; true; end
30
+ def check_params; true; end
31
+ def create_issue; 'http'; end
32
+ def url; 'http'; end
33
+ def comments_allowed?; false; end
34
+ end
35
+
36
+ it 'not valid' do
37
+ expect(ErrbitPlugin::ValidateIssueTracker.new(Bar).valid?).to be false
38
+ end
39
+
40
+ it 'say not implement configured?' do
41
+ is = ErrbitPlugin::ValidateIssueTracker.new(Bar)
42
+ is.valid?
43
+ expect(is.errors).to eql [[:not_inherited]]
44
+ end
45
+ end
46
+
47
+ context "with no label method" do
48
+ class Baz < ErrbitPlugin::IssueTracker
49
+ def note; 'foo'; end
50
+ def fields; ['foo']; end
51
+ def configured?; true; end
52
+ def check_params; true; end
53
+ def create_issue; 'http'; end
54
+ def url; 'http'; end
55
+ def comments_allowed?; false; end
56
+ end
57
+
58
+ it 'not valid' do
59
+ expect(ErrbitPlugin::ValidateIssueTracker.new(Baz).valid?).to be false
60
+ end
61
+
62
+ it 'say not implement configured?' do
63
+ is = ErrbitPlugin::ValidateIssueTracker.new(Baz)
64
+ is.valid?
65
+ expect(is.errors).to eql [[:class_method_missing, :label]]
66
+ end
67
+ end
68
+
69
+ context "without fields method" do
70
+ class BazFields < ErrbitPlugin::IssueTracker
71
+ def self.label; 'foo'; end
72
+ def note; 'foo'; end
73
+ def configured?; true; end
74
+ def check_params; true; end
75
+ def create_issue; 'http'; end
76
+ def url; 'http'; end
77
+ def comments_allowed?; false; end
78
+ end
79
+
80
+ it 'not valid' do
81
+ expect(ErrbitPlugin::ValidateIssueTracker.new(BazFields).valid?).to be false
82
+ end
83
+
84
+ it 'say not implement configured?' do
85
+ is = ErrbitPlugin::ValidateIssueTracker.new(BazFields)
86
+ is.valid?
87
+ expect(is.errors).to eql [[:class_method_missing, :fields]]
88
+ end
89
+ end
90
+
91
+ context "without configured? method" do
92
+ class BazConfigured < ErrbitPlugin::IssueTracker
93
+ def label; 'foo'; end
94
+ def note; 'foo'; end
95
+ def fields; ['foo']; end
96
+ def check_params; true; end
97
+ def create_issue; 'http'; end
98
+ def url; 'http'; end
99
+ def comments_allowed?; false; end
100
+ end
101
+
102
+ it 'not valid' do
103
+ expect(ErrbitPlugin::ValidateIssueTracker.new(BazConfigured).valid?).to be false
104
+ end
105
+
106
+ it 'say not implement configured?' do
107
+ is = ErrbitPlugin::ValidateIssueTracker.new(BazConfigured)
108
+ is.valid?
109
+ expect(is.errors).to eql [[:instance_method_missing, :configured?]]
110
+ end
111
+ end
112
+
113
+ context "without check_params method" do
114
+ class BazCheckParams < ErrbitPlugin::IssueTracker
115
+ def label; 'foo'; end
116
+ def note; 'foo'; end
117
+ def fields; ['foo']; end
118
+ def configured?; true; end
119
+ def create_issue; 'http'; end
120
+ def url; 'http'; end
121
+ def comments_allowed?; false; end
122
+ end
123
+
124
+ it 'not valid' do
125
+ expect(ErrbitPlugin::ValidateIssueTracker.new(BazCheckParams).valid?).to be false
126
+ end
127
+
128
+ it 'say not implement check_params' do
129
+ is = ErrbitPlugin::ValidateIssueTracker.new(BazCheckParams)
130
+ is.valid?
131
+ expect(is.errors).to eql [[:instance_method_missing, :check_params]]
132
+ end
133
+ end
134
+
135
+ context "without create_issue method" do
136
+ class BazCreateIssue < ErrbitPlugin::IssueTracker
137
+ def label; 'foo'; end
138
+ def note; 'foo'; end
139
+ def fields; ['foo']; end
140
+ def configured?; true; end
141
+ def check_params; true; end
142
+ def url; 'http'; end
143
+ def comments_allowed?; false; end
144
+ end
145
+
146
+ it 'not valid' do
147
+ expect(ErrbitPlugin::ValidateIssueTracker.new(BazCreateIssue).valid?).to be false
148
+ end
149
+ it 'say not implement url' do
150
+ is = ErrbitPlugin::ValidateIssueTracker.new(BazCreateIssue)
151
+ is.valid?
152
+ expect(is.errors).to eql [[:instance_method_missing, :create_issue]]
153
+ end
154
+ end
155
+
156
+ context "without url method" do
157
+ class BazUrl < ErrbitPlugin::IssueTracker
158
+ def label; 'foo'; end
159
+ def note; 'foo'; end
160
+ def fields; ['foo']; end
161
+ def configured?; true; end
162
+ def check_params; true; end
163
+ def create_issue; 'http'; end
164
+ def comments_allowed?; false; end
165
+ end
166
+
167
+ it 'not valid' do
168
+ expect(ErrbitPlugin::ValidateIssueTracker.new(BazUrl).valid?).to be false
169
+ end
170
+
171
+ it 'say not implement url' do
172
+ is = ErrbitPlugin::ValidateIssueTracker.new(BazUrl)
173
+ is.valid?
174
+ expect(is.errors).to eql [[:instance_method_missing, :url]]
175
+ end
176
+ end
177
+
178
+ context "without comments_allowed? method" do
179
+ class BazComment < ErrbitPlugin::IssueTracker
180
+ def label; 'foo'; end
181
+ def note; 'foo'; end
182
+ def fields; ['foo']; end
183
+ def configured?; true; end
184
+ def check_params; true; end
185
+ def create_issue; 'http'; end
186
+ def url; 'foo'; end
187
+ end
188
+
189
+ it 'not valid' do
190
+ expect(ErrbitPlugin::ValidateIssueTracker.new(BazComment).valid?).to be false
191
+ end
192
+
193
+ it 'say not implement comments_allowed?' do
194
+ is = ErrbitPlugin::ValidateIssueTracker.new(BazComment)
195
+ is.valid?
196
+ expect(is.errors).to eql [[:instance_method_missing, :comments_allowed?]]
197
+ end
198
+ end
199
+
200
+ context "without note method" do
201
+ class BazNote < ErrbitPlugin::IssueTracker
202
+ def self.label; 'foo'; end
203
+ def self.fields; ['foo']; end
204
+ def configured?; true; end
205
+ def check_params; true; end
206
+ def create_issue; 'http'; end
207
+ def url; 'foo'; end
208
+ def comments_allowed?; false; end
209
+ end
210
+
211
+ it 'not valid' do
212
+ expect(ErrbitPlugin::ValidateIssueTracker.new(BazNote).valid?).to be false
213
+ end
214
+
215
+ it 'say not implement comments_allowed?' do
216
+ is = ErrbitPlugin::ValidateIssueTracker.new(BazNote)
217
+ is.valid?
218
+ expect(is.errors).to eql [[:class_method_missing, :note]]
219
+ end
220
+ end
221
+ end
222
+ end
@@ -0,0 +1,26 @@
1
+ if ENV['COVERAGE']
2
+ require 'simplecov'
3
+ if ENV['CI']
4
+ require 'coveralls'
5
+ Coveralls.wear!
6
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
+ SimpleCov::Formatter::HTMLFormatter,
8
+ Coveralls::SimpleCov::Formatter
9
+ ]
10
+ end
11
+
12
+ SimpleCov.start
13
+ end
14
+
15
+ require 'errbit_plugin'
16
+
17
+ RSpec.configure do |config|
18
+ config.run_all_when_everything_filtered = true
19
+ config.filter_run :focus
20
+
21
+ # Run specs in random order to surface order dependencies. If you find an
22
+ # order dependency and want to debug it, you can fix the order by providing
23
+ # the seed, which is printed after each run.
24
+ # --seed 1234
25
+ config.order = 'random'
26
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: errbit_plugin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Stephen Crosby
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Base to create an errbit plugin
42
+ email:
43
+ - stevecrozz@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".coveralls.yml"
49
+ - ".gitignore"
50
+ - ".travis.yml"
51
+ - Gemfile
52
+ - Guardfile
53
+ - LICENSE
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - errbit_plugin.gemspec
58
+ - lib/errbit_plugin.rb
59
+ - lib/errbit_plugin/issue_tracker.rb
60
+ - lib/errbit_plugin/issue_trackers/fake.rb
61
+ - lib/errbit_plugin/issue_trackers/none.rb
62
+ - lib/errbit_plugin/rails.rb
63
+ - lib/errbit_plugin/register_plugin.rb
64
+ - lib/errbit_plugin/validate_issue_tracker.rb
65
+ - lib/errbit_plugin/version.rb
66
+ - spec/errbit_plugin/register_plugin_spec.rb
67
+ - spec/errbit_plugin/validate_issue_tracker_spec.rb
68
+ - spec/spec_helper.rb
69
+ - vendor/assets/images/fake_create.png
70
+ - vendor/assets/images/fake_inactive.png
71
+ - vendor/assets/images/none_create.png
72
+ - vendor/assets/images/none_inactive.png
73
+ homepage: http://github.com/errbit/errbit
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.2.2
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Base to create an errbit plugin
97
+ test_files:
98
+ - spec/errbit_plugin/register_plugin_spec.rb
99
+ - spec/errbit_plugin/validate_issue_tracker_spec.rb
100
+ - spec/spec_helper.rb
101
+ has_rdoc: