okuribito_rails 0.0.2 → 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.
- checksums.yaml +4 -4
- data/README.md +4 -6
- data/app/assets/images/okuribito_rails/logo.png +0 -0
- data/app/assets/stylesheets/okuribito_rails/application.css +11 -0
- data/app/assets/stylesheets/okuribito_rails/header.css +39 -0
- data/app/assets/stylesheets/okuribito_rails/method_call_info.css +0 -1
- data/app/controllers/okuribito_rails/application_controller.rb +19 -0
- data/app/models/okuribito_rails/method_call_log.rb +1 -1
- data/app/views/layouts/okuribito_rails/_header.html.erb +9 -0
- data/app/views/layouts/okuribito_rails/application.html.erb +4 -1
- data/app/views/okuribito_rails/method_call_situations/index.html.erb +2 -6
- data/lib/generators/okuribito_rails/templates/initializer.erb +6 -0
- data/lib/okuribito_rails/config.rb +15 -2
- data/lib/okuribito_rails/observe_method.rb +18 -11
- data/lib/okuribito_rails/railtie.rb +2 -14
- data/lib/okuribito_rails/regist_method.rb +15 -13
- data/lib/okuribito_rails/start_observer.rb +39 -0
- data/lib/okuribito_rails/version.rb +1 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +131 -0
- data/spec/dummy/log/test.log +26561 -0
- data/spec/factories.rb +6 -6
- data/spec/lib/okuribito_rails/observe_method_spec.rb +33 -0
- data/spec/lib/okuribito_rails/regist_method_spec.rb +40 -0
- data/spec/lib/okuribito_rails/start_observer_spec.rb +36 -0
- data/spec/models/method_call_log_spec.rb +5 -5
- data/spec/models/method_call_situation_spec.rb +5 -5
- data/spec/spec_helper.rb +16 -0
- data/spec/support/test_config.yml +3 -0
- data/spec/support/test_target.rb +5 -0
- metadata +33 -6
data/spec/factories.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :method_call_situation, class: OkuribitoRails::MethodCallSituation do
|
3
|
-
class_name "
|
4
|
-
method_symbol "
|
5
|
-
method_name "
|
3
|
+
class_name "TestTarget"
|
4
|
+
method_symbol "#"
|
5
|
+
method_name "deprecated_method"
|
6
6
|
called_num 0
|
7
7
|
end
|
8
8
|
|
9
9
|
factory :method_call_log, class: OkuribitoRails::MethodCallLog do
|
10
|
-
class_name "
|
11
|
-
method_symbol "
|
12
|
-
method_name "
|
10
|
+
class_name "TestTarget"
|
11
|
+
method_symbol "#"
|
12
|
+
method_name "deprecated_method"
|
13
13
|
end
|
14
14
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "support/test_target"
|
3
|
+
|
4
|
+
describe OkuribitoRails::ObserveMethod do
|
5
|
+
let(:setting_path) { "spec/support/test_config.yml" }
|
6
|
+
|
7
|
+
describe "create MethodCallLog" do
|
8
|
+
before do
|
9
|
+
allow_any_instance_of(OkuribitoRails::ObserveMethod).to receive(:config_once_detect).and_return(true)
|
10
|
+
FactoryGirl.create(:method_call_situation)
|
11
|
+
okuribito = OkuribitoRails::ObserveMethod.new.patch_okuribito
|
12
|
+
okuribito.apply(setting_path)
|
13
|
+
end
|
14
|
+
|
15
|
+
subject { OkuribitoRails::MethodCallLog.count }
|
16
|
+
|
17
|
+
context "call patched method" do
|
18
|
+
before do
|
19
|
+
TestTarget.new.deprecated_method
|
20
|
+
end
|
21
|
+
|
22
|
+
it { is_expected.to eq 1 }
|
23
|
+
end
|
24
|
+
|
25
|
+
context "call unpatched method" do
|
26
|
+
before do
|
27
|
+
TestTarget.deprecated_self_method
|
28
|
+
end
|
29
|
+
|
30
|
+
it { is_expected.to eq 0 }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "support/test_target"
|
3
|
+
|
4
|
+
shared_examples "Evaluate the condition of MethodCallSituation" do
|
5
|
+
it { expect(OkuribitoRails::MethodCallSituation.find_by(class_name: "TestTarget", method_symbol: ".", method_name: "deprecated_self_method")).to be_present }
|
6
|
+
it { expect(OkuribitoRails::MethodCallSituation.find_by(class_name: "TestTarget", method_symbol: "#", method_name: "deprecated_method")).to be_present }
|
7
|
+
end
|
8
|
+
|
9
|
+
describe OkuribitoRails::RegistMethod do
|
10
|
+
let(:setting_path) { "spec/support/test_config.yml" }
|
11
|
+
|
12
|
+
describe "create MethodCallSituation" do
|
13
|
+
context "registered none" do
|
14
|
+
before do
|
15
|
+
OkuribitoRails::RegistMethod.new.update_observe_methods(setting_path)
|
16
|
+
end
|
17
|
+
|
18
|
+
it_behaves_like "Evaluate the condition of MethodCallSituation"
|
19
|
+
end
|
20
|
+
|
21
|
+
context "registered one (Already registered)" do
|
22
|
+
before do
|
23
|
+
FactoryGirl.create(:method_call_situation, class_name: "TestTarget", method_symbol: "#", method_name: "deprecated_method")
|
24
|
+
OkuribitoRails::RegistMethod.new.update_observe_methods(setting_path)
|
25
|
+
end
|
26
|
+
|
27
|
+
it_behaves_like "Evaluate the condition of MethodCallSituation"
|
28
|
+
end
|
29
|
+
|
30
|
+
context "registered one (Delete target)" do
|
31
|
+
before do
|
32
|
+
FactoryGirl.create(:method_call_situation, class_name: "TestTarget", method_symbol: "#", method_name: "delete_target_method")
|
33
|
+
OkuribitoRails::RegistMethod.new.update_observe_methods(setting_path)
|
34
|
+
end
|
35
|
+
|
36
|
+
it_behaves_like "Evaluate the condition of MethodCallSituation"
|
37
|
+
it { expect(OkuribitoRails::MethodCallSituation.find_by(class_name: "TestTarget", method_symbol: "#", method_name: "delete_target_method")).not_to be_present }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe OkuribitoRails::StartObserver do
|
4
|
+
describe "#start" do
|
5
|
+
let(:prohibit_env) { false }
|
6
|
+
let(:before_migrate) { false }
|
7
|
+
let(:setting_path) { "spec/support/test_config.yml" }
|
8
|
+
let(:start_observer) { OkuribitoRails::StartObserver.new }
|
9
|
+
|
10
|
+
before do
|
11
|
+
allow(start_observer).to receive(:prohibit_env?).and_return(prohibit_env)
|
12
|
+
allow(start_observer).to receive(:before_migrate?).and_return(before_migrate)
|
13
|
+
allow(start_observer).to receive(:setting_path).and_return(setting_path)
|
14
|
+
allow(start_observer).to receive(:regist_method)
|
15
|
+
allow(start_observer).to receive(:start_observer)
|
16
|
+
start_observer.start
|
17
|
+
end
|
18
|
+
|
19
|
+
context "allowed env / after_migrate" do
|
20
|
+
it { expect(start_observer).to have_received(:regist_method) }
|
21
|
+
it { expect(start_observer).to have_received(:start_observer) }
|
22
|
+
end
|
23
|
+
|
24
|
+
context "prohibited env" do
|
25
|
+
let(:prohibit_env) { true }
|
26
|
+
it { expect(start_observer).not_to have_received(:regist_method) }
|
27
|
+
it { expect(start_observer).not_to have_received(:start_observer) }
|
28
|
+
end
|
29
|
+
|
30
|
+
context "before_migrate" do
|
31
|
+
let(:before_migrate) { true }
|
32
|
+
it { expect(start_observer).not_to have_received(:regist_method) }
|
33
|
+
it { expect(start_observer).not_to have_received(:start_observer) }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -9,9 +9,9 @@ describe OkuribitoRails::MethodCallLog do
|
|
9
9
|
method_symbol: method_symbol,
|
10
10
|
method_name: method_name)
|
11
11
|
end
|
12
|
-
let(:class_name) { "
|
13
|
-
let(:method_symbol) { "
|
14
|
-
let(:method_name) { "
|
12
|
+
let(:class_name) { "TestTarget" }
|
13
|
+
let(:method_symbol) { "#" }
|
14
|
+
let(:method_name) { "deprecated_method" }
|
15
15
|
|
16
16
|
subject { method_call_log }
|
17
17
|
|
@@ -24,7 +24,7 @@ describe OkuribitoRails::MethodCallLog do
|
|
24
24
|
it { is_expected.to be_valid }
|
25
25
|
|
26
26
|
context "with valid long name" do
|
27
|
-
let(:class_name) { "a" *
|
27
|
+
let(:class_name) { "A" << "a" * 254 }
|
28
28
|
it { is_expected.to be_valid }
|
29
29
|
end
|
30
30
|
end
|
@@ -41,7 +41,7 @@ describe OkuribitoRails::MethodCallLog do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
context "with too long name" do
|
44
|
-
let(:class_name) { "a" *
|
44
|
+
let(:class_name) { "A" << "a" * 255 }
|
45
45
|
it { is_expected.not_to be_valid }
|
46
46
|
end
|
47
47
|
end
|
@@ -8,9 +8,9 @@ describe OkuribitoRails::MethodCallSituation do
|
|
8
8
|
method_name: method_name,
|
9
9
|
called_num: called_num)
|
10
10
|
end
|
11
|
-
let(:class_name) { "
|
12
|
-
let(:method_symbol) { "
|
13
|
-
let(:method_name) { "
|
11
|
+
let(:class_name) { "TestTarget" }
|
12
|
+
let(:method_symbol) { "#" }
|
13
|
+
let(:method_name) { "deprecated_method" }
|
14
14
|
let(:called_num) { 0 }
|
15
15
|
|
16
16
|
subject { method_call_situation }
|
@@ -19,7 +19,7 @@ describe OkuribitoRails::MethodCallSituation do
|
|
19
19
|
it { is_expected.to be_valid }
|
20
20
|
|
21
21
|
context "with valid long name" do
|
22
|
-
let(:class_name) { "a" *
|
22
|
+
let(:class_name) { "A" << "a" * 254 }
|
23
23
|
it { is_expected.to be_valid }
|
24
24
|
end
|
25
25
|
end
|
@@ -36,7 +36,7 @@ describe OkuribitoRails::MethodCallSituation do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
context "with too long name" do
|
39
|
-
let(:class_name) { "a" *
|
39
|
+
let(:class_name) { "A" << "a" * 255 }
|
40
40
|
it { is_expected.not_to be_valid }
|
41
41
|
end
|
42
42
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -12,3 +12,19 @@ require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
|
12
12
|
require "rspec/rails"
|
13
13
|
require "factory_girl"
|
14
14
|
require "factories"
|
15
|
+
|
16
|
+
require 'database_cleaner'
|
17
|
+
|
18
|
+
RSpec.configure do |config|
|
19
|
+
config.before(:suite) do
|
20
|
+
DatabaseCleaner.strategy = :truncation
|
21
|
+
end
|
22
|
+
|
23
|
+
config.before(:each) do
|
24
|
+
DatabaseCleaner.start
|
25
|
+
end
|
26
|
+
|
27
|
+
config.after(:each) do
|
28
|
+
DatabaseCleaner.clean
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: okuribito_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yasuhiro Matsumura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: okuribito
|
@@ -114,6 +114,20 @@ dependencies:
|
|
114
114
|
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: database_cleaner
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
117
131
|
- !ruby/object:Gem::Dependency
|
118
132
|
name: rubocop
|
119
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,8 +170,8 @@ dependencies:
|
|
156
170
|
- - "~>"
|
157
171
|
- !ruby/object:Gem::Version
|
158
172
|
version: 1.0.0
|
159
|
-
description: OkuribitoRails is an engine for Rails that aims to
|
160
|
-
|
173
|
+
description: OkuribitoRails is an engine for Rails that aims to manage method call
|
174
|
+
status.
|
161
175
|
email:
|
162
176
|
- ym.contributor@gmail.com
|
163
177
|
executables: []
|
@@ -167,8 +181,10 @@ files:
|
|
167
181
|
- MIT-LICENSE
|
168
182
|
- README.md
|
169
183
|
- Rakefile
|
184
|
+
- app/assets/images/okuribito_rails/logo.png
|
170
185
|
- app/assets/javascripts/okuribito_rails/application.js
|
171
186
|
- app/assets/stylesheets/okuribito_rails/application.css
|
187
|
+
- app/assets/stylesheets/okuribito_rails/header.css
|
172
188
|
- app/assets/stylesheets/okuribito_rails/method_call_info.css
|
173
189
|
- app/controllers/okuribito_rails/application_controller.rb
|
174
190
|
- app/controllers/okuribito_rails/method_call_logs_controller.rb
|
@@ -176,6 +192,7 @@ files:
|
|
176
192
|
- app/helpers/okuribito_rails/application_helper.rb
|
177
193
|
- app/models/okuribito_rails/method_call_log.rb
|
178
194
|
- app/models/okuribito_rails/method_call_situation.rb
|
195
|
+
- app/views/layouts/okuribito_rails/_header.html.erb
|
179
196
|
- app/views/layouts/okuribito_rails/application.html.erb
|
180
197
|
- app/views/okuribito_rails/method_call_logs/index.html.erb
|
181
198
|
- app/views/okuribito_rails/method_call_situations/index.html.erb
|
@@ -190,6 +207,7 @@ files:
|
|
190
207
|
- lib/okuribito_rails/observe_method.rb
|
191
208
|
- lib/okuribito_rails/railtie.rb
|
192
209
|
- lib/okuribito_rails/regist_method.rb
|
210
|
+
- lib/okuribito_rails/start_observer.rb
|
193
211
|
- lib/okuribito_rails/version.rb
|
194
212
|
- lib/tasks/okuribito_rails_tasks.rake
|
195
213
|
- spec/dummy/Rakefile
|
@@ -248,9 +266,14 @@ files:
|
|
248
266
|
- spec/dummy/public/apple-touch-icon.png
|
249
267
|
- spec/dummy/public/favicon.ico
|
250
268
|
- spec/factories.rb
|
269
|
+
- spec/lib/okuribito_rails/observe_method_spec.rb
|
270
|
+
- spec/lib/okuribito_rails/regist_method_spec.rb
|
271
|
+
- spec/lib/okuribito_rails/start_observer_spec.rb
|
251
272
|
- spec/models/method_call_log_spec.rb
|
252
273
|
- spec/models/method_call_situation_spec.rb
|
253
274
|
- spec/spec_helper.rb
|
275
|
+
- spec/support/test_config.yml
|
276
|
+
- spec/support/test_target.rb
|
254
277
|
homepage: https://github.com/muramurasan/okuribito_rails
|
255
278
|
licenses: []
|
256
279
|
metadata: {}
|
@@ -273,8 +296,7 @@ rubyforge_project:
|
|
273
296
|
rubygems_version: 2.5.1
|
274
297
|
signing_key:
|
275
298
|
specification_version: 4
|
276
|
-
summary: OkuribitoRails is an engine for Rails that aims to
|
277
|
-
call status.
|
299
|
+
summary: OkuribitoRails is an engine for Rails that aims to manage method call status.
|
278
300
|
test_files:
|
279
301
|
- spec/dummy/app/assets/config/manifest.js
|
280
302
|
- spec/dummy/app/assets/javascripts/application.js
|
@@ -332,6 +354,11 @@ test_files:
|
|
332
354
|
- spec/dummy/public/favicon.ico
|
333
355
|
- spec/dummy/Rakefile
|
334
356
|
- spec/factories.rb
|
357
|
+
- spec/lib/okuribito_rails/observe_method_spec.rb
|
358
|
+
- spec/lib/okuribito_rails/regist_method_spec.rb
|
359
|
+
- spec/lib/okuribito_rails/start_observer_spec.rb
|
335
360
|
- spec/models/method_call_log_spec.rb
|
336
361
|
- spec/models/method_call_situation_spec.rb
|
337
362
|
- spec/spec_helper.rb
|
363
|
+
- spec/support/test_config.yml
|
364
|
+
- spec/support/test_target.rb
|