mutant 0.3.0.beta21 → 0.3.0.beta22

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 (223) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +37 -6
  3. data/.rspec +2 -0
  4. data/.ruby-gemset +1 -0
  5. data/.travis.yml +13 -7
  6. data/Gemfile +8 -3
  7. data/Gemfile.devtools +2 -6
  8. data/Guardfile +22 -8
  9. data/README.md +3 -1
  10. data/Rakefile +3 -0
  11. data/bin/mutant +4 -3
  12. data/config/devtools.yml +1 -1
  13. data/config/flay.yml +1 -1
  14. data/config/flog.yml +1 -1
  15. data/config/reek.yml +7 -6
  16. data/config/rubocop.yml +55 -0
  17. data/lib/mutant.rb +3 -1
  18. data/lib/mutant/cache.rb +2 -0
  19. data/lib/mutant/cli.rb +14 -10
  20. data/lib/mutant/cli/classifier.rb +22 -10
  21. data/lib/mutant/cli/classifier/method.rb +14 -15
  22. data/lib/mutant/cli/classifier/namespace.rb +6 -2
  23. data/lib/mutant/cli/classifier/scope.rb +3 -1
  24. data/lib/mutant/color.rb +7 -3
  25. data/lib/mutant/config.rb +2 -0
  26. data/lib/mutant/constants.rb +5 -4
  27. data/lib/mutant/context.rb +2 -0
  28. data/lib/mutant/context/scope.rb +3 -1
  29. data/lib/mutant/differ.rb +10 -2
  30. data/lib/mutant/killer.rb +4 -1
  31. data/lib/mutant/killer/forked.rb +2 -0
  32. data/lib/mutant/killer/forking.rb +2 -0
  33. data/lib/mutant/killer/rspec.rb +19 -3
  34. data/lib/mutant/killer/static.rb +2 -0
  35. data/lib/mutant/loader.rb +8 -1
  36. data/lib/mutant/matcher.rb +2 -0
  37. data/lib/mutant/matcher/chain.rb +2 -0
  38. data/lib/mutant/matcher/method.rb +15 -3
  39. data/lib/mutant/matcher/method/finder.rb +2 -0
  40. data/lib/mutant/matcher/method/instance.rb +4 -1
  41. data/lib/mutant/matcher/method/singleton.rb +7 -1
  42. data/lib/mutant/matcher/methods.rb +3 -1
  43. data/lib/mutant/matcher/namespace.rb +4 -2
  44. data/lib/mutant/matcher/scope.rb +2 -0
  45. data/lib/mutant/mutation.rb +19 -5
  46. data/lib/mutant/mutation/evil.rb +12 -0
  47. data/lib/mutant/mutation/filter.rb +2 -0
  48. data/lib/mutant/mutation/filter/code.rb +3 -1
  49. data/lib/mutant/mutation/filter/regexp.rb +2 -0
  50. data/lib/mutant/mutation/filter/whitelist.rb +2 -0
  51. data/lib/mutant/mutation/neutral.rb +25 -0
  52. data/lib/mutant/mutator.rb +4 -6
  53. data/lib/mutant/mutator/node.rb +5 -1
  54. data/lib/mutant/mutator/node/argument.rb +2 -0
  55. data/lib/mutant/mutator/node/arguments.rb +2 -0
  56. data/lib/mutant/mutator/node/begin.rb +2 -0
  57. data/lib/mutant/mutator/node/block.rb +2 -0
  58. data/lib/mutant/mutator/node/case.rb +3 -1
  59. data/lib/mutant/mutator/node/connective/binary.rb +3 -1
  60. data/lib/mutant/mutator/node/const.rb +2 -0
  61. data/lib/mutant/mutator/node/define.rb +2 -0
  62. data/lib/mutant/mutator/node/generic.rb +4 -3
  63. data/lib/mutant/mutator/node/if.rb +2 -0
  64. data/lib/mutant/mutator/node/literal.rb +2 -0
  65. data/lib/mutant/mutator/node/literal/array.rb +2 -0
  66. data/lib/mutant/mutator/node/literal/boolean.rb +2 -0
  67. data/lib/mutant/mutator/node/literal/dynamic.rb +2 -0
  68. data/lib/mutant/mutator/node/literal/fixnum.rb +3 -1
  69. data/lib/mutant/mutator/node/literal/float.rb +2 -0
  70. data/lib/mutant/mutator/node/literal/hash.rb +2 -0
  71. data/lib/mutant/mutator/node/literal/nil.rb +2 -0
  72. data/lib/mutant/mutator/node/literal/range.rb +2 -1
  73. data/lib/mutant/mutator/node/literal/regex.rb +2 -0
  74. data/lib/mutant/mutator/node/literal/string.rb +2 -0
  75. data/lib/mutant/mutator/node/literal/symbol.rb +5 -1
  76. data/lib/mutant/mutator/node/masgn.rb +2 -0
  77. data/lib/mutant/mutator/node/mlhs.rb +2 -0
  78. data/lib/mutant/mutator/node/named_value/access.rb +2 -0
  79. data/lib/mutant/mutator/node/named_value/constant_assignment.rb +2 -0
  80. data/lib/mutant/mutator/node/named_value/variable_assignment.rb +3 -1
  81. data/lib/mutant/mutator/node/{cbase.rb → noop.rb} +7 -5
  82. data/lib/mutant/mutator/node/return.rb +2 -0
  83. data/lib/mutant/mutator/node/send.rb +2 -0
  84. data/lib/mutant/mutator/node/send/binary.rb +2 -0
  85. data/lib/mutant/mutator/node/splat.rb +2 -0
  86. data/lib/mutant/mutator/node/super.rb +2 -0
  87. data/lib/mutant/mutator/node/when.rb +3 -1
  88. data/lib/mutant/mutator/node/while.rb +2 -0
  89. data/lib/mutant/mutator/node/zsuper.rb +2 -0
  90. data/lib/mutant/mutator/registry.rb +55 -13
  91. data/lib/mutant/mutator/util.rb +2 -0
  92. data/lib/mutant/mutator/util/array.rb +3 -1
  93. data/lib/mutant/mutator/util/symbol.rb +2 -0
  94. data/lib/mutant/node_helpers.rb +10 -4
  95. data/lib/mutant/random.rb +2 -0
  96. data/lib/mutant/reporter.rb +2 -0
  97. data/lib/mutant/reporter/cli.rb +2 -0
  98. data/lib/mutant/reporter/cli/printer.rb +2 -0
  99. data/lib/mutant/reporter/cli/printer/config.rb +5 -2
  100. data/lib/mutant/reporter/cli/printer/killer.rb +2 -0
  101. data/lib/mutant/reporter/cli/printer/mutation.rb +13 -6
  102. data/lib/mutant/reporter/cli/printer/subject.rb +5 -1
  103. data/lib/mutant/reporter/null.rb +2 -0
  104. data/lib/mutant/runner.rb +2 -0
  105. data/lib/mutant/runner/config.rb +2 -0
  106. data/lib/mutant/runner/mutation.rb +2 -0
  107. data/lib/mutant/runner/subject.rb +2 -0
  108. data/lib/mutant/singleton_methods.rb +5 -3
  109. data/lib/mutant/strategy.rb +2 -0
  110. data/lib/mutant/strategy/method_expansion.rb +2 -0
  111. data/lib/mutant/strategy/rspec.rb +2 -0
  112. data/lib/mutant/strategy/rspec/dm2.rb +2 -0
  113. data/lib/mutant/strategy/rspec/dm2/lookup.rb +4 -2
  114. data/lib/mutant/strategy/rspec/dm2/lookup/method.rb +2 -0
  115. data/lib/mutant/strategy/static.rb +2 -0
  116. data/lib/mutant/subject.rb +4 -1
  117. data/lib/mutant/subject/method.rb +2 -0
  118. data/lib/mutant/subject/method/instance.rb +2 -0
  119. data/lib/mutant/subject/method/singleton.rb +2 -0
  120. data/lib/mutant/support/method_object.rb +2 -0
  121. data/lib/mutant/zombifier.rb +10 -6
  122. data/mutant.gemspec +11 -10
  123. data/spec/integration/mutant/rspec_killer_spec.rb +9 -4
  124. data/spec/integration/mutant/test_mutator_handles_types_spec.rb +3 -1
  125. data/spec/integration/mutant/zombie_spec.rb +2 -0
  126. data/spec/shared/method_matcher_behavior.rb +2 -0
  127. data/spec/shared/mutator_behavior.rb +16 -7
  128. data/spec/spec_helper.rb +26 -5
  129. data/spec/support/compress_helper.rb +5 -5
  130. data/spec/support/ice_nine_config.rb +2 -0
  131. data/spec/support/rspec.rb +2 -0
  132. data/spec/support/test_app.rb +2 -0
  133. data/spec/unit/mutant/class_methods/singleton_subclass_instance_spec.rb +2 -0
  134. data/spec/unit/mutant/cli/class_methods/new_spec.rb +17 -8
  135. data/spec/unit/mutant/cli/class_methods/run_spec.rb +10 -2
  136. data/spec/unit/mutant/cli/classifier/class_methods/build_spec.rb +4 -1
  137. data/spec/unit/mutant/cli/classifier/method/each_spec.rb +89 -0
  138. data/spec/unit/mutant/cli/classifier/namespace/flat/each_spec.rb +58 -0
  139. data/spec/unit/mutant/cli/classifier/namespace/recursive/each_spec.rb +58 -0
  140. data/spec/unit/mutant/cli/classifier/scope/each_spec.rb +33 -0
  141. data/spec/unit/mutant/context/root_spec.rb +5 -1
  142. data/spec/unit/mutant/context/scope/root_spec.rb +2 -0
  143. data/spec/unit/mutant/context/scope/unqualified_name_spec.rb +2 -0
  144. data/spec/unit/mutant/differ/class_methods/build_spec.rb +2 -0
  145. data/spec/unit/mutant/differ/class_methods/colorize_line_spec.rb +2 -0
  146. data/spec/unit/mutant/differ/diff_spec.rb +67 -5
  147. data/spec/unit/mutant/killer/rspec/class_methods/new_spec.rb +21 -4
  148. data/spec/unit/mutant/killer/success_predicate_spec.rb +2 -0
  149. data/spec/unit/mutant/loader/eval/class_methods/run_spec.rb +12 -5
  150. data/spec/unit/mutant/matcher/chain/each_spec.rb +2 -0
  151. data/spec/unit/mutant/matcher/chain/matchers_spec.rb +2 -0
  152. data/spec/unit/mutant/matcher/each_spec.rb +8 -1
  153. data/spec/unit/mutant/matcher/method/instance/class_methods/build_spec.rb +4 -2
  154. data/spec/unit/mutant/matcher/method/instance/each_spec.rb +21 -20
  155. data/spec/unit/mutant/matcher/method/singleton/each_spec.rb +22 -19
  156. data/spec/unit/mutant/matcher/methods/instance/each_spec.rb +8 -3
  157. data/spec/unit/mutant/matcher/methods/singleton/each_spec.rb +8 -3
  158. data/spec/unit/mutant/matcher/namespace/each_spec.rb +8 -2
  159. data/spec/unit/mutant/mutator/each_spec.rb +2 -0
  160. data/spec/unit/mutant/mutator/emit_new_spec.rb +10 -3
  161. data/spec/unit/mutant/mutator/emit_spec.rb +4 -2
  162. data/spec/unit/mutant/mutator/node/and_asgn/mutation_spec.rb +26 -0
  163. data/spec/unit/mutant/mutator/node/begin/mutation_spec.rb +2 -0
  164. data/spec/unit/mutant/mutator/node/block/mutation_spec.rb +4 -2
  165. data/spec/unit/mutant/mutator/node/block_pass/mutation_spec.rb +14 -0
  166. data/spec/unit/mutant/mutator/node/break/mutation_spec.rb +15 -0
  167. data/spec/unit/mutant/mutator/node/case/mutation_spec.rb +2 -0
  168. data/spec/unit/mutant/mutator/node/cbase/mutation_spec.rb +3 -6
  169. data/spec/unit/mutant/mutator/node/connective/binary/mutation_spec.rb +2 -0
  170. data/spec/unit/mutant/mutator/node/const/mutation_spec.rb +3 -6
  171. data/spec/unit/mutant/mutator/node/define/mutation_spec.rb +2 -1
  172. data/spec/unit/mutant/mutator/node/defined_predicate/mutation_spec.rb +10 -0
  173. data/spec/unit/mutant/mutator/node/dstr/mutation_spec.rb +21 -0
  174. data/spec/unit/mutant/mutator/node/dsym/mutation_spec.rb +21 -0
  175. data/spec/unit/mutant/mutator/node/ensure/mutation_spec.rb +15 -0
  176. data/spec/unit/mutant/mutator/node/if/mutation_spec.rb +2 -1
  177. data/spec/unit/mutant/mutator/node/literal/array_spec.rb +2 -0
  178. data/spec/unit/mutant/mutator/node/literal/boolean/mutation_spec.rb +2 -0
  179. data/spec/unit/mutant/mutator/node/literal/fixnum_spec.rb +2 -0
  180. data/spec/unit/mutant/mutator/node/literal/float_spec.rb +4 -2
  181. data/spec/unit/mutant/mutator/node/literal/hash_spec.rb +2 -0
  182. data/spec/unit/mutant/mutator/node/literal/nil_spec.rb +4 -5
  183. data/spec/unit/mutant/mutator/node/literal/range_spec.rb +8 -8
  184. data/spec/unit/mutant/mutator/node/literal/regex_spec.rb +2 -0
  185. data/spec/unit/mutant/mutator/node/literal/string_spec.rb +2 -0
  186. data/spec/unit/mutant/mutator/node/literal/symbol_spec.rb +2 -0
  187. data/spec/unit/mutant/mutator/node/masgn/mutation_spec.rb +4 -10
  188. data/spec/unit/mutant/mutator/node/match_current_line/mutation_spec.rb +20 -0
  189. data/spec/unit/mutant/mutator/node/named_value/access/mutation_spec.rb +3 -2
  190. data/spec/unit/mutant/mutator/node/named_value/constant_assignment/mutation_spec.rb +3 -2
  191. data/spec/unit/mutant/mutator/node/named_value/variable_assignment/mutation_spec.rb +3 -2
  192. data/spec/unit/mutant/mutator/node/next/mutation_spec.rb +15 -0
  193. data/spec/unit/mutant/mutator/node/op_assgn/mutation_spec.rb +26 -0
  194. data/spec/unit/mutant/mutator/node/or_asgn/mutation_spec.rb +26 -0
  195. data/spec/unit/mutant/mutator/node/redo/mutation_spec.rb +10 -0
  196. data/spec/unit/mutant/mutator/node/rescue/mutation_spec.rb +24 -0
  197. data/spec/unit/mutant/mutator/node/restarg/mutation_spec.rb +16 -0
  198. data/spec/unit/mutant/mutator/node/return/mutation_spec.rb +2 -0
  199. data/spec/unit/mutant/mutator/node/send/mutation_spec.rb +3 -1
  200. data/spec/unit/mutant/mutator/node/super/mutation_spec.rb +2 -0
  201. data/spec/unit/mutant/mutator/node/while/mutation_spec.rb +3 -1
  202. data/spec/unit/mutant/mutator/node/yield/mutation_spec.rb +15 -0
  203. data/spec/unit/mutant/node_helpers/n_not_spec.rb +2 -0
  204. data/spec/unit/mutant/runner/config/subjects_spec.rb +6 -2
  205. data/spec/unit/mutant/runner/config/success_predicate_spec.rb +15 -6
  206. data/spec/unit/mutant/runner/mutation/killer_spec.rb +3 -1
  207. data/spec/unit/mutant/runner/subject/success_predicate_spec.rb +15 -8
  208. data/spec/unit/mutant/strategy/method_expansion/class_methods/run_spec.rb +2 -0
  209. data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/instance/spec_files_spec.rb +32 -11
  210. data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/singleton/spec_files_spec.rb +31 -11
  211. data/spec/unit/mutant/subject/context_spec.rb +2 -0
  212. data/spec/unit/mutant/subject/mutations_spec.rb +2 -0
  213. data/spec/unit/mutant/subject/node_spec.rb +2 -0
  214. data/test_app/lib/test_app.rb +2 -0
  215. data/test_app/lib/test_app/literal.rb +2 -0
  216. data/test_app/spec/shared/method_filter_parse_behavior.rb +5 -1
  217. data/test_app/spec/shared/method_match_behavior.rb +2 -0
  218. data/test_app/spec/spec_helper.rb +3 -1
  219. data/test_app/spec/unit/test_app/literal/command_spec.rb +2 -0
  220. data/test_app/spec/unit/test_app/literal/string_spec.rb +3 -1
  221. metadata +66 -18
  222. data/bin/zombie +0 -18
  223. data/test_app/spec/shared/mutator_behavior.rb +0 -44
@@ -1,8 +1,12 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  shared_examples_for 'an invalid cli run' do
4
6
  it 'should raise error' do
5
- expect { subject }.to raise_error(Mutant::CLI::Error, expected_message)
7
+ expect do
8
+ subject
9
+ end.to raise_error(Mutant::CLI::Error, expected_message)
6
10
  end
7
11
  end
8
12
 
@@ -28,6 +32,9 @@ describe Mutant::CLI, '.new' do
28
32
  let(:expected_strategy) { Mutant::Strategy::Rspec::Unit }
29
33
  let(:expected_reporter) { Mutant::Reporter::CLI.new($stdout) }
30
34
 
35
+ let(:ns) { Mutant::CLI::Classifier }
36
+ let(:cache) { Mutant::Cache.new }
37
+
31
38
  let(:cli) { object.new(arguments) }
32
39
 
33
40
  subject { cli }
@@ -70,21 +77,23 @@ describe Mutant::CLI, '.new' do
70
77
  end
71
78
 
72
79
  context 'with explicit method matcher' do
73
- let(:arguments) { %w(--rspec-unit TestApp::Literal#float) }
74
- let(:expected_matcher) { Mutant::CLI::Classifier::Method.new(Mutant::Cache.new, 'TestApp::Literal#float') }
80
+ let(:arguments) { %w(--rspec-unit TestApp::Literal#float) }
81
+ let(:expected_matcher) { ns::Method.new(cache, 'TestApp::Literal#float') }
75
82
 
76
83
  it_should_behave_like 'a cli parser'
77
84
  end
78
85
 
79
86
  context 'with namespace matcher' do
80
- let(:arguments) { %w(--rspec-unit ::TestApp*) }
81
- let(:expected_matcher) { Mutant::CLI::Classifier::Namespace::Recursive.new(Mutant::Cache.new, '::TestApp*') }
87
+ let(:matcher) { '::TestApp*' }
88
+ let(:arguments) { %W(--rspec-unit #{matcher}) }
89
+ let(:expected_matcher) { ns::Namespace::Recursive.new(cache, matcher) }
82
90
 
83
91
  it_should_behave_like 'a cli parser'
84
92
  end
85
93
 
86
94
  context 'with code filter' do
87
- let(:arguments) { %w(--rspec-unit --code faa --code bbb TestApp::Literal#float) }
95
+ let(:matcher) { 'TestApp::Literal#float' }
96
+ let(:arguments) { %W(--rspec-unit --code faa --code bbb #{matcher}) }
88
97
 
89
98
  let(:filters) do
90
99
  [
@@ -93,8 +102,8 @@ describe Mutant::CLI, '.new' do
93
102
  ]
94
103
  end
95
104
 
96
- let(:expected_matcher) { Mutant::CLI::Classifier::Method.new(Mutant::Cache.new, 'TestApp::Literal#float') }
97
- let(:expected_filter) { Mutant::Mutation::Filter::Whitelist.new(filters) }
105
+ let(:expected_matcher) { ns::Method.new(cache, 'TestApp::Literal#float') }
106
+ let(:expected_filter) { Mutant::Mutation::Filter::Whitelist.new(filters) }
98
107
 
99
108
  it_should_behave_like 'a cli parser'
100
109
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::CLI, '.run' do
@@ -21,7 +23,10 @@ describe Mutant::CLI, '.run' do
21
23
  it { should be(0) }
22
24
 
23
25
  it 'should run with attributes' do
24
- Mutant::Runner::Config.should_receive(:run).with(config).and_return(runner)
26
+ Mutant::Runner::Config
27
+ .should_receive(:run)
28
+ .with(config)
29
+ .and_return(runner)
25
30
  should be(0)
26
31
  end
27
32
  end
@@ -32,7 +37,10 @@ describe Mutant::CLI, '.run' do
32
37
  it { should be(1) }
33
38
 
34
39
  it 'should run with attributes' do
35
- Mutant::Runner::Config.should_receive(:run).with(config).and_return(runner)
40
+ Mutant::Runner::Config
41
+ .should_receive(:run)
42
+ .with(config)
43
+ .and_return(runner)
36
44
  should be(1)
37
45
  end
38
46
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::CLI::Classifier, '.build' do
@@ -9,7 +11,8 @@ describe Mutant::CLI::Classifier, '.build' do
9
11
 
10
12
  shared_examples_for this_spec do
11
13
  it 'shoud return expected instance' do
12
- should eql(expected_class.new(cache, expected_class::REGEXP.match(input)))
14
+ regexp = expected_class::REGEXP
15
+ should eql(expected_class.new(cache, regexp.match(input)))
13
16
  end
14
17
 
15
18
  let(:expected_class) { Mutant::CLI::Classifier::Method }
@@ -0,0 +1,89 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Mutant::CLI::Classifier::Method, '#each' do
6
+ let(:object) { described_class.build(cache, input) }
7
+ let(:cache) { Mutant::Cache.new }
8
+ let(:instance_method) { '::TestApp::Literal#string' }
9
+ let(:singleton_method) { '::TestApp::Literal.string' }
10
+ let(:unknown_method) { '::TestApp::Literal#unknown' }
11
+
12
+ context 'with a block' do
13
+ subject { object.each {} }
14
+
15
+ context 'with an instance method name' do
16
+ let(:input) { instance_method }
17
+
18
+ it_behaves_like 'a command method'
19
+
20
+ it 'yield an instance subject' do
21
+ expect { |block| object.each(&block) }
22
+ .to yield_with_args(Mutant::Subject::Method::Instance)
23
+ end
24
+ end
25
+
26
+ context 'with an singleton method name' do
27
+ let(:input) { singleton_method }
28
+
29
+ it_behaves_like 'a command method'
30
+
31
+ it 'yield an instance subject' do
32
+ expect { |block| object.each(&block) }
33
+ .to yield_with_args(Mutant::Subject::Method::Singleton)
34
+ end
35
+ end
36
+
37
+ context 'with an unknown method' do
38
+ let(:input) { unknown_method }
39
+
40
+ it 'raises an exception' do
41
+ expect { subject }
42
+ .to raise_error(NameError, "Cannot find method #{input}")
43
+ end
44
+ end
45
+ end
46
+
47
+ context 'without a block' do
48
+ subject { object.each }
49
+
50
+ context 'with an instance method name' do
51
+ let(:input) { instance_method }
52
+
53
+ it 'returns an enumerator' do
54
+ should be_instance_of(to_enum.class)
55
+ end
56
+
57
+ it 'yield an instance subject' do
58
+ expect { |block| subject.each(&block) }
59
+ .to yield_with_args(Mutant::Subject::Method::Instance)
60
+ end
61
+ end
62
+
63
+ context 'with an singleton method name' do
64
+ let(:input) { singleton_method }
65
+
66
+ it 'returns an enumerator' do
67
+ should be_instance_of(to_enum.class)
68
+ end
69
+
70
+ it 'yield an instance subject' do
71
+ expect { |block| subject.each(&block) }
72
+ .to yield_with_args(Mutant::Subject::Method::Singleton)
73
+ end
74
+ end
75
+
76
+ context 'with an unknown method' do
77
+ let(:input) { unknown_method }
78
+
79
+ it 'returns an enumerator' do
80
+ should be_instance_of(to_enum.class)
81
+ end
82
+
83
+ it 'raises an exception when #each is called' do
84
+ expect { subject.each {} }
85
+ .to raise_error(NameError, "Cannot find method #{input}")
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,58 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Mutant::CLI::Classifier::Namespace::Flat, '#each' do
6
+ let(:object) { described_class.build(cache, input) }
7
+ let(:cache) { Mutant::Cache.new }
8
+ let(:known_namespace) { '::TestApp::Literal' }
9
+ let(:unknown_namespace) { '::TestApp::Object' }
10
+
11
+ context 'with a block' do
12
+ subject { object.each {} }
13
+
14
+ context 'with a known namespace' do
15
+ let(:input) { known_namespace }
16
+
17
+ it_behaves_like 'a command method'
18
+
19
+ it 'yield method subjects' do
20
+ expect { |block| object.each(&block) }
21
+ .to yield_control.exactly(7).times
22
+ end
23
+ end
24
+
25
+ context 'with an unknown namespace' do
26
+ let(:input) { unknown_namespace }
27
+
28
+ it 'raises an exception' do
29
+ expect { subject }.to raise_error(NameError)
30
+ end
31
+ end
32
+ end
33
+
34
+ context 'without a block' do
35
+ subject { object.each }
36
+
37
+ context 'with a known namespace' do
38
+ let(:input) { known_namespace }
39
+
40
+ it 'returns an enumerator' do
41
+ should be_instance_of(to_enum.class)
42
+ end
43
+
44
+ it 'yield an instance subject' do
45
+ expect { |block| object.each(&block) }
46
+ .to yield_control.exactly(7).times
47
+ end
48
+ end
49
+
50
+ context 'with an unknown namespace' do
51
+ let(:input) { unknown_namespace }
52
+
53
+ it 'raises an exception when #each is called' do
54
+ expect { subject.each {} }.to raise_error(NameError)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,58 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Mutant::CLI::Classifier::Namespace::Recursive, '#each' do
6
+ let(:object) { described_class.build(cache, "#{input}*") }
7
+ let(:cache) { Mutant::Cache.new }
8
+ let(:known_namespace) { '::TestApp::Literal' }
9
+ let(:unknown_namespace) { '::TestApp::Object' }
10
+
11
+ context 'with a block' do
12
+ subject { object.each {} }
13
+
14
+ context 'with a known namespace' do
15
+ let(:input) { known_namespace }
16
+
17
+ it_behaves_like 'a command method'
18
+
19
+ it 'yield method subjects' do
20
+ expect { |block| object.each(&block) }
21
+ .to yield_control.exactly(7).times
22
+ end
23
+ end
24
+
25
+ context 'with an unknown namespace' do
26
+ let(:input) { unknown_namespace }
27
+
28
+ it 'raises an exception' do
29
+ expect { subject }.to raise_error(NameError)
30
+ end
31
+ end
32
+ end
33
+
34
+ context 'without a block' do
35
+ subject { object.each }
36
+
37
+ context 'with a known namespace' do
38
+ let(:input) { known_namespace }
39
+
40
+ it 'returns an enumerator' do
41
+ should be_instance_of(to_enum.class)
42
+ end
43
+
44
+ it 'yield an instance subject' do
45
+ expect { |block| object.each(&block) }
46
+ .to yield_control.exactly(7).times
47
+ end
48
+ end
49
+
50
+ context 'with an unknown namespace' do
51
+ let(:input) { unknown_namespace }
52
+
53
+ it 'raises an exception when #each is called' do
54
+ expect { subject.each {} }.to raise_error(NameError)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Mutant::CLI::Classifier::Scope, '#each' do
6
+ let(:object) { described_class.build(cache, input) }
7
+ let(:cache) { Mutant::Cache.new }
8
+ let(:input) { ::TestApp::Literal }
9
+
10
+ context 'with a block' do
11
+ subject { object.each {} }
12
+
13
+ it_behaves_like 'a command method'
14
+
15
+ it 'yield method subjects' do
16
+ expect { |block| object.each(&block) }
17
+ .to yield_control.exactly(7).times
18
+ end
19
+ end
20
+
21
+ context 'without a block' do
22
+ subject { object.each }
23
+
24
+ it 'returns an enumerator' do
25
+ should be_instance_of(to_enum.class)
26
+ end
27
+
28
+ it 'yield an instance subject' do
29
+ expect { |block| object.each(&block) }
30
+ .to yield_control.exactly(7).times
31
+ end
32
+ end
33
+ end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Context, '#root' do
@@ -6,6 +8,8 @@ describe Mutant::Context, '#root' do
6
8
  let(:object) { described_class.allocate }
7
9
 
8
10
  it 'should raise error' do
9
- expect { subject }.to raise_error('Mutant::Context#root is not implemented')
11
+ expect do
12
+ subject
13
+ end.to raise_error('Mutant::Context#root is not implemented')
10
14
  end
11
15
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Context::Scope, '#root' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Context::Scope, '#unqualified_name' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Differ, '.build' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Differ, '.colorize_line' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Differ, '#diff' do
@@ -9,7 +11,16 @@ describe Mutant::Differ, '#diff' do
9
11
  let(:old) { %w(foo bar) }
10
12
  let(:new) { %w(baz bar) }
11
13
 
12
- it { should eql("@@ -1,3 +1,3 @@\n-foo\n+baz\n bar\n") }
14
+ let(:expectation) do
15
+ strip_indent(<<-STR)
16
+ @@ -1,3 +1,3 @@
17
+ -foo
18
+ +baz
19
+ bar
20
+ STR
21
+ end
22
+
23
+ it { should eql(expectation) }
13
24
 
14
25
  it_should_behave_like 'an idempotent method'
15
26
  end
@@ -18,7 +29,16 @@ describe Mutant::Differ, '#diff' do
18
29
  let(:old) { %w(foo bar) }
19
30
  let(:new) { %w(foo baz bar) }
20
31
 
21
- it { should eql("@@ -1,3 +1,4 @@\n foo\n+baz\n bar\n") }
32
+ let(:expectation) do
33
+ strip_indent(<<-STR)
34
+ @@ -1,3 +1,4 @@
35
+ foo
36
+ +baz
37
+ bar
38
+ STR
39
+ end
40
+
41
+ it { should eql(expectation) }
22
42
 
23
43
  it_should_behave_like 'an idempotent method'
24
44
  end
@@ -27,7 +47,21 @@ describe Mutant::Differ, '#diff' do
27
47
  let(:old) { %w(foo bar baz boz a b c) }
28
48
  let(:new) { %w(foo bar baz boz a b c other) }
29
49
 
30
- it { should eql("@@ -1,8 +1,9 @@\n foo\n bar\n baz\n boz\n a\n b\n c\n+other\n") }
50
+ let(:expectation) do
51
+ strip_indent(<<-STR)
52
+ @@ -1,8 +1,9 @@
53
+ foo
54
+ bar
55
+ baz
56
+ boz
57
+ a
58
+ b
59
+ c
60
+ +other
61
+ STR
62
+ end
63
+
64
+ it { should eql(expectation) }
31
65
 
32
66
  it_should_behave_like 'an idempotent method'
33
67
  end
@@ -36,7 +70,21 @@ describe Mutant::Differ, '#diff' do
36
70
  let(:old) { %w(other foo bar baz boz a b c) }
37
71
  let(:new) { %w(foo bar baz boz a b c) }
38
72
 
39
- it { should eql("@@ -1,9 +1,8 @@\n-other\n foo\n bar\n baz\n boz\n a\n b\n c\n") }
73
+ let(:expectation) do
74
+ strip_indent(<<-STR)
75
+ @@ -1,9 +1,8 @@
76
+ -other
77
+ foo
78
+ bar
79
+ baz
80
+ boz
81
+ a
82
+ b
83
+ c
84
+ STR
85
+ end
86
+
87
+ it { should eql(expectation) }
40
88
 
41
89
  it_should_behave_like 'an idempotent method'
42
90
  end
@@ -45,7 +93,21 @@ describe Mutant::Differ, '#diff' do
45
93
  let(:old) { %w(foo bar baz boz a b c) }
46
94
  let(:new) { %w(other foo bar baz boz a b c) }
47
95
 
48
- it { should eql("@@ -1,8 +1,9 @@\n+other\n foo\n bar\n baz\n boz\n a\n b\n c\n") }
96
+ let(:expectation) do
97
+ strip_indent(<<-STR)
98
+ @@ -1,8 +1,9 @@
99
+ +other
100
+ foo
101
+ bar
102
+ baz
103
+ boz
104
+ a
105
+ b
106
+ c
107
+ STR
108
+ end
109
+
110
+ it { should eql(expectation) }
49
111
 
50
112
  it_should_behave_like 'an idempotent method'
51
113
  end