honeybadger-api 1.0.0
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/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +189 -0
- data/Rakefile +1 -0
- data/honeybadger-api.gemspec +26 -0
- data/lib/honeybadger-api.rb +41 -0
- data/lib/honeybadger-api/client.rb +48 -0
- data/lib/honeybadger-api/comment.rb +47 -0
- data/lib/honeybadger-api/configuration.rb +12 -0
- data/lib/honeybadger-api/deploy.rb +46 -0
- data/lib/honeybadger-api/environment.rb +27 -0
- data/lib/honeybadger-api/fault.rb +63 -0
- data/lib/honeybadger-api/notice.rb +45 -0
- data/lib/honeybadger-api/paginator.rb +72 -0
- data/lib/honeybadger-api/project.rb +71 -0
- data/lib/honeybadger-api/request.rb +44 -0
- data/lib/honeybadger-api/team.rb +42 -0
- data/lib/honeybadger-api/team_invitation.rb +61 -0
- data/lib/honeybadger-api/team_member.rb +58 -0
- data/lib/honeybadger-api/user.rb +19 -0
- data/lib/honeybadger-api/version.rb +5 -0
- data/spec/comment_spec.rb +89 -0
- data/spec/deploy_spec.rb +82 -0
- data/spec/environment_spec.rb +31 -0
- data/spec/factories/comment_factory.rb +16 -0
- data/spec/factories/deploy_factory.rb +15 -0
- data/spec/factories/environment_factory.rb +14 -0
- data/spec/factories/fault_factory.rb +29 -0
- data/spec/factories/notice_factory.rb +14 -0
- data/spec/factories/project_factory.rb +44 -0
- data/spec/factories/team_factory.rb +16 -0
- data/spec/factories/team_invitation_factory.rb +27 -0
- data/spec/factories/team_member_factory.rb +17 -0
- data/spec/factories/user_factory.rb +10 -0
- data/spec/fault_spec.rb +132 -0
- data/spec/notice_spec.rb +81 -0
- data/spec/paginator_spec.rb +106 -0
- data/spec/project_spec.rb +151 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/team_invitation_spec.rb +98 -0
- data/spec/team_member_spec.rb +112 -0
- data/spec/team_spec.rb +68 -0
- data/spec/user_spec.rb +17 -0
- data/spec/version_spec.rb +7 -0
- metadata +195 -0
data/spec/fault_spec.rb
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Honeybadger::Api::Fault do
|
4
|
+
|
5
|
+
describe "initializing a new comment" do
|
6
|
+
before :all do
|
7
|
+
@fault = FactoryGirl.build :fault
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should have a identifier" do
|
11
|
+
@fault.id.should == 1
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have a project identifier" do
|
15
|
+
@fault.project_id.should == 2
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have an exception klass" do
|
19
|
+
@fault.klass.should == "RuntimeError"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have an action where the fault occurs" do
|
23
|
+
@fault.action.should == "runtime_error"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should have a component where the fault occurs" do
|
27
|
+
@fault.component.should == "pages"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should have a message" do
|
31
|
+
@fault.message.should == "This is a runtime error"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should have an environment" do
|
35
|
+
@fault.environment.should == "production"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should have a notice count" do
|
39
|
+
@fault.notices_count.should == 7
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should have a comment count" do
|
43
|
+
@fault.comments_count.should == 0
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should have a last notice at" do
|
47
|
+
@fault.last_notice_at.should == DateTime.parse("2012-01-01T00:02:00Z")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should have a created_at" do
|
51
|
+
@fault.created_at.should == DateTime.parse("2012-01-01T00:01:00Z")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "an ignored fault" do
|
56
|
+
before :each do
|
57
|
+
@fault = FactoryGirl.build :ignored_fault
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should identify the fault as ignored" do
|
61
|
+
@fault.ignored?.should be_true
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "a resolved fault" do
|
66
|
+
before :each do
|
67
|
+
@fault = FactoryGirl.build :resolved_fault
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should identify the fault as resolved" do
|
71
|
+
@fault.resolved?.should be_true
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "an unresolved and unignored fault" do
|
76
|
+
before :each do
|
77
|
+
@fault = FactoryGirl.build :fault
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should identify the fault as unresolved" do
|
81
|
+
@fault.resolved?.should be_false
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should identify the fault as not ignored" do
|
85
|
+
@fault.ignored?.should be_false
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "all" do
|
90
|
+
before :each do
|
91
|
+
@project_id = 1
|
92
|
+
@path = "projects/#{@project_id}/faults"
|
93
|
+
@handler = Proc.new { |response| Fault.new(response) }
|
94
|
+
Honeybadger::Api::Fault.expects(:handler).returns(@handler)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should find all of the faults" do
|
98
|
+
Honeybadger::Api::Request.expects(:all).with(@path, @handler).once
|
99
|
+
Honeybadger::Api::Fault.all(@project_id)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "paginate" do
|
104
|
+
before :each do
|
105
|
+
@project_id = 1
|
106
|
+
@path = "projects/#{@project_id}/faults"
|
107
|
+
@handler = Proc.new { |response| Fault.new(response) }
|
108
|
+
@filters = { some_filter: 'value' }
|
109
|
+
Honeybadger::Api::Fault.expects(:handler).returns(@handler)
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should paginate all of the faults" do
|
113
|
+
Honeybadger::Api::Request.expects(:paginate).with(@path, @handler, @filters).once
|
114
|
+
Honeybadger::Api::Fault.paginate(@project_id, @filters)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "find" do
|
119
|
+
before :each do
|
120
|
+
@project_id = 1
|
121
|
+
@fault_id = 2
|
122
|
+
@path = "projects/#{@project_id}/faults/#{@fault_id}"
|
123
|
+
@handler = Proc.new { |response| Fault.new(response) }
|
124
|
+
Honeybadger::Api::Fault.expects(:handler).returns(@handler)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should find a fault" do
|
128
|
+
Honeybadger::Api::Request.expects(:find).with(@path, @handler).once
|
129
|
+
Honeybadger::Api::Fault.find(@project_id, @fault_id)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
data/spec/notice_spec.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Honeybadger::Api::Notice do
|
4
|
+
|
5
|
+
describe "initializing a new comment" do
|
6
|
+
before :all do
|
7
|
+
@notice = FactoryGirl.build :notice
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should have a identifier" do
|
11
|
+
@notice.id.should == 1
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have a fault identifier" do
|
15
|
+
@notice.fault_id.should == 2
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have a message" do
|
19
|
+
@notice.message.should == "This is a runtime error"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have an environment" do
|
23
|
+
@notice.environment.should == "production"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should have a request" do
|
27
|
+
@notice.request.empty?.should == false
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should have a created_at" do
|
31
|
+
@notice.created_at.should == DateTime.parse("2012-01-01T00:01:00Z")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "all" do
|
36
|
+
before :each do
|
37
|
+
@project_id = 1
|
38
|
+
@fault_id = 2
|
39
|
+
@path = "projects/#{@project_id}/faults/#{@fault_id}/notices"
|
40
|
+
@handler = Proc.new { |response| Notice.new(response) }
|
41
|
+
Honeybadger::Api::Notice.expects(:handler).returns(@handler)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should find all of the notices" do
|
45
|
+
Honeybadger::Api::Request.expects(:all).with(@path, @handler).once
|
46
|
+
Honeybadger::Api::Notice.all(@project_id, @fault_id)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "paginate" do
|
51
|
+
before :each do
|
52
|
+
@project_id = 1
|
53
|
+
@fault_id = 2
|
54
|
+
@path = "projects/#{@project_id}/faults/#{@fault_id}/notices"
|
55
|
+
@handler = Proc.new { |response| Notice.new(response) }
|
56
|
+
@filters = { some_filter: 'value' }
|
57
|
+
Honeybadger::Api::Notice.expects(:handler).returns(@handler)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should paginate all of the notices" do
|
61
|
+
Honeybadger::Api::Request.expects(:paginate).with(@path, @handler, @filters).once
|
62
|
+
Honeybadger::Api::Notice.paginate(@project_id, @fault_id, @filters)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "find" do
|
67
|
+
before :each do
|
68
|
+
@project_id = 1
|
69
|
+
@fault_id = 2
|
70
|
+
@notice_id = 3
|
71
|
+
@path = "projects/#{@project_id}/faults/#{@fault_id}/notices/#{@notice_id}"
|
72
|
+
@handler = Proc.new { |response| Notice.new(response) }
|
73
|
+
Honeybadger::Api::Notice.expects(:handler).returns(@handler)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should find a notice" do
|
77
|
+
Honeybadger::Api::Request.expects(:find).with(@path, @handler).once
|
78
|
+
Honeybadger::Api::Notice.find(@project_id, @fault_id, @notice_id)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Honeybadger::Api::Paginator do
|
4
|
+
|
5
|
+
describe "initializing a new paginator" do
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "next? and previous?" do
|
10
|
+
before :all do
|
11
|
+
@client_stub = stub('client')
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "when there is one page" do
|
15
|
+
before :all do
|
16
|
+
opts = {
|
17
|
+
:current_page => 1,
|
18
|
+
:num_pages => 1,
|
19
|
+
:results => []
|
20
|
+
}
|
21
|
+
@client_stub.expects(:get).returns(opts)
|
22
|
+
Honeybadger::Api.stubs(:client).returns(@client_stub)
|
23
|
+
handler = Proc.new { |response| Project.new(response) }
|
24
|
+
|
25
|
+
@paginator = Honeybadger::Api::Paginator.new("projects", {}, handler)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should not have a next page" do
|
29
|
+
@paginator.next?.should be_false
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should not have a previous page" do
|
33
|
+
@paginator.previous?.should be_false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "when there are two pages and on first page" do
|
38
|
+
before :all do
|
39
|
+
opts = {
|
40
|
+
:current_page => 1,
|
41
|
+
:num_pages => 2,
|
42
|
+
:results => []
|
43
|
+
}
|
44
|
+
@client_stub.expects(:get).returns(opts)
|
45
|
+
Honeybadger::Api.stubs(:client).returns(@client_stub)
|
46
|
+
handler = Proc.new { |response| Project.new(response) }
|
47
|
+
|
48
|
+
@paginator = Honeybadger::Api::Paginator.new("projects", {}, handler)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should have a next page" do
|
52
|
+
@paginator.next?.should be_true
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should not have a previous page" do
|
56
|
+
@paginator.previous?.should be_false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "when there are two pages and on last page" do
|
61
|
+
before :all do
|
62
|
+
opts = {
|
63
|
+
:current_page => 2,
|
64
|
+
:num_pages => 2,
|
65
|
+
:results => []
|
66
|
+
}
|
67
|
+
@client_stub.expects(:get).returns(opts)
|
68
|
+
Honeybadger::Api.stubs(:client).returns(@client_stub)
|
69
|
+
handler = Proc.new { |response| Project.new(response) }
|
70
|
+
|
71
|
+
@paginator = Honeybadger::Api::Paginator.new("projects", {}, handler)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should not have a next page" do
|
75
|
+
@paginator.next?.should be_false
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should have a previous page" do
|
79
|
+
@paginator.previous?.should be_true
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "when there are three pages and on middle page" do
|
84
|
+
before :all do
|
85
|
+
opts = {
|
86
|
+
:current_page => 2,
|
87
|
+
:num_pages => 3,
|
88
|
+
:results => []
|
89
|
+
}
|
90
|
+
@client_stub.expects(:get).returns(opts)
|
91
|
+
Honeybadger::Api.stubs(:client).returns(@client_stub)
|
92
|
+
handler = Proc.new { |response| Project.new(response) }
|
93
|
+
|
94
|
+
@paginator = Honeybadger::Api::Paginator.new("projects", {}, handler)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should have a next page" do
|
98
|
+
@paginator.next?.should be_true
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should have a previous page" do
|
102
|
+
@paginator.previous?.should be_true
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Honeybadger::Api::Project do
|
4
|
+
|
5
|
+
describe "initializing a new project" do
|
6
|
+
before :all do
|
7
|
+
@project = FactoryGirl.build :project
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should have an identifier" do
|
11
|
+
@project.id.should == 1
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have a name" do
|
15
|
+
@project.name.should == "Rails"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have an owner" do
|
19
|
+
@project.owner.name.should == "Tom Smith"
|
20
|
+
@project.owner.email.should == "tom.smith@example.com"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have users" do
|
24
|
+
@project.users.length.should == 1
|
25
|
+
@project.users.first.name.should == "user"
|
26
|
+
@project.users.first.email.should == "user@example.com"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have a token" do
|
30
|
+
@project.token.should == "098sflj2"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have a list of environments" do
|
34
|
+
@project.environments.length.should == 1
|
35
|
+
@project.environments.first.should be_kind_of(Honeybadger::Api::Environment)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should have a fault count" do
|
39
|
+
@project.fault_count.should == 14
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should have an unresolved fault count" do
|
43
|
+
@project.unresolved_fault_count.should == 1
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should have a last notice at" do
|
47
|
+
@project.last_notice_at.should == DateTime.parse("2012-01-01T00:02:00Z")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should have a created_at" do
|
51
|
+
@project.created_at.should == DateTime.parse("2012-01-01T00:01:00Z")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "an active project" do
|
56
|
+
before :each do
|
57
|
+
@project = FactoryGirl.build :active_project
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should identify the project as active" do
|
61
|
+
@project.active?.should be_true
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should not identify the project as inactive" do
|
65
|
+
@project.inactive?.should be_false
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "an inactive project" do
|
70
|
+
before :each do
|
71
|
+
@project = FactoryGirl.build :inactive_project
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should identify the project as inactive" do
|
75
|
+
@project.inactive?.should be_true
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should not identify the project as active" do
|
79
|
+
@project.active?.should be_false
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "a public linked project" do
|
84
|
+
before :each do
|
85
|
+
@project = FactoryGirl.build :public_project
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should identify as publicly linked" do
|
89
|
+
@project.public_links?.should be_true
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should not identify as privately linked" do
|
93
|
+
@project.private_links?.should be_false
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "a private linked project" do
|
98
|
+
before :each do
|
99
|
+
@project = FactoryGirl.build :private_project
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should identify as privately linked" do
|
103
|
+
@project.private_links?.should be_true
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should not identify as publicly linked" do
|
107
|
+
@project.public_links?.should be_false
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "all" do
|
112
|
+
before :each do
|
113
|
+
@path = "projects"
|
114
|
+
@handler = Proc.new { |response| Project.new(response) }
|
115
|
+
Honeybadger::Api::Project.expects(:handler).returns(@handler)
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should find all of the projects" do
|
119
|
+
Honeybadger::Api::Request.expects(:all).with(@path, @handler).once
|
120
|
+
Honeybadger::Api::Project.all
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe "paginate" do
|
125
|
+
before :each do
|
126
|
+
@path = "projects"
|
127
|
+
@handler = Proc.new { |response| Project.new(response) }
|
128
|
+
@filters = { some_filter: 'value' }
|
129
|
+
Honeybadger::Api::Project.expects(:handler).returns(@handler)
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should paginate all of the projects" do
|
133
|
+
Honeybadger::Api::Request.expects(:paginate).with(@path, @handler, @filters).once
|
134
|
+
Honeybadger::Api::Project.paginate(@filters)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe "find" do
|
139
|
+
before :each do
|
140
|
+
@project_id = 1
|
141
|
+
@path = "projects/#{@project_id}"
|
142
|
+
@handler = Proc.new { |response| Project.new(response) }
|
143
|
+
Honeybadger::Api::Project.expects(:handler).returns(@handler)
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should find a project" do
|
147
|
+
Honeybadger::Api::Request.expects(:find).with(@path, @handler).once
|
148
|
+
Honeybadger::Api::Project.find(@project_id)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|