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
@@ -14,6 +14,27 @@ module Chanko
14
14
  Exception.new
15
15
  end
16
16
 
17
+ context "when Config.propagated_errors includes given error" do
18
+ before do
19
+ Config.propagated_errors << Exception
20
+ end
21
+
22
+ it "raises up error without any logging" do
23
+ expect(Logger).not_to receive(:debug)
24
+ expect { described_class.handle(error, insensitive_unit) }.to raise_error(error)
25
+ end
26
+ end
27
+
28
+ context "when Config.propagated_errors does not include given error" do
29
+ before do
30
+ Config.propagated_errors << StandardError
31
+ end
32
+
33
+ it "raises up no error" do
34
+ expect { described_class.handle(error, insensitive_unit) }.not_to raise_error
35
+ end
36
+ end
37
+
17
38
  context "when Config.raise_error is false" do
18
39
  it "raises up no error" do
19
40
  expect { described_class.handle(error, insensitive_unit) }.not_to raise_error
@@ -26,13 +47,13 @@ module Chanko
26
47
  end
27
48
 
28
49
  it "raises up error" do
29
- expect { described_class.handle(error, insensitive_unit) }.to raise_error
50
+ expect { described_class.handle(error, insensitive_unit) }.to raise_error(error)
30
51
  end
31
52
  end
32
53
 
33
54
  context "when unit.raise_error is configured" do
34
55
  it "raises up error" do
35
- expect { described_class.handle(error, sensitive_unit) }.to raise_error
56
+ expect { described_class.handle(error, sensitive_unit) }.to raise_error(error)
36
57
  end
37
58
  end
38
59
  end
@@ -6,10 +6,25 @@ module Chanko
6
6
  Loader.load(:example_unit)
7
7
  end
8
8
 
9
- let(:context) do
10
- Class.new(ActionView::Base) do
11
- include Chanko::Invoker
9
+ def rails5_action_view_instance
10
+ klass = Class.new(ActionView::Base) do
11
+ def current_unit
12
+ units.last
13
+ end
14
+
15
+ def units
16
+ @units ||= []
17
+ end
18
+
19
+ def path
20
+ view_paths.first.to_s
21
+ end
22
+ end
23
+ klass.new
24
+ end
12
25
 
26
+ def rails6_action_view_instance
27
+ klass = Class.new(ActionView::Base.with_empty_template_cache) do
13
28
  def current_unit
14
29
  units.last
15
30
  end
@@ -21,7 +36,18 @@ module Chanko
21
36
  def path
22
37
  view_paths.first.to_s
23
38
  end
24
- end.new
39
+ end
40
+
41
+ klass.with_view_paths([], {}, nil)
42
+ end
43
+
44
+ let(:context) do
45
+ case Rails::VERSION::MAJOR
46
+ when 5
47
+ rails5_action_view_instance
48
+ when 6
49
+ rails6_action_view_instance
50
+ end
25
51
  end
26
52
 
27
53
  let(:context_without_view_paths) do
@@ -40,19 +66,19 @@ module Chanko
40
66
 
41
67
  describe ".invoke" do
42
68
  it "invokes block with given context and stacked unit" do
43
- described_class.new(unit, :label) { current_unit }.invoke(context, options).should == unit
69
+ expect(described_class.new(unit, :label) { current_unit }.invoke(context, options)).to eq(unit)
44
70
  end
45
71
 
46
72
  context "when context is a view" do
47
73
  it "invokes with unit's view path" do
48
- described_class.new(unit, :label) { path }.invoke(context, options).should == unit.view_path
74
+ expect(described_class.new(unit, :label) { path }.invoke(context, options)).to eq(unit.view_path)
49
75
  end
50
76
  end
51
77
 
52
78
  context "when context does not have view_paths" do
53
79
  it "invokes successfully" do
54
- described_class.new(unit, :label) { "test" }.
55
- invoke(context_without_view_paths, options).should == "test"
80
+ expect(described_class.new(unit, :label) { "test" }.
81
+ invoke(context_without_view_paths, options)).to eq("test")
56
82
  end
57
83
  end
58
84
  end
@@ -19,7 +19,7 @@ module Chanko
19
19
  "test"
20
20
  end
21
21
  end
22
- view.__example_unit_test.should == "test"
22
+ expect(view.__example_unit_test).to eq("test")
23
23
  end
24
24
  end
25
25
  end
@@ -3,67 +3,67 @@ require "spec_helper"
3
3
  module Chanko
4
4
  describe Invoker do
5
5
  let(:view) do
6
- Class.new(ActionView::Base) do
7
- include Chanko::Invoker
8
- include Chanko::Helper
9
- include Chanko::UnitProxyProvider
10
- end.new
6
+ controller.helpers
11
7
  end
12
8
 
13
9
  let(:controller) do
14
- Class.new(ActionController::Base) do
15
- include Chanko::Invoker
16
- include Chanko::Helper
17
- include Chanko::UnitProxyProvider
18
- end.new
10
+ Class.new(ActionController::Base).new
19
11
  end
20
12
 
21
13
  describe "#invoke" do
22
14
  it "invokes in the same context with receiver" do
23
- view.invoke(:example_unit, :self, :type => :plain).should == view
15
+ expect(view.invoke(:example_unit, :self, :type => :plain)).to eq(view)
24
16
  end
25
17
 
26
18
  it "invokes with locals option" do
27
- view.invoke(:example_unit, :locals, :locals => { :key => "value" }, :type => :plain).
28
- should == "value"
19
+ expect(view.invoke(:example_unit, :locals, :locals => { :key => "value" }, :type => :plain)).
20
+ to eq("value")
29
21
  end
30
22
 
31
23
  it "invokes with falsy locals" do
32
- view.invoke(:example_unit, :falsy, :locals => { :key => nil }, :type => :plain).
33
- should == true
24
+ expect(view.invoke(:example_unit, :falsy, :locals => { :key => nil }, :type => :plain)).
25
+ to eq(true)
34
26
  end
35
27
 
36
28
  it "invokes with shared method" do
37
- view.invoke(:example_unit, :shared, :type => :plain).should == "shared args"
29
+ expect(view.invoke(:example_unit, :shared, :type => :plain)).to eq("shared args")
38
30
  end
39
31
 
40
32
  it "invokes with helper method in view context" do
41
- view.invoke(:example_unit, :helper, :type => :plain).should == "helper"
33
+ expect(view.invoke(:example_unit, :helper, :type => :plain)).to eq("helper")
34
+ end
35
+
36
+ context 'when unit is referred from unit function' do
37
+ it 'responds to method which the context responds to' do
38
+ expect(view.invoke(:example_unit, :respond_to_helper?, type: :plain)).to eq(true)
39
+ end
42
40
  end
43
41
 
44
42
  context "when invoked in view" do
45
43
  it "invokes with partial view" do
46
- view.invoke(:example_unit, :render, :type => :plain).should == "test\n"
44
+ expect(view.invoke(:example_unit, :render, :type => :plain)).to eq("test\n")
47
45
  end
48
46
  end
49
47
 
50
48
  context "when invoked in controller" do
51
49
  it "invokes with unit views path" do
52
- controller.invoke(:example_unit, :render, :type => :plain).should == "test\n"
50
+ expect(controller.invoke(:example_unit, :render, :type => :plain)).to eq("test\n")
53
51
  end
54
52
  end
55
53
 
56
54
  context "when short-hand style args is passed" do
57
55
  it "recognizes args as locals option" do
58
- view.invoke(:example_unit, :locals, :key => "value").should ==
56
+ expect(view.invoke(:example_unit, :locals, :key => "value")).to eq(
59
57
  '<div class="unit unit__example_unit unit__example_unit__locals">value</div>'
58
+ )
60
59
  end
61
60
  end
62
61
 
63
62
  context "when type is not specified" do
64
63
  it "invokes and returns result surrounded by div" do
65
- view.invoke(:example_unit, :test).should ==
64
+ expect(view.invoke(:example_unit, :test)).to eq(
66
65
  '<div class="unit unit__example_unit unit__example_unit__test">test</div>'
66
+ )
67
67
  end
68
68
  end
69
69
 
@@ -73,58 +73,84 @@ module Chanko
73
73
  end
74
74
 
75
75
  it "invokes and returns result surrounded by div" do
76
- view.invoke(:example_unit, :test).should ==
76
+ expect(view.invoke(:example_unit, :test)).to eq(
77
77
  '<div class="extension ext_example_unit ext_example_unit-test">test</div>'
78
+ )
78
79
  end
79
80
  end
80
81
 
81
82
  context "when type is :plain" do
82
83
  it "does not surround result with html element" do
83
- view.invoke(:example_unit, :test, :type => :plain).should == "test"
84
+ expect(view.invoke(:example_unit, :test, :type => :plain)).to eq("test")
84
85
  end
85
86
  end
86
87
 
87
88
  context "when the result is blank" do
88
89
  it "does not surround result with html element" do
89
- view.invoke(:example_unit, :blank).should == " "
90
+ expect(view.invoke(:example_unit, :blank)).to eq(" ")
90
91
  end
91
92
  end
92
93
 
93
94
  context "when type is :inline" do
94
95
  it "invokes and returns result surrounded by span" do
95
- view.invoke(:example_unit, :test, :type => :inline).should ==
96
+ expect(view.invoke(:example_unit, :test, :type => :inline)).to eq(
96
97
  '<span class="unit unit__example_unit unit__example_unit__test">test</span>'
98
+ )
97
99
  end
98
100
  end
99
101
 
100
102
  context "when context is not a view" do
101
103
  it "does not surround result with html tag" do
102
- controller.invoke(:example_unit, :test).should == "test"
104
+ expect(controller.invoke(:example_unit, :test)).to eq("test")
103
105
  end
104
106
  end
105
107
 
106
108
  context "when run_default is called in function" do
107
109
  it "invokes given block as a fallback" do
108
- controller.invoke(:example_unit, :default) { "default" }.should == "default"
110
+ expect(controller.invoke(:example_unit, :default) { "default" }).to eq("default")
111
+ end
112
+ end
113
+
114
+ context "when nested run_default is called in function" do
115
+ it "invokes given block as a fallback" do
116
+ Chanko::Loader.load("sensitive_unit")
117
+ expect(SensitiveUnit).to receive(:ping).once
118
+
119
+ expect(controller.invoke(:sensitive_unit, :outer_default) do
120
+ "default"
121
+ end).to eq "default"
122
+ end
123
+
124
+ it 'use both locals' do
125
+ expect(controller.invoke(:example_unit, :nesting_locals_outer, :locals => { :outer_one => "outer_one", :outer_two => "outer_two", :outer_three => "outer_three"}) do
126
+ "default"
127
+ end).to eq "outer_one.inner_one.outer_two.default.inner_two.outer_three"
128
+ end
129
+
130
+ context 'active_if is false' do
131
+ it "invokes given block as a fallback " do
132
+ Chanko::Loader.load("sensitive_inactive_unit")
133
+ expect(controller.invoke(:sensitive_inactive_unit, :outer) { invoke(:sensitive_inactive_unit, :inner) }).to eq(nil)
134
+ end
109
135
  end
110
136
  end
111
137
 
112
138
  context "when run_default is called but no block given" do
113
139
  it "invokes given block as a fallback" do
114
- controller.invoke(:example_unit, :default).should == nil
140
+ expect(controller.invoke(:example_unit, :default)).to eq(nil)
115
141
  end
116
142
  end
117
143
 
118
144
  context "when non-existent unit is specified" do
119
145
  it "does nothing" do
120
- view.invoke(:non_existent_unit, :test, :type => :plain).should == nil
146
+ expect(view.invoke(:non_existent_unit, :test, :type => :plain)).to eq(nil)
121
147
  end
122
148
  end
123
149
 
124
150
  context "when function is not found" do
125
151
  it "runs default but not handled by ExceptionHandler" do
126
- ExceptionHandler.should_not_receive(:handle)
127
- view.invoke(:example_unit, :non_existent_function) { "default" }.should == "default"
152
+ expect(ExceptionHandler).not_to receive(:handle)
153
+ expect(view.invoke(:example_unit, :non_existent_function) { "default" }).to eq("default")
128
154
  end
129
155
  end
130
156
 
@@ -132,22 +158,22 @@ module Chanko
132
158
  context "when block is given" do
133
159
  context "when context is a view" do
134
160
  it "captures given block as a fallback" do
135
- view.should_receive(:capture).and_call_original
136
- view.invoke(:example_unit, :error) { "error" }.should == "error"
161
+ expect(view).to receive(:capture).and_call_original
162
+ expect(view.invoke(:example_unit, :error) { "error" }).to eq("error")
137
163
  end
138
164
  end
139
165
 
140
166
  context "when context is not a view" do
141
167
  it "calls given block as a fallback" do
142
- controller.should_not_receive(:capture)
143
- controller.invoke(:example_unit, :error) { "error" }.should == "error"
168
+ expect(controller).not_to receive(:capture)
169
+ expect(controller.invoke(:example_unit, :error) { "error" }).to eq("error")
144
170
  end
145
171
  end
146
172
  end
147
173
 
148
174
  context "when no block is given" do
149
175
  it "rescues the error and does nothing" do
150
- view.invoke(:example_unit, :error).should == nil
176
+ expect(view.invoke(:example_unit, :error)).to eq(nil)
151
177
  end
152
178
  end
153
179
  end
@@ -4,38 +4,40 @@ module Chanko
4
4
  describe Loader do
5
5
  describe ".load" do
6
6
  after do
7
- described_class.cache.clear
7
+ Chanko::Loader.cache.clear
8
8
  end
9
9
 
10
10
  context "when existent unit name is passed" do
11
11
  it "loads unit in units directory and returns the Module" do
12
- described_class.load(:example_unit).should == ExampleUnit
12
+ expect(Chanko::Loader.load(:example_unit)).to eq(ExampleUnit)
13
13
  end
14
14
  end
15
15
 
16
16
  context "when non-existent unit name is passed" do
17
17
  it "returns nil" do
18
- described_class.load(:non_existent_unit).should == nil
18
+ expect(Chanko::Loader.load(:non_existent_unit)).to eq(false)
19
19
  end
20
20
  end
21
21
 
22
22
  context "when loader has ever loaded specified unit" do
23
- it "load unit from cache" do
24
- described_class.any_instance.should_receive(:load_from_file).and_call_original
25
- described_class.load(:example_unit)
26
- described_class.load(:example_unit)
23
+ it "load unit from cache", classic: true do
24
+ expect(Chanko::Loader::ClassicLoader).to receive(:load_from_cache).twice.and_call_original
25
+ expect(Chanko::Loader::ClassicLoader).to receive(:save_to_cache).with(anything, ExampleUnit).and_call_original
26
+ expect(Chanko::Loader.load(:example_unit)).to eq(ExampleUnit)
27
+ expect(Chanko::Loader.load(:example_unit)).to eq(ExampleUnit)
27
28
  end
28
29
  end
29
30
 
30
31
  context "when loader has ever loaded specified wrong unit" do
31
32
  before do
32
- described_class.cache.clear
33
+ Chanko::Loader.cache.clear
33
34
  end
34
35
 
35
- it "load unit from cache" do
36
- described_class.any_instance.should_receive(:load_from_file).and_call_original
37
- described_class.load(:non_existent_unit)
38
- described_class.load(:non_existent_unit)
36
+ it "load unit from cache", classic: true do
37
+ expect(Chanko::Loader::ClassicLoader).to receive(:load_from_cache).twice.and_call_original
38
+ expect(Chanko::Loader::ClassicLoader).to receive(:save_to_cache).with(anything, false).and_call_original
39
+ expect(Chanko::Loader.load(:non_existent_unit)).to eq(false)
40
+ expect(Chanko::Loader.load(:non_existent_unit)).to eq(false)
39
41
  end
40
42
  end
41
43
  end
@@ -4,11 +4,17 @@ require "stringio"
4
4
  module Chanko
5
5
  describe Logger do
6
6
  around do |example|
7
- origin, Rails.logger = Rails.logger, ::Logger.new(io)
7
+ origin, Rails.logger = Rails.logger, logger
8
8
  example.run
9
9
  Rails.logger = origin
10
10
  end
11
11
 
12
+ let(:logger) do
13
+ logger = ::Logger.new(io)
14
+ logger.formatter = lambda {|severity, time, progname, message| message }
15
+ logger
16
+ end
17
+
12
18
  let(:io) do
13
19
  StringIO.new
14
20
  end
@@ -47,7 +53,7 @@ module Chanko
47
53
  context "when given Exception" do
48
54
  it "parses and logs it" do
49
55
  described_class.debug(exception)
50
- log.should == lines.join("\n")
56
+ expect(log).to eq(lines.join("\n"))
51
57
  end
52
58
 
53
59
  context "when Config.backtrace_limit is configured" do
@@ -57,7 +63,7 @@ module Chanko
57
63
 
58
64
  it "prints backtrace up to configured depth" do
59
65
  described_class.debug(exception)
60
- log.should == lines[0..5].join("\n")
66
+ expect(log).to eq(lines[0..5].join("\n"))
61
67
  end
62
68
  end
63
69
  end
@@ -65,7 +71,7 @@ module Chanko
65
71
  context "when given String" do
66
72
  it "adds prefix" do
67
73
  described_class.debug("test")
68
- log.should == " [Chanko] test"
74
+ expect(log).to eq(" [Chanko] test")
69
75
  end
70
76
  end
71
77
  end
@@ -77,17 +83,17 @@ module Chanko
77
83
 
78
84
  it "logs nothing" do
79
85
  described_class.debug("test")
80
- log.should == ""
86
+ expect(log).to eq("")
81
87
  end
82
88
  end
83
89
 
84
90
  context "when Rails.logger is nil" do
85
91
  before do
86
- Rails.stub(:logger)
92
+ allow(Rails).to receive(:logger)
87
93
  end
88
94
 
89
95
  it "does notihng" do
90
- expect { described_class.debug(exception) }.not_to raise_error(NoMethodError)
96
+ expect { described_class.debug(exception) }.not_to raise_error
91
97
  end
92
98
  end
93
99
  end
@@ -3,25 +3,35 @@ require "chanko/test"
3
3
 
4
4
  module Chanko
5
5
  describe Test do
6
+ def rails5_action_view_instance
7
+ Class.new(ActionView::Base).new
8
+ end
9
+
10
+ def rails6_action_view_instance
11
+ klass = Class.new(ActionView::Base.with_empty_template_cache)
12
+ klass.with_view_paths(nil, {}, nil)
13
+ end
14
+
6
15
  let(:view) do
7
- Class.new(ActionView::Base) do
8
- include Chanko::Invoker
9
- include Chanko::Helper
10
- include Chanko::UnitProxyProvider
11
- end.new
16
+ case Rails::VERSION::MAJOR
17
+ when 5
18
+ rails5_action_view_instance
19
+ when 6
20
+ rails6_action_view_instance
21
+ end
12
22
  end
13
23
 
14
24
  describe "#enable_unit" do
15
25
  it "forces to enable specified unit" do
16
26
  enable_unit(:inactive_unit)
17
- view.invoke(:inactive_unit, :inactive, :type => :plain).should == "inactive"
27
+ expect(view.invoke(:inactive_unit, :inactive, :type => :plain)).to eq("inactive")
18
28
  end
19
29
  end
20
30
 
21
31
  describe "#disable_unit" do
22
32
  it "forces to disable specified unit" do
23
33
  disable_unit(:example_unit)
24
- view.invoke(:example_unit, :test).should == nil
34
+ expect(view.invoke(:example_unit, :test)).to eq(nil)
25
35
  end
26
36
  end
27
37
  end
@@ -13,7 +13,7 @@ module Chanko
13
13
  "test"
14
14
  end
15
15
  end
16
- ExampleClass.new.test.should == "test"
16
+ expect(ExampleClass.new.test).to eq("test")
17
17
  end
18
18
 
19
19
  it "extends class methods" do
@@ -24,7 +24,7 @@ module Chanko
24
24
  end
25
25
  end
26
26
  end
27
- ExampleClass.test.should == "test"
27
+ expect(ExampleClass.test).to eq("test")
28
28
  end
29
29
 
30
30
  it "extends instance methods with prefix" do
@@ -33,7 +33,7 @@ module Chanko
33
33
  "test"
34
34
  end
35
35
  end
36
- ExampleClass.new.__prefix_test.should == "test"
36
+ expect(ExampleClass.new.__prefix_test).to eq("test")
37
37
  end
38
38
  end
39
39
  end
@@ -7,28 +7,28 @@ module Chanko
7
7
  context "when identifier is a class" do
8
8
  it "returns identifier with no change" do
9
9
  identifier = ActionView::Base
10
- described_class.find(identifier).should == ActionView::Base
10
+ expect(described_class.find(identifier)).to eq(ActionView::Base)
11
11
  end
12
12
  end
13
13
 
14
14
  context "when identifier is a reserved label" do
15
15
  it "returns reserved class for that" do
16
16
  identifier = :view
17
- described_class.find(identifier).should == ActionView::Base
17
+ expect(described_class.find(identifier)).to eq(ActionView::Base)
18
18
  end
19
19
  end
20
20
 
21
21
  context "when identifier is a string that means a class" do
22
22
  it "returns class of that string" do
23
23
  identifier = "ActionView::Base"
24
- described_class.find(identifier).should == ActionView::Base
24
+ expect(described_class.find(identifier)).to eq(ActionView::Base)
25
25
  end
26
26
  end
27
27
 
28
28
  context "when no class is found" do
29
29
  it "returns nil" do
30
30
  identifier = "Non::Existent::Class"
31
- described_class.find(identifier).should == nil
31
+ expect(described_class.find(identifier)).to eq(nil)
32
32
  end
33
33
  end
34
34
  end
@@ -10,8 +10,8 @@ module Chanko
10
10
  context "when given unit name" do
11
11
  it "returns proxy for specified unit" do
12
12
  proxy = view.unit(:example_unit)
13
- proxy.should be_a UnitProxy
14
- proxy.unit.should == ExampleUnit
13
+ expect(proxy).to be_a UnitProxy
14
+ expect(proxy.unit).to eq(ExampleUnit)
15
15
  end
16
16
  end
17
17
 
@@ -26,7 +26,7 @@ module Chanko
26
26
 
27
27
  it "returns proxy for the top unit of current unit stack" do
28
28
  proxy = view.unit
29
- proxy.unit.should == ExampleUnit
29
+ expect(proxy.unit).to eq(ExampleUnit)
30
30
  end
31
31
  end
32
32
 
@@ -39,10 +39,10 @@ module Chanko
39
39
  end
40
40
 
41
41
  it "change this method name with it" do
42
- view.should_not be_respond_to(:proxy)
42
+ expect(view).not_to be_respond_to(:proxy)
43
43
  proxy = view.proxy(:example_unit)
44
- proxy.should be_a UnitProxy
45
- view.should be_respond_to(:proxy)
44
+ expect(proxy).to be_a UnitProxy
45
+ expect(view).to be_respond_to(:proxy)
46
46
  end
47
47
  end
48
48
 
@@ -55,12 +55,12 @@ module Chanko
55
55
  end
56
56
 
57
57
  it "change this method name with it" do
58
- view.should_not be_respond_to(:proxy1)
59
- view.should_not be_respond_to(:proxy2)
60
- view.proxy1(:example_unit).should be_a UnitProxy
61
- view.proxy2(:example_unit).should be_a UnitProxy
62
- view.should be_respond_to(:proxy1)
63
- view.should be_respond_to(:proxy2)
58
+ expect(view).not_to be_respond_to(:proxy1)
59
+ expect(view).not_to be_respond_to(:proxy2)
60
+ expect(view.proxy1(:example_unit)).to be_a UnitProxy
61
+ expect(view.proxy2(:example_unit)).to be_a UnitProxy
62
+ expect(view).to be_respond_to(:proxy1)
63
+ expect(view).to be_respond_to(:proxy2)
64
64
  end
65
65
  end
66
66
  end
@@ -8,14 +8,14 @@ module Chanko
8
8
 
9
9
  describe "#active?" do
10
10
  it "returns activation status of unit" do
11
- view.unit(:example_unit).should be_active
12
- view.unit(:inactive_unit).should_not be_active
11
+ expect(view.unit(:example_unit)).to be_active
12
+ expect(view.unit(:inactive_unit)).not_to be_active
13
13
  end
14
14
  end
15
15
 
16
16
  describe "#method_missing" do
17
17
  it "calls prefixed method" do
18
- view.should_receive(:__example_unit_test)
18
+ expect(view).to receive(:__example_unit_test)
19
19
  view.unit(:example_unit).test
20
20
  end
21
21
  end