chanko 2.0.0 → 2.3.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 (71) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/master_and_pr.yml +64 -0
  3. data/CHANGELOG.md +42 -0
  4. data/MIT-LICENSE +1 -1
  5. data/README.md +30 -9
  6. data/Rakefile +2 -9
  7. data/bin/setup +8 -0
  8. data/bin/test +7 -0
  9. data/chanko.gemspec +8 -4
  10. data/gemfiles/Gemfile_rails_5.0.rb +6 -0
  11. data/gemfiles/Gemfile_rails_5.0.rb.lock +203 -0
  12. data/gemfiles/Gemfile_rails_5.1.rb +6 -0
  13. data/gemfiles/Gemfile_rails_5.1.rb.lock +203 -0
  14. data/gemfiles/Gemfile_rails_5.2.rb +6 -0
  15. data/gemfiles/Gemfile_rails_5.2.rb.lock +209 -0
  16. data/gemfiles/Gemfile_rails_6.0.rb +8 -0
  17. data/gemfiles/Gemfile_rails_6.0.rb.lock +238 -0
  18. data/gemfiles/Gemfile_rails_6.1.rb +8 -0
  19. data/gemfiles/Gemfile_rails_6.1.rb.lock +241 -0
  20. data/lib/chanko/active_if.rb +42 -10
  21. data/lib/chanko/config.rb +20 -2
  22. data/lib/chanko/controller.rb +1 -1
  23. data/lib/chanko/exception_handler.rb +32 -5
  24. data/lib/chanko/function.rb +3 -1
  25. data/lib/chanko/invoker.rb +25 -4
  26. data/lib/chanko/loader.rb +127 -43
  27. data/lib/chanko/railtie.rb +33 -6
  28. data/lib/chanko/resolver/no_cache_file_system_resolver.rb +13 -0
  29. data/lib/chanko/test.rb +6 -1
  30. data/lib/chanko/unit/scope_finder.rb +7 -7
  31. data/lib/chanko/unit.rb +5 -1
  32. data/lib/chanko/unit_proxy.rb +4 -0
  33. data/lib/chanko/version.rb +1 -1
  34. data/lib/generators/chanko/unit/templates/unit.rb.erb +7 -1
  35. data/spec/chanko/controller_spec.rb +5 -5
  36. data/spec/chanko/deprecated_spec.rb +27 -0
  37. data/spec/chanko/exception_handler_spec.rb +23 -2
  38. data/spec/chanko/function_spec.rb +34 -8
  39. data/spec/chanko/helper_spec.rb +1 -1
  40. data/spec/chanko/invoker_spec.rb +62 -36
  41. data/spec/chanko/loader_spec.rb +14 -12
  42. data/spec/chanko/logger_spec.rb +13 -7
  43. data/spec/chanko/test_spec.rb +17 -7
  44. data/spec/chanko/unit/extender_spec.rb +3 -3
  45. data/spec/chanko/unit/scope_finder_spec.rb +4 -4
  46. data/spec/chanko/unit_proxy_provider_spec.rb +12 -12
  47. data/spec/chanko/unit_proxy_spec.rb +3 -3
  48. data/spec/chanko/unit_spec.rb +107 -33
  49. data/spec/controllers/application_controller_spec.rb +2 -2
  50. data/spec/dummy/README.md +12 -0
  51. data/spec/dummy/app/assets/config/manifest.js +3 -0
  52. data/spec/dummy/app/controllers/entries_controller.rb +2 -2
  53. data/spec/dummy/app/models/entry.rb +0 -1
  54. data/spec/dummy/app/units/entry_deletion/entry_deletion.rb +6 -0
  55. data/spec/dummy/config/application.rb +15 -17
  56. data/spec/dummy/config/boot.rb +4 -5
  57. data/spec/dummy/config/environment.rb +1 -1
  58. data/spec/dummy/config/environments/development.rb +2 -16
  59. data/spec/dummy/config/environments/production.rb +5 -1
  60. data/spec/dummy/config/environments/test.rb +10 -7
  61. data/spec/dummy/config/initializers/chanko_initializer.rb +0 -0
  62. data/spec/dummy/config/initializers/secret_token.rb +1 -0
  63. data/spec/dummy/config/storage.yml +1 -0
  64. data/spec/fixtures/units/example_unit/example_unit.rb +17 -0
  65. data/spec/fixtures/units/sensitive_inactive_unit/sensitive_inactive_unit.rb +9 -0
  66. data/spec/fixtures/units/sensitive_unit/sensitive_unit.rb +16 -0
  67. data/spec/spec_helper.rb +35 -5
  68. metadata +112 -70
  69. data/.travis.yml +0 -5
  70. data/Gemfile +0 -26
  71. data/spec/dummy/README.rdoc +0 -261
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  module Chanko
4
4
  describe Unit do
5
5
  before do
6
- unit.stub(:name => "ExampleUnit")
6
+ allow(unit).to receive_messages(:name => "ExampleUnit")
7
7
  end
8
8
 
9
9
  let(:unit) do
@@ -14,7 +14,7 @@ module Chanko
14
14
  Class.new { include Chanko::Helper }.new
15
15
  end
16
16
 
17
- describe ".active_if" do
17
+ describe "about active_if" do
18
18
  before do
19
19
  ActiveIf.define(:true) { true }
20
20
  ActiveIf.define(:false) { false }
@@ -26,38 +26,112 @@ module Chanko
26
26
 
27
27
  subject { unit.active?(view) }
28
28
 
29
- context "in default configuration" do
30
- it "is configured to return always true" do
31
- should be_true
29
+ describe ".active_if" do
30
+ context "in default configuration" do
31
+ it "is configured to return always true" do
32
+ is_expected.to eq(true)
33
+ end
34
+ end
35
+
36
+ context "when labels are specified" do
37
+ before do
38
+ unit.active_if(:true, :false)
39
+ end
40
+ specify "all of defined conditions must pass" do
41
+ is_expected.to eq(false)
42
+ end
43
+ end
44
+
45
+ context "when block is passed" do
46
+ before do
47
+ unit.active_if(:true) { false }
48
+ end
49
+ specify "all of defined conditions and block must pass" do
50
+ is_expected.to eq(false)
51
+ end
52
+ end
53
+
54
+ context "when an undefined condition is specified" do
55
+ before do
56
+ unit.active_if(:this_is_not_a_condition)
57
+ end
58
+
59
+ specify "an undefined condition must raise NoConditionFound" do
60
+ expect { subject }.to raise_error Chanko::ActiveIf::NoConditionFound, /this_is_not_a_condition/
61
+ end
32
62
  end
33
63
  end
34
64
 
35
- context "when labels are specified" do
36
- before do
37
- unit.active_if(:true, :false)
65
+ describe ".any" do
66
+ context "when conditions returned true and false" do
67
+ before do
68
+ unit.instance_eval do
69
+ active_if any(:true, :false)
70
+ end
71
+ end
72
+ it { is_expected.to eq(true) }
38
73
  end
39
- specify "all of defined conditions must pass" do
40
- should be_false
74
+
75
+ context "when all conditions returned false" do
76
+ before do
77
+ unit.instance_eval do
78
+ active_if any(:false, :false)
79
+ end
80
+ end
81
+ it { is_expected.to eq(false) }
41
82
  end
42
83
  end
43
84
 
44
- context "when block is passed" do
45
- before do
46
- unit.active_if(:true) { false }
85
+ describe ".none" do
86
+ context "when all conditions returned false" do
87
+ before do
88
+ unit.instance_eval do
89
+ active_if none(:false, :false)
90
+ end
91
+ end
92
+ it { is_expected.to eq(true) }
47
93
  end
48
- specify "all of defined conditions and block must pass" do
49
- should be_false
94
+
95
+ context "when conditions returned true and false" do
96
+ before do
97
+ unit.instance_eval do
98
+ active_if none(:true, :false)
99
+ end
100
+ end
101
+ it { is_expected.to eq(false) }
50
102
  end
51
103
  end
52
104
 
53
- context "when any is specified" do
54
- before do
55
- unit.instance_eval do
56
- active_if any(:true, :false)
105
+ context "when using 'any' and 'none'" do
106
+ context "'any' in 'none'" do
107
+ before do
108
+ unit.instance_eval do
109
+ active_if none(any(:true, :false))
110
+ end
111
+ end
112
+ it "returns negatived result of inner-expression" do
113
+ is_expected.to eq(false)
57
114
  end
58
115
  end
59
- specify "any of conditions must pass" do
60
- should be_true
116
+
117
+ context "'none' in 'any'" do
118
+ before do
119
+ unit.instance_eval do
120
+ active_if any(none(:true), :false)
121
+ end
122
+ end
123
+ it "uses none(:true) as false" do
124
+ is_expected.to eq(false)
125
+ end
126
+ end
127
+
128
+ context "more nested" do
129
+ before do
130
+ unit.instance_eval do
131
+ active_if any(any(none(:false), :false), :false)
132
+ end
133
+ end
134
+ it { is_expected.to eq(true) }
61
135
  end
62
136
  end
63
137
  end
@@ -65,13 +139,13 @@ module Chanko
65
139
  describe ".scope" do
66
140
  specify "given scope is recorded to used scope list" do
67
141
  unit.scope(:view) { }
68
- unit.scopes.keys.should == [ActionView::Base]
142
+ expect(unit.scopes.keys).to eq([ActionView::Base])
69
143
  end
70
144
 
71
145
  context "in the scoped block" do
72
146
  specify "current_scope returns given scope" do
73
147
  unit.scope(:view) do
74
- unit.current_scope.should == ActionView::Base
148
+ expect(unit.current_scope).to eq(ActionView::Base)
75
149
  end
76
150
  end
77
151
  end
@@ -79,7 +153,7 @@ module Chanko
79
153
  context "out of the scoped block" do
80
154
  specify "current_scope returns nil" do
81
155
  unit.scope(:view) { }
82
- unit.current_scope.should == nil
156
+ expect(unit.current_scope).to eq(nil)
83
157
  end
84
158
  end
85
159
  end
@@ -91,16 +165,16 @@ module Chanko
91
165
  "test"
92
166
  end
93
167
  end
94
- unit.scopes[ActionView::Base][:test].block.call.should == "test"
168
+ expect(unit.scopes[ActionView::Base][:test].block.call).to eq("test")
95
169
  end
96
170
  end
97
171
 
98
172
  describe ".shared" do
99
- it "stroes given block with given label" do
173
+ it "stores given block with given label" do
100
174
  unit.shared(:test) do
101
175
  "test"
102
176
  end
103
- unit.shared_methods[:test].call.should == "test"
177
+ expect(unit.shared_methods[:test].call).to eq("test")
104
178
  end
105
179
  end
106
180
 
@@ -111,7 +185,7 @@ module Chanko
111
185
  "test"
112
186
  end
113
187
  end
114
- view.__example_unit_test.should == "test"
188
+ expect(view.__example_unit_test).to eq("test")
115
189
  end
116
190
  end
117
191
 
@@ -156,25 +230,25 @@ module Chanko
156
230
  end
157
231
 
158
232
  it "defines instance methods with prefix" do
159
- ExampleModel.new.__example_unit_test.should == "test"
233
+ expect(ExampleModel.new.__example_unit_test).to eq("test")
160
234
  end
161
235
 
162
236
  it "defines class methods with prefix" do
163
- ExampleModel.__example_unit_test.should == "test"
237
+ expect(ExampleModel.__example_unit_test).to eq("test")
164
238
  end
165
239
 
166
240
  it "defines scope method with prefix" do
167
- ExampleModel.__example_unit_active.should == "scoped"
241
+ expect(ExampleModel.__example_unit_active).to eq("scoped")
168
242
  end
169
243
 
170
244
  it "defines has_one association method with prefix" do
171
- ExampleModel.__example_unit_user.should == [:class_name => "User"]
245
+ expect(ExampleModel.__example_unit_user).to eq([:class_name => "User"])
172
246
  end
173
247
  end
174
248
 
175
249
  describe ".view_path" do
176
250
  it "returns path for its view directory" do
177
- unit.view_path.should == "#{Config.units_directory_path}/example_unit/views"
251
+ expect(unit.view_path).to eq("#{Config.units_directory_path}/example_unit/views")
178
252
  end
179
253
  end
180
254
  end
@@ -7,8 +7,8 @@ describe ApplicationController do
7
7
  end
8
8
  end
9
9
 
10
- it "clears cache before each request" do
11
- Chanko::Loader.cache.should_receive(:clear).exactly(2)
10
+ it "clears cache before each request", classic: true do
11
+ expect(Chanko::Loader.cache).to receive(:clear).exactly(2)
12
12
  get :index
13
13
  get :index
14
14
  end
@@ -0,0 +1,12 @@
1
+ # Chanko example
2
+ This is an example rails application using Chanko.
3
+ This application has a unit called EntryDeletion,
4
+ which extends MVC logics to provide a feature to delete entries.
5
+
6
+ ## Start
7
+ ```
8
+ $ bundle install
9
+ $ bundle exec rake db:create db:migrate
10
+ $ rails s
11
+ $ open http://localhost:3000
12
+ ```
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
@@ -17,7 +17,7 @@ class EntriesController < ApplicationController
17
17
  end
18
18
 
19
19
  def create
20
- @entry = Entry.create(params[:entry])
20
+ @entry = Entry.create(params[:entry].permit(:title, :body))
21
21
  redirect_to @entry
22
22
  end
23
23
 
@@ -27,7 +27,7 @@ class EntriesController < ApplicationController
27
27
 
28
28
  def update
29
29
  @entry = Entry.find(params[:id])
30
- @entry.update_attributes(params[:entry])
30
+ @entry.update_attributes(params[:entry].permit(:title, :body))
31
31
  redirect_to @entry
32
32
  end
33
33
  end
@@ -1,3 +1,2 @@
1
1
  class Entry < ActiveRecord::Base
2
- attr_accessible :body, :deleted_at, :title
3
2
  end
@@ -26,6 +26,12 @@ module EntryDeletion
26
26
  def soft_delete
27
27
  update_attributes(:deleted_at => Time.now)
28
28
  end
29
+
30
+ class_methods do
31
+ def gc_all_soft_deleted_users
32
+ where.not(deleted_at: nil).delete_all
33
+ end
34
+ end
29
35
  end
30
36
  end
31
37
 
@@ -1,15 +1,9 @@
1
1
  require File.expand_path('../boot', __FILE__)
2
2
 
3
- # Pick the frameworks you want:
4
- require "active_record/railtie"
5
- require "action_controller/railtie"
6
- require "action_mailer/railtie"
7
- require "active_resource/railtie"
8
- require "sprockets/railtie"
9
- # require "rails/test_unit/railtie"
3
+ require "rails/all"
10
4
 
11
5
  if defined?(Bundler)
12
- Bundler.require(*Rails.groups(:assets => %w(development test)))
6
+ Bundler.require(:default, Rails.env)
13
7
  end
14
8
 
15
9
  require "chanko"
@@ -52,17 +46,21 @@ module Dummy
52
46
  # like if you have constraints or database-specific column types
53
47
  # config.active_record.schema_format = :sql
54
48
 
55
- # Enforce whitelist mode for mass assignment.
56
- # This will create an empty whitelist of attributes available for mass-assignment for all models
57
- # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
58
- # parameters by using an attr_accessible or attr_protected declaration.
59
- config.active_record.whitelist_attributes = true
60
-
61
- # Enable the asset pipeline
62
- config.assets.enabled = true
63
-
64
49
  # Version of your assets, change this if you want to expire all your assets
65
50
  config.assets.version = '1.0'
51
+ config.assets.quiet = true if ::Rails::VERSION::MAJOR >= 5
52
+ if Rails::VERSION::MAJOR >= 6
53
+ if ENV['AUTOLOADER'] == 'zeitwerk'
54
+ Chanko::Test.logger.info("Autoloader: zeitwerk")
55
+ config.autoloader = :zeitwerk
56
+ else
57
+ Chanko::Test.logger.info("Autoloader: classic")
58
+ config.autoloader = :classic
59
+ end
60
+ end
66
61
  end
67
62
  end
68
63
 
64
+ if Rails::VERSION::MAJOR >= 6 && Rails.autoloaders.zeitwerk_enabled?
65
+ Rails.autoloaders.main.collapse(Rails.root.join('app', 'units', '*'))
66
+ end
@@ -1,10 +1,9 @@
1
1
  require 'rubygems'
2
- gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
2
 
4
- if File.exist?(gemfile)
5
- ENV['BUNDLE_GEMFILE'] = gemfile
6
- require 'bundler'
7
- Bundler.setup
3
+ unless ENV['BUNDLE_GEMFILE']
4
+ raise "Select Gemfile_x.rb from gemfiles dir then set BUNDLE_GEMFILE"
8
5
  end
9
6
 
7
+ require 'bundler/setup'
8
+
10
9
  $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -2,4 +2,4 @@
2
2
  require File.expand_path('../application', __FILE__)
3
3
 
4
4
  # Initialize the rails application
5
- Dummy::Application.initialize!
5
+ Rails.application.initialize!
@@ -6,9 +6,6 @@ Dummy::Application.configure do
6
6
  # since you don't have to restart the web server when you make code changes.
7
7
  config.cache_classes = false
8
8
 
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
11
-
12
9
  # Show full error reports and disable caching
13
10
  config.consider_all_requests_local = true
14
11
  config.action_controller.perform_caching = false
@@ -19,19 +16,8 @@ Dummy::Application.configure do
19
16
  # Print deprecation notices to the Rails logger
20
17
  config.active_support.deprecation = :log
21
18
 
22
- # Only use best-standards-support built into browsers
23
- config.action_dispatch.best_standards_support = :builtin
24
-
25
- # Raise exception on mass assignment protection for Active Record models
26
- config.active_record.mass_assignment_sanitizer = :strict
27
-
28
- # Log the query plan for queries taking more than this (works
29
- # with SQLite, MySQL, and PostgreSQL)
30
- config.active_record.auto_explain_threshold_in_seconds = 0.5
31
-
32
- # Do not compress assets
33
- config.assets.compress = false
34
-
35
19
  # Expands the lines which load the assets
36
20
  config.assets.debug = true
21
+
22
+ config.eager_load = false
37
23
  end
@@ -9,7 +9,7 @@ Dummy::Application.configure do
9
9
  config.action_controller.perform_caching = true
10
10
 
11
11
  # Disable Rails's static asset server (Apache or nginx will already do this)
12
- config.serve_static_assets = false
12
+ config.serve_static_files = false
13
13
 
14
14
  # Compress JavaScripts and CSS
15
15
  config.assets.compress = true
@@ -64,4 +64,8 @@ Dummy::Application.configure do
64
64
  # Log the query plan for queries taking more than this (works
65
65
  # with SQLite, MySQL, and PostgreSQL)
66
66
  # config.active_record.auto_explain_threshold_in_seconds = 0.5
67
+
68
+ config.eager_load = true
69
+
70
+ config.assets.js_compressor = :uglifier
67
71
  end
@@ -8,12 +8,9 @@ Dummy::Application.configure do
8
8
  config.cache_classes = true
9
9
 
10
10
  # Configure static asset server for tests with Cache-Control for performance
11
- config.serve_static_assets = true
11
+ config.serve_static_files = true
12
12
  config.static_cache_control = "public, max-age=3600"
13
13
 
14
- # Log error messages when you accidentally call methods on nil
15
- config.whiny_nils = true
16
-
17
14
  # Show full error reports and disable caching
18
15
  config.consider_all_requests_local = true
19
16
  config.action_controller.perform_caching = false
@@ -29,9 +26,15 @@ Dummy::Application.configure do
29
26
  # ActionMailer::Base.deliveries array.
30
27
  config.action_mailer.delivery_method = :test
31
28
 
32
- # Raise exception on mass assignment protection for Active Record models
33
- config.active_record.mass_assignment_sanitizer = :strict
34
-
35
29
  # Print deprecation notices to the stderr
36
30
  config.active_support.deprecation = :stderr
31
+
32
+ if ENV['EAGER_LOAD'] == 'true'
33
+ Chanko::Test.logger.info("EagerLoad: on")
34
+ config.eager_load = true
35
+ else
36
+ Chanko::Test.logger.info("EagerLoad: off")
37
+ config.eager_load = false
38
+ end
39
+
37
40
  end
@@ -5,3 +5,4 @@
5
5
  # Make sure the secret is at least 30 characters and all random,
6
6
  # no regular words or you'll be exposed to dictionary attacks.
7
7
  Dummy::Application.config.secret_token = '51ca37a6709156b59d667c092cd18abe392f137efb5e8be61287a5d38823e31d61470bb417098476092e5c53c52467e4a949163c6e78ce70e921ed928b39f9d8'
8
+ Dummy::Application.config.secret_key_base = '24b191b073b60770ff32d8c0096a6786c8aa0c5f7c0968838f5321a0fbda49da3a567984ca3862f353b4cc408e1e23fedd1f3d808ae91965758239f19642a2e6'
@@ -0,0 +1 @@
1
+
@@ -29,6 +29,19 @@ module ExampleUnit
29
29
  function(:render) do
30
30
  render_to_string :partial => "/test", :locals => { :local => "test" }
31
31
  end
32
+
33
+ function(:nesting_locals_outer) do
34
+ result = "#{outer_one}."
35
+ result += invoke(:example_unit, :nesting_locals_inner, :locals => { :inner_one => "inner_one", :inner_two => "inner_two" }) do
36
+ "#{outer_two}.#{run_default}"
37
+ end
38
+ result += ".#{outer_three}"
39
+ result
40
+ end
41
+
42
+ function(:nesting_locals_inner) do
43
+ "#{inner_one}.#{run_default}.#{inner_two}"
44
+ end
32
45
  end
33
46
 
34
47
  scope(:view) do
@@ -60,6 +73,10 @@ module ExampleUnit
60
73
  unit.helper
61
74
  end
62
75
 
76
+ function(:respond_to_helper?) do
77
+ unit.respond_to?(:helper)
78
+ end
79
+
63
80
  function(:render) do
64
81
  render "/test", :local => "test"
65
82
  end
@@ -0,0 +1,9 @@
1
+ module SensitiveInactiveUnit
2
+ include Chanko::Unit
3
+ active_if { false }
4
+
5
+ scope(:controller) do
6
+ function(:outer) {}
7
+ function(:innner) {}
8
+ end
9
+ end
@@ -1,4 +1,20 @@
1
1
  module SensitiveUnit
2
2
  include Chanko::Unit
3
3
  raise_error
4
+
5
+ def self.ping
6
+ end
7
+
8
+ scope(:controller) do
9
+ function(:outer_default) do
10
+ invoke(:sensitive_unit, :inner_default) do
11
+ SensitiveUnit.ping
12
+ run_default
13
+ end
14
+ end
15
+
16
+ function(:inner_default) do
17
+ run_default
18
+ end
19
+ end
4
20
  end
data/spec/spec_helper.rb CHANGED
@@ -1,27 +1,57 @@
1
- require "simplecov"
2
- SimpleCov.start do
1
+ require 'simplecov'
2
+
3
+ SimpleCov.start 'rails' do
4
+ if ENV['CI']
5
+ require 'simplecov-lcov'
6
+ SimpleCov::Formatter::LcovFormatter.config do |c|
7
+ c.report_with_single_file = true
8
+ c.single_report_path = 'coverage/lcov.info'
9
+ end
10
+ formatter SimpleCov::Formatter::LcovFormatter
11
+ end
12
+
3
13
  add_filter "/spec\/fixtures/"
4
14
  add_filter "/spec\/dummy/"
5
15
  end
6
16
 
7
17
  ENV["RAILS_ENV"] ||= "test"
8
18
  require "chanko"
19
+ require "chanko/test"
20
+ Chanko::Config.units_directory_path = File.expand_path("../fixtures/units", __FILE__)
9
21
 
10
22
  require File.expand_path("../dummy/config/environment", __FILE__)
11
23
  require "rspec/rails"
12
- require "rspec/autorun"
13
24
 
14
25
  RSpec.configure do |config|
15
26
  config.use_transactional_fixtures = true
16
27
  config.infer_base_class_for_anonymous_controllers = false
17
- config.treat_symbols_as_metadata_keys_with_true_values = true
18
28
  config.run_all_when_everything_filtered = true
19
29
  config.filter_run :focus
20
30
 
31
+ config.expect_with :rspec do |expectations|
32
+ expectations.syntax = :expect
33
+ end
34
+
21
35
  config.after do
22
36
  Chanko::Config.reset
23
37
  Chanko::Config.units_directory_path = File.expand_path("../fixtures/units", __FILE__)
24
38
  end
39
+
40
+ # rspec-rails 3 will no longer automatically infer an example group's spec type
41
+ # from the file location. You can explicitly opt-in to the feature using this
42
+ # config option.
43
+ # To explicitly tag specs without using automatic inference, set the `:type`
44
+ # metadata manually:
45
+ #
46
+ # describe ThingsController, :type => :controller do
47
+ # # Equivalent to being in spec/controllers
48
+ # end
49
+ config.infer_spec_type_from_file_location!
50
+
51
+ if Rails.respond_to?(:autoloaders) && Rails.autoloaders.zeitwerk_enabled?
52
+ config.filter_run_excluding classic: true
53
+ else
54
+ config.filter_run_excluding zeitwerk: true
55
+ end
25
56
  end
26
57
 
27
- Chanko::Config.units_directory_path = File.expand_path("../fixtures/units", __FILE__)