mascot-rails 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -7
- data/app/controllers/mascot/sitemap_controller.rb +9 -46
- data/config/routes.rb +5 -3
- data/lib/mascot-rails.rb +12 -3
- data/lib/mascot/action_controller_context.rb +49 -0
- data/lib/mascot/route_constraint.rb +1 -1
- data/spec/dummy/log/test.log +8063 -0
- data/spec/mascot-rails_spec.rb +42 -0
- data/spec/spec_helper.rb +11 -26
- metadata +5 -6
- data/spec/dummy/config/initializers/mascot.rb +0 -3
data/spec/mascot-rails_spec.rb
CHANGED
@@ -2,6 +2,21 @@ require "spec_helper"
|
|
2
2
|
require "rails"
|
3
3
|
require "mascot-rails"
|
4
4
|
|
5
|
+
describe Mascot do
|
6
|
+
context "default configuration" do
|
7
|
+
subject{ Mascot.configuration }
|
8
|
+
it "has sitemap" do
|
9
|
+
expect(subject.sitemap.file_path).to eql(Rails.root.join("app/pages"))
|
10
|
+
end
|
11
|
+
it "has Rails.application as parent engine" do
|
12
|
+
expect(subject.parent_engine).to eql(Rails.application)
|
13
|
+
end
|
14
|
+
it "has routes enabled by default" do
|
15
|
+
expect(subject.routes).to be true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
5
20
|
describe Mascot::RouteConstraint do
|
6
21
|
let(:sitemap) { Mascot::Sitemap.new(file_path: "spec/pages") }
|
7
22
|
let(:route_constraint) { Mascot::RouteConstraint.new(sitemap) }
|
@@ -61,3 +76,30 @@ describe Mascot::SitemapController, type: :controller do
|
|
61
76
|
end
|
62
77
|
end
|
63
78
|
end
|
79
|
+
|
80
|
+
describe "Mascot routes", type: :routing do
|
81
|
+
context "routes enabled" do
|
82
|
+
before do
|
83
|
+
Mascot.configuration.routes = true
|
84
|
+
Rails.application.reload_routes!
|
85
|
+
end
|
86
|
+
it "generates link" do
|
87
|
+
expect(page_path("hi")).to eql("/hi")
|
88
|
+
end
|
89
|
+
it "is routable" do
|
90
|
+
expect(get("/hi")).to route_to(controller: "mascot/sitemap", action: "show", path: "hi")
|
91
|
+
end
|
92
|
+
end
|
93
|
+
context "routes disabled" do
|
94
|
+
before do
|
95
|
+
Mascot.configuration.routes = false
|
96
|
+
Rails.application.reload_routes!
|
97
|
+
end
|
98
|
+
it "is not routable" do
|
99
|
+
expect(get("/hi")).to_not be_routable
|
100
|
+
end
|
101
|
+
it "does not generate link" do
|
102
|
+
expect{page_path("hi")}.to raise_exception(NoMethodError)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -11,33 +11,18 @@ Rails.backtrace_cleaner.remove_silencers!
|
|
11
11
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
12
12
|
|
13
13
|
RSpec.configure do |config|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
config.mock_with :rspec
|
15
|
+
config.use_transactional_fixtures = true
|
16
|
+
config.infer_base_class_for_anonymous_controllers = false
|
17
|
+
config.order = "random"
|
18
|
+
config.after(:each) do
|
19
|
+
Mascot.instance_variable_set(:@configuration, nil)
|
20
|
+
Rails.application.reload_routes!
|
21
|
+
end
|
18
22
|
end
|
19
23
|
|
20
24
|
require "codeclimate-test-reporter"
|
25
|
+
CodeClimate::TestReporter.configure do |config|
|
26
|
+
config.git_dir = `git rev-parse --show-toplevel`.strip
|
27
|
+
end
|
21
28
|
CodeClimate::TestReporter.start
|
22
|
-
|
23
|
-
# From test folder...
|
24
|
-
# # Configure Rails Environment
|
25
|
-
# ENV["RAILS_ENV"] = "test"
|
26
|
-
|
27
|
-
# require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
|
28
|
-
# ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
|
29
|
-
# ActiveRecord::Migrator.migrations_paths << File.expand_path('../../db/migrate', __FILE__)
|
30
|
-
# require "rails/test_help"
|
31
|
-
|
32
|
-
# # Filter out Minitest backtrace while allowing backtrace from other libraries
|
33
|
-
# # to be shown.
|
34
|
-
# Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|
35
|
-
|
36
|
-
|
37
|
-
# # Load fixtures from the engine
|
38
|
-
# if ActiveSupport::TestCase.respond_to?(:fixture_path=)
|
39
|
-
# ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
40
|
-
# ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
|
41
|
-
# ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files"
|
42
|
-
# ActiveSupport::TestCase.fixtures :all
|
43
|
-
# end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mascot-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brad Gessler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sqlite3
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.1.
|
61
|
+
version: 0.1.4
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.1.
|
68
|
+
version: 0.1.4
|
69
69
|
description:
|
70
70
|
email:
|
71
71
|
- bradgessler@gmail.com
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- app/helpers/mascot/application_helper.rb
|
80
80
|
- config/routes.rb
|
81
81
|
- lib/mascot-rails.rb
|
82
|
+
- lib/mascot/action_controller_context.rb
|
82
83
|
- lib/mascot/engine.rb
|
83
84
|
- lib/mascot/route_constraint.rb
|
84
85
|
- lib/tasks/mascot_tasks.rake
|
@@ -119,7 +120,6 @@ files:
|
|
119
120
|
- spec/dummy/config/initializers/cookies_serializer.rb
|
120
121
|
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
121
122
|
- spec/dummy/config/initializers/inflections.rb
|
122
|
-
- spec/dummy/config/initializers/mascot.rb
|
123
123
|
- spec/dummy/config/initializers/mime_types.rb
|
124
124
|
- spec/dummy/config/initializers/session_store.rb
|
125
125
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
@@ -201,7 +201,6 @@ test_files:
|
|
201
201
|
- spec/dummy/config/initializers/cookies_serializer.rb
|
202
202
|
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
203
203
|
- spec/dummy/config/initializers/inflections.rb
|
204
|
-
- spec/dummy/config/initializers/mascot.rb
|
205
204
|
- spec/dummy/config/initializers/mime_types.rb
|
206
205
|
- spec/dummy/config/initializers/session_store.rb
|
207
206
|
- spec/dummy/config/initializers/wrap_parameters.rb
|