delta_test 0.1.0 → 0.2.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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +32 -0
  3. data/README.md +63 -14
  4. data/Rakefile +16 -3
  5. data/circle.yml +8 -1
  6. data/delta_test.gemspec +4 -3
  7. data/ext/delta_test/delta_test_native.c +154 -0
  8. data/ext/delta_test/delta_test_native.h +15 -0
  9. data/ext/delta_test/extconf.rb +12 -0
  10. data/lib/delta_test.rb +8 -2
  11. data/lib/delta_test/cli.rb +108 -21
  12. data/lib/delta_test/configuration.rb +91 -35
  13. data/lib/delta_test/dependencies_table.rb +15 -1
  14. data/lib/delta_test/generator.rb +42 -29
  15. data/lib/delta_test/profiler.rb +5 -0
  16. data/lib/delta_test/related_spec_list.rb +67 -8
  17. data/lib/delta_test/spec_helpers.rb +9 -7
  18. data/lib/delta_test/version.rb +1 -1
  19. data/spec/lib/delta_test/cli_spec.rb +26 -5
  20. data/spec/lib/delta_test/configuration_spec.rb +12 -0
  21. data/spec/lib/delta_test/dependencies_table_spec.rb +35 -0
  22. data/spec/lib/delta_test/generator_spec.rb +34 -17
  23. data/spec/lib/delta_test/profiler_spec.rb +121 -0
  24. data/spec/lib/delta_test/related_spec_list_spec.rb +150 -34
  25. data/spec/lib/delta_test/spec_helpers_spec.rb +11 -5
  26. data/spec/rails/Gemfile +8 -2
  27. data/spec/rails/Gemfile.lock +37 -3
  28. data/spec/rails/app/models/category.rb +14 -0
  29. data/spec/rails/app/models/comment.rb +20 -0
  30. data/spec/rails/app/models/post.rb +23 -0
  31. data/spec/rails/app/models/post_categorizing.rb +14 -0
  32. data/spec/rails/app/models/user.rb +15 -0
  33. data/spec/rails/db/migrate/20150518052022_create_users.rb +9 -0
  34. data/spec/rails/db/migrate/20150518052057_create_posts.rb +11 -0
  35. data/spec/rails/db/migrate/20150518052332_create_comments.rb +11 -0
  36. data/spec/rails/db/migrate/20150518052523_create_categories.rb +9 -0
  37. data/spec/rails/db/migrate/20150518052604_create_post_categorizings.rb +10 -0
  38. data/spec/rails/db/schema.rb +59 -0
  39. data/spec/rails/spec/factories/categories.rb +5 -0
  40. data/spec/rails/spec/factories/comments.rb +8 -0
  41. data/spec/rails/spec/factories/post_categorizings.rb +6 -0
  42. data/spec/rails/spec/factories/posts.rb +7 -0
  43. data/spec/rails/spec/factories/users.rb +5 -0
  44. data/spec/rails/spec/models/category_spec.rb +3 -0
  45. data/spec/rails/spec/models/comment_spec.rb +3 -0
  46. data/spec/rails/spec/models/post_categorizing_spec.rb +3 -0
  47. data/spec/rails/spec/models/post_spec.rb +3 -0
  48. data/spec/rails/spec/models/user_spec.rb +20 -0
  49. data/spec/rails/spec/spec_helper.rb +53 -9
  50. data/spec/spec_helper.rb +2 -0
  51. metadata +79 -19
  52. data/lib/delta_test/analyzer.rb +0 -47
  53. data/spec/lib/delta_test/analyzer_spec.rb +0 -126
@@ -1,47 +0,0 @@
1
- require 'ruby-prof'
2
-
3
- module DeltaTest
4
- class Analyzer
5
-
6
- attr_reader :result
7
-
8
- ###
9
- # Start analyzer
10
- ###
11
- def start
12
- @result = nil
13
- @files = Set.new
14
-
15
- RubyProf.stop if RubyProf.running?
16
- RubyProf.start
17
- end
18
-
19
- ###
20
- # Stop analyzer
21
- ###
22
- def stop
23
- @result = nil
24
- @result = RubyProf.stop if RubyProf.running?
25
- end
26
-
27
- ###
28
- # Gather source files in the call stack
29
- #
30
- # @return {Set<String>}
31
- ###
32
- def related_source_files
33
- return @files unless @result
34
-
35
- @result.threads.each do |thread|
36
- thread.methods.each do |method|
37
- @files << method.source_file
38
- end
39
- end
40
-
41
- @result = nil
42
-
43
- @files
44
- end
45
-
46
- end
47
- end
@@ -1,126 +0,0 @@
1
- require 'delta_test/analyzer'
2
-
3
- describe DeltaTest::Analyzer do
4
-
5
- let(:analyzer) { DeltaTest::Analyzer.new }
6
-
7
- after do
8
- RubyProf.stop if RubyProf.running?
9
- end
10
-
11
- describe '#new' do
12
-
13
- it 'should initialize new instance' do
14
- expect { analyzer }.not_to raise_error
15
- end
16
-
17
- end
18
-
19
- describe '#start' do
20
-
21
- it 'should start ruby-prof' do
22
- expect(RubyProf.running?).to be(false)
23
-
24
- expect {
25
- analyzer.start
26
- }.not_to raise_error
27
-
28
- expect(RubyProf.running?).to be(true)
29
- end
30
-
31
- end
32
-
33
- describe '#stop' do
34
-
35
- it 'should not raise error if `start` is not yet called' do
36
- expect {
37
- analyzer.stop
38
- }.not_to raise_error
39
- end
40
-
41
- it 'should set result' do
42
- analyzer.start
43
-
44
- expect(analyzer.result).to be_nil
45
-
46
- expect {
47
- analyzer.stop
48
- }.not_to raise_error
49
-
50
- expect(analyzer.result).not_to be_nil
51
- end
52
-
53
- end
54
-
55
- describe '#related_source_files' do
56
-
57
- it 'should retrun nil if not yet started' do
58
- expect(analyzer.related_source_files).to be_nil
59
- end
60
-
61
- it 'should return an empty set unless stop' do
62
- analyzer.start
63
- expect(analyzer.related_source_files).to be_empty
64
- end
65
-
66
- it 'should return a set of source files after stopped' do
67
- analyzer.start
68
- analyzer.stop
69
- expect(analyzer.related_source_files).not_to be_empty
70
- end
71
-
72
- describe 'Source files' do
73
-
74
- context 'Instantiated class in a file' do
75
-
76
- it 'should not include the file' do
77
- analyzer.start
78
- Sample::Alpha.new
79
- analyzer.stop
80
- expect(analyzer.related_source_files).not_to include(fixture_path('sample/alpha.rb'))
81
- expect(analyzer.related_source_files).not_to include(fixture_path('sample/beta.rb'))
82
- expect(analyzer.related_source_files).not_to include(fixture_path('sample/gamma.rb'))
83
- end
84
-
85
- end
86
-
87
- context 'Called some instance methods of a class in the file' do
88
-
89
- it 'should include the file' do
90
- analyzer.start
91
- Sample::Alpha.new.alpha
92
- analyzer.stop
93
- expect(analyzer.related_source_files).to include(fixture_path('sample/alpha.rb'))
94
- expect(analyzer.related_source_files).not_to include(fixture_path('sample/beta.rb'))
95
- expect(analyzer.related_source_files).not_to include(fixture_path('sample/gamma.rb'))
96
- end
97
-
98
- end
99
-
100
- context 'Called methods that uses extarnal classes' do
101
-
102
- it 'should include a extarnal file' do
103
- analyzer.start
104
- Sample::Alpha.new.beta
105
- analyzer.stop
106
- expect(analyzer.related_source_files).to include(fixture_path('sample/alpha.rb'))
107
- expect(analyzer.related_source_files).to include(fixture_path('sample/beta.rb'))
108
- expect(analyzer.related_source_files).not_to include(fixture_path('sample/gamma.rb'))
109
- end
110
-
111
- it 'should include extarnal files even if nested' do
112
- analyzer.start
113
- Sample::Alpha.new.beta_gamma
114
- analyzer.stop
115
- expect(analyzer.related_source_files).to include(fixture_path('sample/alpha.rb'))
116
- expect(analyzer.related_source_files).to include(fixture_path('sample/beta.rb'))
117
- expect(analyzer.related_source_files).to include(fixture_path('sample/gamma.rb'))
118
- end
119
-
120
- end
121
-
122
- end
123
-
124
- end
125
-
126
- end