passages 0.1.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.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.travis.yml +7 -0
  4. data/Gemfile +3 -0
  5. data/Gemfile.lock +119 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +20 -0
  8. data/app/assets/javascripts/passages/application.js +74 -0
  9. data/app/assets/stylesheets/passages/application.css +20 -0
  10. data/app/controllers/passages/routes_controller.rb +49 -0
  11. data/app/views/passages/routes/_route.html.erb +7 -0
  12. data/app/views/passages/routes/_routes_header.html.erb +5 -0
  13. data/app/views/passages/routes/routes.html.erb +59 -0
  14. data/config/initializers/assets.rb +1 -0
  15. data/config/routes.rb +3 -0
  16. data/lib/passages/engine.rb +11 -0
  17. data/lib/passages/engine_route.rb +13 -0
  18. data/lib/passages/engine_route_collection.rb +10 -0
  19. data/lib/passages/mount_route.rb +12 -0
  20. data/lib/passages/route.rb +44 -0
  21. data/lib/passages/route_collection.rb +23 -0
  22. data/lib/passages.rb +5 -0
  23. data/passages.gemspec +24 -0
  24. data/spec/controllers/passages/routes_controller_spec.rb +46 -0
  25. data/spec/lib/passages/engine_route_collection_spec.rb +42 -0
  26. data/spec/lib/passages/mount_route_spec.rb +29 -0
  27. data/spec/lib/passages/route_collection_spec.rb +50 -0
  28. data/spec/lib/passages/route_spec.rb +64 -0
  29. data/spec/spec_helper.rb +4 -0
  30. data/vendor/assets/fonts/glyphicons-halflings-regular.eot +0 -0
  31. data/vendor/assets/fonts/glyphicons-halflings-regular.svg +288 -0
  32. data/vendor/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
  33. data/vendor/assets/fonts/glyphicons-halflings-regular.woff +0 -0
  34. data/vendor/assets/fonts/glyphicons-halflings-regular.woff2 +0 -0
  35. data/vendor/assets/javascripts/bootstrap.min.js +7 -0
  36. data/vendor/assets/javascripts/jquery-2.1.4.min.js +4 -0
  37. data/vendor/assets/stylesheets/bootstrap-theme.min.css +5 -0
  38. data/vendor/assets/stylesheets/bootstrap.min.css +5 -0
  39. data/version.rb +7 -0
  40. metadata +118 -0
@@ -0,0 +1,29 @@
1
+ require_relative '../../spec_helper'
2
+ require_relative '../../../lib/passages/mount_route'
3
+
4
+ module Passages
5
+ describe MountRoute do
6
+ subject { described_class.new(anything, anything) }
7
+
8
+ describe '#initialize' do
9
+ it 'sets the @app ivar' do
10
+ expect(subject.instance_variable_get(:@app)).to_not be_nil
11
+ end
12
+ end
13
+
14
+ describe '#engine_name' do
15
+ it 'calls name on the app ivar' do
16
+ expect(subject.instance_variable_get(:@app)).to receive(:name)
17
+ subject.engine_name
18
+ end
19
+ end
20
+
21
+ [:internal?, :path].each do |method|
22
+ describe "##{ method }" do
23
+ it "responds to #{ method }" do
24
+ expect(subject).to respond_to(method)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,50 @@
1
+ require_relative '../../spec_helper'
2
+ require_relative '../../../lib/passages/route_collection'
3
+
4
+ module Passages
5
+ describe RouteCollection do
6
+ let(:fake_route) { instance_double(Passages::Route) }
7
+
8
+ before do
9
+ allow_any_instance_of(described_class).to receive(:main_app_name) { 'SomeGreatApp' }
10
+ allow(fake_route).to receive(:internal?) { false }
11
+ end
12
+
13
+ subject { described_class.new([fake_route]) }
14
+
15
+ it 'is behaves like an enumerable' do
16
+ expect(subject.respond_to?(:each)).to eq(true)
17
+ end
18
+
19
+ describe '#initialize' do
20
+ subject { described_class.new([fake_route]) }
21
+
22
+ it 'sets the @routes variable' do
23
+ expect(subject.instance_variable_get(:@routes)).to_not be_nil
24
+ end
25
+
26
+ context 'route is internal' do
27
+ before do
28
+ allow(fake_route).to receive(:internal?) { true }
29
+ end
30
+
31
+ it 'does not add it to @routes' do
32
+ expect(subject.routes).to be_empty
33
+ end
34
+
35
+ context 'internal and external routes exist' do
36
+ let(:another_fake_route) { instance_double(Passages::Route) }
37
+ subject { described_class.new([fake_route, another_fake_route])}
38
+
39
+ before do
40
+ allow(another_fake_route).to receive(:internal?) { false }
41
+ end
42
+
43
+ it 'only adds the external route' do
44
+ expect(subject.routes).to eq([another_fake_route])
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,64 @@
1
+ require_relative '../../spec_helper'
2
+ require_relative '../../../lib/passages/route'
3
+
4
+ module Passages
5
+ describe Route do
6
+ subject { described_class.new(anything) }
7
+
8
+ describe '#name' do
9
+ it 'calls name on the __getobj__' do
10
+ expect(subject.__getobj__).to receive(:name)
11
+ subject.name
12
+ end
13
+ end
14
+
15
+ describe '#verb' do
16
+ it 'calls verb on the __getobj__' do
17
+ expect(subject.__getobj__).to receive(:verb)
18
+ subject.verb
19
+ end
20
+ end
21
+
22
+ describe '#controller' do
23
+ it 'calls controller on the __getobj__' do
24
+ expect(subject.__getobj__).to receive(:controller)
25
+ subject.controller
26
+ end
27
+ end
28
+
29
+ describe '#action' do
30
+ it 'calls action on the __getobj__' do
31
+ expect(subject.__getobj__).to receive(:action)
32
+ subject.action
33
+ end
34
+ end
35
+
36
+ describe '#path' do
37
+ it 'calls path on the __getobj__' do
38
+ expect(subject.__getobj__).to receive(:path)
39
+ subject.path
40
+ end
41
+ end
42
+
43
+ describe '.from_raw_route' do
44
+ let(:raw_route) { anything }
45
+ before { allow(described_class).to receive(:mount_route_class) { mount_class } }
46
+
47
+ context 'mount class is present' do
48
+ let(:mount_class) { anything }
49
+ it 'instantiates and returns a new MountRoute' do
50
+ expect(MountRoute).to receive(:new).with(raw_route, mount_class)
51
+ described_class.from_raw_route(raw_route)
52
+ end
53
+ end
54
+
55
+ context 'mount class is nil' do
56
+ let(:mount_class) { nil }
57
+ it 'instantiates and returns a new Route' do
58
+ expect(described_class).to receive(:new).with(raw_route)
59
+ described_class.from_raw_route(raw_route)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,4 @@
1
+ require 'action_dispatch/routing'
2
+ require 'action_dispatch/routing/inspector'
3
+ require 'active_support'
4
+ require 'action_controller'