lena 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.
@@ -1,30 +1,50 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'generating errors', js: true do
4
- it 'includes data attributes' do
5
- visit root_path
6
- expect(page.body).to include('data-lena-url')
7
- expect(page.body).to include('data-lena-destination')
8
- end
3
+ describe 'lena test app' do
9
4
 
10
- it 'reports errors for log' do
11
- expect { visit log_path }.to change { Lena.events.length }.by(1)
12
- event = Lena.events[-1]
13
- expect(event[:message]).to eq("Simple error log")
14
- expect(event[:stacktrace]).to eq("unsupported")
5
+ context 'with default capture' do
6
+ it 'throws exceptions' do
7
+ expect { visit lena.report_path }.to raise_error(Lena::ClientError)
8
+ end
15
9
  end
16
10
 
17
- it 'reports errors for exceptions' do
18
- expect { visit throw_path }.to change { Lena.events.length }.by(1)
19
- event = Lena.events[-1]
20
- expect(event[:message]).to eq("Error: Simple error throw\nResource: undefined:0")
21
- expect(event[:stacktrace]).to be_nil
22
- end
11
+ context 'with custom capture', js: true do
12
+ before do
13
+ @report_handler = Lena::Engine.config.report_handler
14
+ @events = []
15
+ handler = Proc.new { |params| @events << params }
16
+ Lena.setup { |config| config.report_handler = handler }
17
+ end
18
+
19
+ after do
20
+ Lena::Engine.config.report_handler = @report_handler
21
+ end
22
+
23
+ it 'includes data attributes' do
24
+ visit root_path
25
+ expect(page.body).to include('data-lena-remote-url')
26
+ expect(page.body).to include('data-lena-destination')
27
+ end
28
+
29
+ it 'reports errors for log' do
30
+ expect { visit log_path }.to change { @events.length }.by(1)
31
+ event = @events[-1]
32
+ expect(event[:message]).to eq("Simple error log")
33
+ expect(event[:stacktrace]).to eq("unsupported")
34
+ end
35
+
36
+ it 'reports errors for exceptions' do
37
+ expect { visit throw_path }.to change { @events.length }.by(1)
38
+ event = @events[-1]
39
+ expect(event[:message]).to eq("Error: Simple error throw\nResource: undefined:0")
40
+ expect(event[:stacktrace]).to be_nil
41
+ end
23
42
 
24
- it 'reports errors when nested, but cannot provide stack trace' do
25
- expect { visit throw_callstack_path }.to change { Lena.events.length }.by(1)
26
- event = Lena.events[-1]
27
- expect(event[:message]).to eq("ReferenceError: Can't find variable: undefinedFunctionCall\nResource: undefined:0")
28
- expect(event[:stacktrace]).to be_nil
43
+ it 'reports errors when nested, but cannot provide stack trace' do
44
+ expect { visit throw_callstack_path }.to change { @events.length }.by(1)
45
+ event = @events[-1]
46
+ expect(event[:message]).to eq("ReferenceError: Can't find variable: undefinedFunctionCall\nResource: undefined:0")
47
+ expect(event[:stacktrace]).to be_nil
48
+ end
29
49
  end
30
50
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lena
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Whitney Young
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-27 00:00:00.000000000 Z
11
+ date: 2013-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -139,7 +139,6 @@ files:
139
139
  - lib/lena.rb
140
140
  - MIT-LICENSE
141
141
  - Rakefile
142
- - README.rdoc
143
142
  - spec/dummy/app/assets/javascripts/application.js
144
143
  - spec/dummy/app/controllers/application_controller.rb
145
144
  - spec/dummy/app/views/application/index.html
@@ -155,7 +154,6 @@ files:
155
154
  - spec/dummy/config/environment.rb
156
155
  - spec/dummy/config/environments/development.rb
157
156
  - spec/dummy/config/environments/test.rb
158
- - spec/dummy/config/initializers/lena.rb
159
157
  - spec/dummy/config/initializers/secret_token.rb
160
158
  - spec/dummy/config/routes.rb
161
159
  - spec/dummy/config.ru
@@ -216,7 +214,6 @@ test_files:
216
214
  - spec/dummy/config/environment.rb
217
215
  - spec/dummy/config/environments/development.rb
218
216
  - spec/dummy/config/environments/test.rb
219
- - spec/dummy/config/initializers/lena.rb
220
217
  - spec/dummy/config/initializers/secret_token.rb
221
218
  - spec/dummy/config/routes.rb
222
219
  - spec/dummy/config.ru
data/README.rdoc DELETED
@@ -1,48 +0,0 @@
1
- = Leña {<img src="https://secure.travis-ci.org/wbyoung/lena.png"/>}[http://travis-ci.org/wbyoung/lena] {<img src="https://codeclimate.com/github/wbyoung/lena.png"/>}[https://codeclimate.com/github/wbyoung/lena] {<img src="https://coveralls.io/repos/wbyoung/lena/badge.png"/>}[https://coveralls.io/r/wbyoung/lena]
2
-
3
- Leña provides simple server-side JavaScript error logging for production Rails applications. This allows you to better track errors that occur in your front-end code.
4
-
5
- == Installation
6
-
7
- Add the following to your +application.js+:
8
-
9
- //= require lena
10
-
11
- Add the following to your +routes.rb+:
12
-
13
- mount Lena::Engine => "/lena"
14
-
15
- Update your +application.html.erb+:
16
-
17
- <%= javascript_include_tag "application", lena.configuration %>
18
-
19
- If you use Turbolinks or provide other options for your javascript include, you can merge them: <tt>lena.configuration.merge("data-something" => true)</tt>.
20
-
21
- == Usage Client Side
22
-
23
- Leña will now track all exceptions that are thrown in your application. You can also use Leña to log individual errors without throwing an exception. In your JavaScript, simply:
24
-
25
- lena.log('My Error Message')
26
-
27
- == Usage Server Side
28
-
29
- Leña will simply throw an exception, <tt>Lena::JavaScriptError</tt>, when it receives a log message. Why? Because you should be using {something}[https://github.com/smartinez87/exception_notification] to report server errors when they occur. Also that's basically what's happening on the client side, so why not throw an exception on the server?
30
-
31
- If you need to configure what Leña does, you can add +config/initializers/lena.rb+:
32
-
33
- Lena.setup do |config|
34
- config.javascript_handler = Proc.new do |params|
35
- # Custom handling of log message here
36
- end
37
- end
38
-
39
-
40
- == Alternative Setup
41
-
42
- An alternative to setting up Leña on your +application.js+ file is to import Leña separately. This may impact performance, but it will catch compiler errors in any scripts included after it:
43
-
44
- <%= javascript_include_tag "lena", lena.configuration %>
45
-
46
- == License
47
-
48
- This project is distributed under the MIT-LICENSE.
@@ -1,10 +0,0 @@
1
-
2
- # For testing, we'll store all events into an array
3
- Lena.class.send(:cattr_accessor, :events)
4
- Lena.events = []
5
-
6
- Lena.setup do |config|
7
- config.javascript_handler = Proc.new do |params|
8
- Lena.events << params
9
- end
10
- end