rspec-core 2.99.0 → 3.0.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 (216) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.sig +0 -0
  3. data/.yardopts +1 -0
  4. data/Changelog.md +339 -1
  5. data/License.txt +1 -0
  6. data/README.md +19 -37
  7. data/exe/rspec +2 -23
  8. data/lib/rspec/core/backport_random.rb +336 -0
  9. data/lib/rspec/core/backtrace_formatter.rb +70 -0
  10. data/lib/rspec/core/configuration.rb +479 -577
  11. data/lib/rspec/core/configuration_options.rb +71 -54
  12. data/lib/rspec/core/drb.rb +111 -0
  13. data/lib/rspec/core/dsl.rb +86 -18
  14. data/lib/rspec/core/example.rb +267 -119
  15. data/lib/rspec/core/example_group.rb +381 -393
  16. data/lib/rspec/core/filter_manager.rb +133 -114
  17. data/lib/rspec/core/flat_map.rb +18 -0
  18. data/lib/rspec/core/formatters/base_formatter.rb +51 -125
  19. data/lib/rspec/core/formatters/base_text_formatter.rb +34 -286
  20. data/lib/rspec/core/formatters/console_codes.rb +24 -1
  21. data/lib/rspec/core/formatters/deprecation_formatter.rb +25 -26
  22. data/lib/rspec/core/formatters/documentation_formatter.rb +27 -25
  23. data/lib/rspec/core/formatters/helpers.rb +14 -36
  24. data/lib/rspec/core/formatters/html_formatter.rb +58 -65
  25. data/lib/rspec/core/formatters/html_printer.rb +12 -18
  26. data/lib/rspec/core/formatters/json_formatter.rb +54 -31
  27. data/lib/rspec/core/formatters/profile_formatter.rb +67 -0
  28. data/lib/rspec/core/formatters/progress_formatter.rb +11 -15
  29. data/lib/rspec/core/formatters/snippet_extractor.rb +22 -11
  30. data/lib/rspec/core/formatters.rb +90 -43
  31. data/lib/rspec/core/hooks.rb +325 -270
  32. data/lib/rspec/core/memoized_helpers.rb +45 -156
  33. data/lib/rspec/core/metadata.rb +284 -236
  34. data/lib/rspec/core/metadata_filter.rb +86 -0
  35. data/lib/rspec/core/mocking_adapters/flexmock.rb +29 -0
  36. data/lib/rspec/core/{mocking/with_mocha.rb → mocking_adapters/mocha.rb} +19 -16
  37. data/lib/rspec/core/mocking_adapters/null.rb +12 -0
  38. data/lib/rspec/core/mocking_adapters/rr.rb +29 -0
  39. data/lib/rspec/core/mocking_adapters/rspec.rb +30 -0
  40. data/lib/rspec/core/notifications.rb +511 -0
  41. data/lib/rspec/core/option_parser.rb +49 -74
  42. data/lib/rspec/core/ordering.rb +156 -0
  43. data/lib/rspec/core/pending.rb +94 -96
  44. data/lib/rspec/core/project_initializer/.rspec +3 -0
  45. data/lib/rspec/core/project_initializer/spec/spec_helper.rb +78 -0
  46. data/lib/rspec/core/project_initializer.rb +24 -64
  47. data/lib/rspec/core/rake_task.rb +44 -130
  48. data/lib/rspec/core/reporter.rb +76 -59
  49. data/lib/rspec/core/ruby_project.rb +2 -1
  50. data/lib/rspec/core/runner.rb +117 -52
  51. data/lib/rspec/core/shared_context.rb +10 -10
  52. data/lib/rspec/core/shared_example_group.rb +108 -121
  53. data/lib/rspec/core/version.rb +3 -1
  54. data/lib/rspec/core/warnings.rb +40 -0
  55. data/lib/rspec/core/world.rb +66 -10
  56. data/lib/rspec/core.rb +64 -104
  57. data.tar.gz.sig +3 -0
  58. metadata +75 -322
  59. metadata.gz.sig +1 -0
  60. data/exe/autospec +0 -13
  61. data/features/Autotest.md +0 -38
  62. data/features/README.md +0 -17
  63. data/features/Upgrade.md +0 -364
  64. data/features/command_line/README.md +0 -28
  65. data/features/command_line/example_name_option.feature +0 -97
  66. data/features/command_line/exit_status.feature +0 -82
  67. data/features/command_line/format_option.feature +0 -75
  68. data/features/command_line/init.feature +0 -18
  69. data/features/command_line/line_number_appended_to_path.feature +0 -140
  70. data/features/command_line/line_number_option.feature +0 -53
  71. data/features/command_line/order.feature +0 -26
  72. data/features/command_line/pattern_option.feature +0 -49
  73. data/features/command_line/rake_task.feature +0 -122
  74. data/features/command_line/require_option.feature +0 -43
  75. data/features/command_line/ruby.feature +0 -22
  76. data/features/command_line/tag.feature +0 -98
  77. data/features/command_line/warnings_option.feature +0 -29
  78. data/features/configuration/alias_example_to.feature +0 -48
  79. data/features/configuration/backtrace_clean_patterns.feature +0 -102
  80. data/features/configuration/custom_settings.feature +0 -84
  81. data/features/configuration/default_path.feature +0 -38
  82. data/features/configuration/deprecation_stream.feature +0 -58
  83. data/features/configuration/fail_fast.feature +0 -77
  84. data/features/configuration/failure_exit_code.feature +0 -36
  85. data/features/configuration/order_and_seed.feature +0 -3
  86. data/features/configuration/output_stream.feature +0 -24
  87. data/features/configuration/pattern.feature +0 -38
  88. data/features/configuration/profile.feature +0 -220
  89. data/features/configuration/read_options_from_file.feature +0 -90
  90. data/features/configuration/run_all_when_everything_filtered.feature +0 -76
  91. data/features/configuration/show_failures_in_pending_blocks.feature +0 -61
  92. data/features/configuration/treat_symbols_as_metadata_keys_with_true_values.feature +0 -52
  93. data/features/example_groups/basic_structure.feature +0 -55
  94. data/features/example_groups/shared_context.feature +0 -74
  95. data/features/example_groups/shared_examples.feature +0 -294
  96. data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -197
  97. data/features/filtering/exclusion_filters.feature +0 -138
  98. data/features/filtering/if_and_unless.feature +0 -168
  99. data/features/filtering/inclusion_filters.feature +0 -105
  100. data/features/formatters/configurable_colors.feature +0 -31
  101. data/features/formatters/custom_formatter.feature +0 -36
  102. data/features/formatters/json_formatter.feature +0 -30
  103. data/features/formatters/text_formatter.feature +0 -46
  104. data/features/helper_methods/arbitrary_methods.feature +0 -40
  105. data/features/helper_methods/let.feature +0 -50
  106. data/features/helper_methods/modules.feature +0 -149
  107. data/features/hooks/around_hooks.feature +0 -343
  108. data/features/hooks/before_and_after_hooks.feature +0 -427
  109. data/features/hooks/filtering.feature +0 -234
  110. data/features/metadata/current_example.feature +0 -56
  111. data/features/metadata/described_class.feature +0 -17
  112. data/features/metadata/user_defined.feature +0 -113
  113. data/features/mock_framework_integration/use_any_framework.feature +0 -106
  114. data/features/mock_framework_integration/use_flexmock.feature +0 -96
  115. data/features/mock_framework_integration/use_mocha.feature +0 -97
  116. data/features/mock_framework_integration/use_rr.feature +0 -98
  117. data/features/mock_framework_integration/use_rspec.feature +0 -97
  118. data/features/pending/pending_examples.feature +0 -229
  119. data/features/spec_files/arbitrary_file_suffix.feature +0 -13
  120. data/features/step_definitions/additional_cli_steps.rb +0 -49
  121. data/features/subject/attribute_of_subject.feature +0 -124
  122. data/features/subject/explicit_subject.feature +0 -101
  123. data/features/subject/implicit_subject.feature +0 -63
  124. data/features/subject/one_liner_syntax.feature +0 -71
  125. data/features/support/env.rb +0 -14
  126. data/features/support/rubinius.rb +0 -6
  127. data/lib/autotest/discover.rb +0 -10
  128. data/lib/autotest/rspec2.rb +0 -77
  129. data/lib/rspec/core/backtrace_cleaner.rb +0 -46
  130. data/lib/rspec/core/backward_compatibility.rb +0 -55
  131. data/lib/rspec/core/caller_filter.rb +0 -60
  132. data/lib/rspec/core/command_line.rb +0 -47
  133. data/lib/rspec/core/deprecated_mutable_array_proxy.rb +0 -32
  134. data/lib/rspec/core/deprecation.rb +0 -26
  135. data/lib/rspec/core/drb_command_line.rb +0 -26
  136. data/lib/rspec/core/drb_options.rb +0 -87
  137. data/lib/rspec/core/extensions/instance_eval_with_args.rb +0 -44
  138. data/lib/rspec/core/extensions/kernel.rb +0 -9
  139. data/lib/rspec/core/extensions/module_eval_with_args.rb +0 -38
  140. data/lib/rspec/core/extensions/ordered.rb +0 -27
  141. data/lib/rspec/core/formatters/text_mate_formatter.rb +0 -34
  142. data/lib/rspec/core/metadata_hash_builder.rb +0 -97
  143. data/lib/rspec/core/mocking/with_absolutely_nothing.rb +0 -11
  144. data/lib/rspec/core/mocking/with_flexmock.rb +0 -27
  145. data/lib/rspec/core/mocking/with_rr.rb +0 -27
  146. data/lib/rspec/core/mocking/with_rspec.rb +0 -27
  147. data/lib/rspec/core/shared_example_group/collection.rb +0 -45
  148. data/spec/autotest/discover_spec.rb +0 -49
  149. data/spec/autotest/failed_results_re_spec.rb +0 -45
  150. data/spec/autotest/rspec_spec.rb +0 -133
  151. data/spec/command_line/order_spec.rb +0 -204
  152. data/spec/rspec/core/backtrace_cleaner_spec.rb +0 -68
  153. data/spec/rspec/core/caller_filter_spec.rb +0 -58
  154. data/spec/rspec/core/command_line_spec.rb +0 -127
  155. data/spec/rspec/core/command_line_spec_output.txt +0 -0
  156. data/spec/rspec/core/configuration_options_spec.rb +0 -417
  157. data/spec/rspec/core/configuration_spec.rb +0 -2072
  158. data/spec/rspec/core/deprecation_spec.rb +0 -27
  159. data/spec/rspec/core/deprecations_spec.rb +0 -59
  160. data/spec/rspec/core/drb_command_line_spec.rb +0 -102
  161. data/spec/rspec/core/drb_options_spec.rb +0 -193
  162. data/spec/rspec/core/dsl_spec.rb +0 -25
  163. data/spec/rspec/core/example_group_spec.rb +0 -1337
  164. data/spec/rspec/core/example_spec.rb +0 -502
  165. data/spec/rspec/core/filter_manager_spec.rb +0 -246
  166. data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -108
  167. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -524
  168. data/spec/rspec/core/formatters/console_codes_spec.rb +0 -50
  169. data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +0 -263
  170. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -89
  171. data/spec/rspec/core/formatters/helpers_spec.rb +0 -104
  172. data/spec/rspec/core/formatters/html_formatted.html +0 -397
  173. data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -131
  174. data/spec/rspec/core/formatters/json_formatter_spec.rb +0 -115
  175. data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -30
  176. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -26
  177. data/spec/rspec/core/formatters/text_mate_formatted.html +0 -397
  178. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +0 -107
  179. data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
  180. data/spec/rspec/core/hooks_spec.rb +0 -269
  181. data/spec/rspec/core/kernel_extensions_spec.rb +0 -9
  182. data/spec/rspec/core/memoized_helpers_spec.rb +0 -776
  183. data/spec/rspec/core/metadata_spec.rb +0 -514
  184. data/spec/rspec/core/option_parser_spec.rb +0 -297
  185. data/spec/rspec/core/pending_example_spec.rb +0 -260
  186. data/spec/rspec/core/pending_spec.rb +0 -27
  187. data/spec/rspec/core/project_initializer_spec.rb +0 -130
  188. data/spec/rspec/core/rake_task_spec.rb +0 -202
  189. data/spec/rspec/core/reporter_spec.rb +0 -167
  190. data/spec/rspec/core/resources/a_bar.rb +0 -0
  191. data/spec/rspec/core/resources/a_foo.rb +0 -0
  192. data/spec/rspec/core/resources/a_spec.rb +0 -1
  193. data/spec/rspec/core/resources/custom_example_group_runner.rb +0 -14
  194. data/spec/rspec/core/resources/formatter_specs.rb +0 -60
  195. data/spec/rspec/core/resources/utf8_encoded.rb +0 -8
  196. data/spec/rspec/core/rspec_matchers_spec.rb +0 -45
  197. data/spec/rspec/core/ruby_project_spec.rb +0 -26
  198. data/spec/rspec/core/runner_spec.rb +0 -82
  199. data/spec/rspec/core/shared_context_spec.rb +0 -114
  200. data/spec/rspec/core/shared_example_group/collection_spec.rb +0 -70
  201. data/spec/rspec/core/shared_example_group_spec.rb +0 -138
  202. data/spec/rspec/core/world_spec.rb +0 -142
  203. data/spec/rspec/core_spec.rb +0 -108
  204. data/spec/spec_helper.rb +0 -135
  205. data/spec/support/config_options_helper.rb +0 -15
  206. data/spec/support/helper_methods.rb +0 -55
  207. data/spec/support/in_sub_process.rb +0 -37
  208. data/spec/support/isolate_load_path_mutation.rb +0 -6
  209. data/spec/support/isolated_directory.rb +0 -10
  210. data/spec/support/isolated_home_directory.rb +0 -16
  211. data/spec/support/matchers.rb +0 -65
  212. data/spec/support/mathn_integration_support.rb +0 -12
  213. data/spec/support/sandboxed_mock_space.rb +0 -116
  214. data/spec/support/shared_example_groups.rb +0 -42
  215. data/spec/support/silence_dsl_deprecations.rb +0 -32
  216. data/spec/support/spec_files.rb +0 -44
@@ -1,130 +0,0 @@
1
- require "spec_helper"
2
-
3
- module RSpec::Core
4
- describe ProjectInitializer, :isolated_directory => true do
5
-
6
- describe "#run" do
7
- context "with no args" do
8
- let(:command_line_config) { ProjectInitializer.new }
9
-
10
- before do
11
- command_line_config.stub(:warn)
12
- command_line_config.stub(:puts)
13
- command_line_config.stub(:gets => 'no')
14
- end
15
-
16
- context "with no .rspec file" do
17
- it "says it's creating .rspec " do
18
- command_line_config.should_receive(:puts).with(/create\s+\.rspec/)
19
- command_line_config.run
20
- end
21
-
22
- it "generates a .rspec" do
23
- command_line_config.run
24
- expect(File.read('.rspec')).to match(/--color\n--format progress/m)
25
- end
26
- end
27
-
28
- context "with a .rspec file" do
29
- it "says .rspec exists" do
30
- FileUtils.touch('.rspec')
31
- command_line_config.should_receive(:puts).with(/exist\s+\.rspec/)
32
- command_line_config.run
33
- end
34
-
35
- it "doesn't create a new one" do
36
- File.open('.rspec', 'w') {|f| f << '--color'}
37
- command_line_config.run
38
- expect(File.read('.rspec')).to eq('--color')
39
- end
40
- end
41
-
42
- context "with no spec/spec_helper.rb file" do
43
- it "says it's creating spec/spec_helper.rb " do
44
- command_line_config.should_receive(:puts).with(/create\s+spec\/spec_helper.rb/)
45
- command_line_config.run
46
- end
47
-
48
- it "generates a spec/spec_helper.rb" do
49
- command_line_config.run
50
- expect(File.read('spec/spec_helper.rb')).to match(/RSpec\.configure do \|config\|/m)
51
- end
52
- end
53
-
54
- context "with a spec/spec_helper.rb file" do
55
- before { FileUtils.mkdir('spec') }
56
-
57
- it "says spec/spec_helper.rb exists" do
58
- FileUtils.touch('spec/spec_helper.rb')
59
- command_line_config.should_receive(:puts).with(/exist\s+spec\/spec_helper.rb/)
60
- command_line_config.run
61
- end
62
-
63
- it "doesn't create a new one" do
64
- random_content = "content #{rand}"
65
- File.open('spec/spec_helper.rb', 'w') {|f| f << random_content}
66
- command_line_config.run
67
- expect(File.read('spec/spec_helper.rb')).to eq(random_content)
68
- end
69
- end
70
-
71
- context "with autotest/discover.rb" do
72
- before do
73
- FileUtils.mkdir('autotest')
74
- FileUtils.touch 'autotest/discover.rb'
75
- end
76
-
77
- it "asks whether to delete the file" do
78
- command_line_config.should_receive(:puts).with(/delete/)
79
- command_line_config.run
80
- end
81
-
82
- it "removes it if confirmed" do
83
- command_line_config.stub(:gets => 'yes')
84
- command_line_config.run
85
- expect(File.exist?('autotest/discover.rb')).to be_falsey
86
- end
87
-
88
- it "leaves it if not confirmed" do
89
- command_line_config.stub(:gets => 'no')
90
- command_line_config.run
91
- expect(File.exist?('autotest/discover.rb')).to be_truthy
92
- end
93
- end
94
-
95
- context "with lib/tasks/rspec.rake" do
96
- before do
97
- FileUtils.mkdir_p('lib/tasks')
98
- FileUtils.touch 'lib/tasks/rspec.rake'
99
- end
100
-
101
- it "asks whether to delete the file" do
102
- command_line_config.should_receive(:puts).with(/delete/)
103
- command_line_config.run
104
- end
105
-
106
- it "removes it if confirmed" do
107
- command_line_config.stub(:gets => 'yes')
108
- command_line_config.run
109
- expect(File.exist?('lib/tasks/rspec.rake')).to be_falsey
110
- end
111
-
112
- it "leaves it if not confirmed" do
113
- command_line_config.stub(:gets => 'no')
114
- command_line_config.run
115
- expect(File.exist?('lib/tasks/rspec.rake')).to be_truthy
116
- end
117
- end
118
- end
119
-
120
- context "given an arg" do
121
- it "warns if arg received (no longer necessary)" do
122
- config = ProjectInitializer.new("another_arg")
123
- config.stub(:puts)
124
- config.stub(:gets => 'no')
125
- config.run
126
- end
127
- end
128
- end
129
- end
130
- end
@@ -1,202 +0,0 @@
1
- require "spec_helper"
2
- require "rspec/core/rake_task"
3
- require 'tempfile'
4
-
5
- module RSpec::Core
6
- describe RakeTask do
7
- let(:task) { RakeTask.new }
8
-
9
- def ruby
10
- FileUtils::RUBY
11
- end
12
-
13
- def with_rcov
14
- task.rcov = true
15
- yield
16
- end
17
-
18
- def spec_command
19
- task.__send__(:spec_command)
20
- end
21
-
22
- context "with a name passed to the constructor" do
23
- let(:task) { RakeTask.new(:task_name) }
24
-
25
- it "correctly sets the name" do
26
- expect(task.name).to eq :task_name
27
- end
28
- end
29
-
30
- context "with args passed to the rake task" do
31
- it "correctly passes along task arguments" do
32
- task = RakeTask.new(:rake_task_args, :files) do |t, args|
33
- expect(args[:files]).to eq "first_spec.rb"
34
- end
35
-
36
- task.should_receive(:run_task) { true }
37
- expect(Rake.application.invoke_task("rake_task_args[first_spec.rb]")).to be_truthy
38
- end
39
- end
40
-
41
- context "default" do
42
- it "renders rspec" do
43
- expect(spec_command).to match(/^#{ruby} -S rspec/)
44
- end
45
- end
46
-
47
- context "with rcov" do
48
- before { allow(RSpec).to receive(:deprecate) }
49
-
50
- it "renders rcov" do
51
- with_rcov do
52
- expect(spec_command).to match(/^#{ruby} -S rcov/)
53
- end
54
- end
55
-
56
- it 'warns of deprecation' do
57
- expect(RSpec).to receive(:deprecate)
58
- with_rcov { spec_command }
59
- end
60
- end
61
-
62
- context "with ruby options" do
63
- it "renders them before -S" do
64
- task.ruby_opts = "-w"
65
- expect(spec_command).to match(/^#{ruby} -w -S rspec/)
66
- end
67
- end
68
-
69
- context "with rcov_opts" do
70
- before { allow(RSpec).to receive(:deprecate) }
71
-
72
- context "with rcov=false (default)" do
73
- it "does not add the rcov options to the command" do
74
- task.rcov_opts = '--exclude "mocks"'
75
- expect(spec_command).not_to match(/--exclude "mocks"/)
76
- end
77
-
78
- it 'warns of deprecation' do
79
- expect(RSpec).to receive(:deprecate)
80
- task.rcov_opts = '--exclude "mocks"'
81
- end
82
- end
83
-
84
- context "with rcov=true" do
85
- it "renders them after rcov" do
86
- task.rcov = true
87
- task.rcov_opts = '--exclude "mocks"'
88
- expect(spec_command).to match(/rcov.*--exclude "mocks"/)
89
- end
90
-
91
- it "ensures that -Ispec:lib is in the resulting command" do
92
- task.rcov = true
93
- task.rcov_opts = '--exclude "mocks"'
94
- expect(spec_command).to match(/rcov.*-Ispec:lib/)
95
- end
96
-
97
- it 'warns of deprecation' do
98
- expect(RSpec).to receive(:deprecate)
99
- task.rcov_opts = '--exclude "mocks"'
100
- end
101
- end
102
- end
103
-
104
- context "with rspec_opts" do
105
- before { allow(RSpec).to receive(:deprecate) }
106
-
107
- context "with rcov=true" do
108
- it "adds the rspec_opts after the rcov_opts and files" do
109
- task.stub(:files_to_run) { "this.rb that.rb" }
110
- task.rcov = true
111
- task.rspec_opts = "-Ifoo"
112
- expect(spec_command).to match(/this.rb that.rb -- -Ifoo/)
113
- end
114
- end
115
- context "with rcov=false (default)" do
116
- it "adds the rspec_opts" do
117
- task.rspec_opts = "-Ifoo"
118
- expect(spec_command).to match(/rspec.*-Ifoo/)
119
- end
120
- end
121
- end
122
-
123
- def specify_consistent_ordering_of_files_to_run(pattern, task)
124
- orderings = [
125
- %w[ a/1.rb a/2.rb a/3.rb ],
126
- %w[ a/2.rb a/1.rb a/3.rb ],
127
- %w[ a/3.rb a/2.rb a/1.rb ]
128
- ].map do |files|
129
- FileList.should_receive(:[]).with(pattern) { files }
130
- task.__send__(:files_to_run)
131
- end
132
-
133
- expect(orderings.uniq.size).to eq(1)
134
- end
135
-
136
- context "with SPEC env var set" do
137
- it "sets files to run" do
138
- with_env_vars 'SPEC' => 'path/to/file' do
139
- expect(task.__send__(:files_to_run)).to eq(["path/to/file"])
140
- end
141
- end
142
-
143
- it "sets the files to run in a consistent order, regardless of the underlying FileList ordering" do
144
- with_env_vars 'SPEC' => 'a/*.rb' do
145
- specify_consistent_ordering_of_files_to_run('a/*.rb', task)
146
- end
147
- end
148
- end
149
-
150
- it "sets the files to run in a consistent order, regardless of the underlying FileList ordering" do
151
- task = RakeTask.new(:consistent_file_order) do |t|
152
- t.pattern = 'a/*.rb'
153
- end
154
-
155
- # since the config block is deferred til task invocation, must fake
156
- # calling the task so the expected pattern is picked up
157
- task.should_receive(:run_task) { true }
158
- expect(Rake.application.invoke_task(task.name)).to be_truthy
159
-
160
- specify_consistent_ordering_of_files_to_run('a/*.rb', task)
161
- end
162
-
163
- context "with paths with quotes or spaces" do
164
- it "escapes the quotes and spaces" do
165
- task.pattern = File.join(Dir.tmpdir, "*spec.rb")
166
- ["first_spec.rb", "second_\"spec.rb", "third_\'spec.rb", "fourth spec.rb"].each do |file_name|
167
- FileUtils.touch(File.join(Dir.tmpdir, file_name))
168
- end
169
- expect(task.__send__(:files_to_run).sort).to eq([
170
- File.join(Dir.tmpdir, "first_spec.rb"),
171
- File.join(Dir.tmpdir, "fourth\\ spec.rb"),
172
- File.join(Dir.tmpdir, "second_\\\"spec.rb"),
173
- File.join(Dir.tmpdir, "third_\\\'spec.rb")
174
- ])
175
- end
176
- end
177
-
178
- context "with paths including symlinked directories" do
179
- it "finds the files" do
180
- project_dir = File.join(Dir.tmpdir, "project")
181
- FileUtils.rm_rf project_dir
182
-
183
- foos_dir = File.join(project_dir, "spec/foos")
184
- FileUtils.mkdir_p foos_dir
185
- FileUtils.touch(File.join(foos_dir, "foo_spec.rb"))
186
-
187
- bars_dir = File.join(Dir.tmpdir, "shared/spec/bars")
188
- FileUtils.mkdir_p bars_dir
189
- FileUtils.touch(File.join(bars_dir, "bar_spec.rb"))
190
-
191
- FileUtils.ln_s bars_dir, File.join(project_dir, "spec/bars")
192
-
193
- FileUtils.cd(project_dir) do
194
- expect(RakeTask.new.__send__(:files_to_run).sort).to eq([
195
- "./spec/bars/bar_spec.rb",
196
- "./spec/foos/foo_spec.rb"
197
- ])
198
- end
199
- end
200
- end
201
- end
202
- end
@@ -1,167 +0,0 @@
1
- require "spec_helper"
2
-
3
- module RSpec::Core
4
- describe Reporter do
5
- describe "abort" do
6
- let(:formatter) { double("formatter") }
7
- let(:example) { double("example") }
8
- let(:reporter) { Reporter.new(formatter) }
9
-
10
- before do
11
- allow_deprecation
12
- end
13
-
14
- %w[start_dump dump_pending dump_failures dump_summary close].each do |message|
15
- it "sends #{message} to the formatter(s) that respond to message" do
16
- formatter.should_receive(message)
17
- reporter.abort(nil)
18
- end
19
-
20
- it "doesnt notify formatters about messages they dont implement" do
21
- expect { reporter.abort(nil) }.to_not raise_error
22
- end
23
-
24
- it 'warns of deprecation' do
25
- expect_deprecation_with_call_site(__FILE__, __LINE__ + 1)
26
- reporter.abort(nil)
27
- end
28
- end
29
- end
30
-
31
- describe "finish" do
32
- let(:formatter) { double("formatter") }
33
- let(:example) { double("example") }
34
- let(:reporter) { Reporter.new(formatter) }
35
-
36
- %w[start_dump dump_pending dump_failures dump_summary close].each do |message|
37
- it "sends #{message} to the formatter(s) that respond to message" do
38
- formatter.should_receive(message)
39
- reporter.finish(nil)
40
- end
41
-
42
- it "doesnt notify formatters about messages they dont implement" do
43
- expect { reporter.finish(nil) }.to_not raise_error
44
- end
45
- end
46
- end
47
-
48
- context "given one formatter" do
49
- it "passes messages to that formatter" do
50
- formatter = double("formatter", :example_started => nil)
51
- example = double("example")
52
- reporter = Reporter.new(formatter)
53
-
54
- formatter.should_receive(:example_started).
55
- with(example)
56
-
57
- reporter.example_started(example)
58
- end
59
-
60
- it "passes example_group_started and example_group_finished messages to that formatter in that order" do
61
- order = []
62
-
63
- formatter = double("formatter")
64
- formatter.stub(:example_group_started) { |group| order << "Started: #{group.description}" }
65
- formatter.stub(:example_group_finished) { |group| order << "Finished: #{group.description}" }
66
-
67
- group = ExampleGroup.describe("root")
68
- group.describe("context 1") do
69
- example("ignore") {}
70
- end
71
- group.describe("context 2") do
72
- example("ignore") {}
73
- end
74
-
75
- group.run(Reporter.new(formatter))
76
-
77
- expect(order).to eq([
78
- "Started: root",
79
- "Started: context 1",
80
- "Finished: context 1",
81
- "Started: context 2",
82
- "Finished: context 2",
83
- "Finished: root"
84
- ])
85
- end
86
- end
87
-
88
- context "given an example group with no examples" do
89
- it "does not pass example_group_started or example_group_finished to formatter" do
90
- formatter = double("formatter")
91
- formatter.should_not_receive(:example_group_started)
92
- formatter.should_not_receive(:example_group_finished)
93
-
94
- group = ExampleGroup.describe("root")
95
-
96
- group.run(Reporter.new(formatter))
97
- end
98
- end
99
-
100
- context "given multiple formatters" do
101
- it "passes messages to all formatters" do
102
- formatters = (1..2).map { double("formatter", :example_started => nil) }
103
- example = double("example")
104
- reporter = Reporter.new(*formatters)
105
-
106
- formatters.each do |formatter|
107
- formatter.
108
- should_receive(:example_started).
109
- with(example)
110
- end
111
-
112
- reporter.example_started(example)
113
- end
114
- end
115
-
116
- describe "#report" do
117
- it "supports one arg (count)" do
118
- Reporter.new.report(1) {}
119
- end
120
-
121
- it "supports two args (count, seed)" do
122
- Reporter.new.report(1, 2) {}
123
- end
124
-
125
- it "yields itself" do
126
- reporter = Reporter.new
127
- yielded = nil
128
- reporter.report(3) {|r| yielded = r}
129
- expect(yielded).to eq(reporter)
130
- end
131
- end
132
-
133
- describe "#register_listener" do
134
- let(:reporter) { Reporter.new }
135
- let(:listener) { double("listener", :start => nil) }
136
-
137
- before { reporter.register_listener listener, :start }
138
-
139
- it 'will register the listener to specified notifications' do
140
- expect(reporter.registered_listeners :start).to eq [listener]
141
- end
142
-
143
- it 'will send notifications when a subscribed event is triggered' do
144
- listener.should_receive(:start).with(42)
145
- reporter.start 42
146
- end
147
- end
148
-
149
- describe "timing" do
150
- it "uses RSpec::Core::Time as to not be affected by changes to time in examples" do
151
- formatter = double(:formatter)
152
- duration = nil
153
- formatter.stub(:dump_summary) do |dur, _, _, _|
154
- duration = dur
155
- end
156
-
157
- reporter = Reporter.new formatter
158
- reporter.start 1
159
- Time.stub(:now => ::Time.utc(2012, 10, 1))
160
-
161
-
162
- reporter.finish 1234
163
- expect(duration).to be < 0.2
164
- end
165
- end
166
- end
167
- end
File without changes
File without changes
@@ -1 +0,0 @@
1
- # Empty - used by ../options_spec.rb
@@ -1,14 +0,0 @@
1
- module Custom
2
- class ExampleGroupRunner
3
- attr_reader :options, :arg
4
- def initialize(options, arg)
5
- @options, @arg = options, arg
6
- end
7
-
8
- def load_files(files)
9
- end
10
-
11
- def run
12
- end
13
- end
14
- end
@@ -1,60 +0,0 @@
1
- # Deliberately named _specs.rb to avoid being loaded except when specified
2
-
3
- describe "pending spec with no implementation" do
4
- it "is pending"
5
- end
6
-
7
- describe "pending command with block format" do
8
- context "with content that would fail" do
9
- it "is pending" do
10
- pending do
11
- expect(1).to eq(2)
12
- end
13
- end
14
- end
15
-
16
- context "with content that would pass" do
17
- it "fails" do
18
- pending do
19
- expect(1).to eq(1)
20
- end
21
- end
22
- end
23
- end
24
-
25
- describe "passing spec" do
26
- it "passes" do
27
- expect(1).to eq(1)
28
- end
29
- end
30
-
31
- describe "failing spec" do
32
- it "fails" do
33
- expect(1).to eq(2)
34
- end
35
- end
36
-
37
- describe "a failing spec with odd backtraces" do
38
- it "fails with a backtrace that has no file" do
39
- require 'erb'
40
-
41
- ERB.new("<%= raise 'foo' %>").result
42
- end
43
-
44
- it "fails with a backtrace containing an erb file" do
45
- e = Exception.new
46
-
47
- def e.backtrace
48
- ["/foo.html.erb:1:in `<main>': foo (RuntimeError)",
49
- " from /lib/ruby/1.9.1/erb.rb:753:in `eval'"]
50
- end
51
-
52
- def e.message
53
- # Redefining message steps around this behaviour
54
- # on JRuby: http://jira.codehaus.org/browse/JRUBY-5637
55
- self.class.name
56
- end
57
-
58
- raise e
59
- end
60
- end
@@ -1,8 +0,0 @@
1
- # encoding: utf-8
2
- module Custom
3
- class ExampleUTF8ClassNameVarietà
4
- def self.è
5
- così = :però
6
- end
7
- end
8
- end
@@ -1,45 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module RSpec::Matchers
4
- def __method_with_super
5
- super
6
- end
7
-
8
- module ModThatIncludesMatchers
9
- include RSpec::Matchers
10
- end
11
-
12
- RSpec.configure do |c|
13
- c.include RSpec::Matchers, :include_rspec_matchers => true
14
- c.include ModThatIncludesMatchers, :include_mod_that_includes_rspec_matchers => true
15
- end
16
-
17
- describe self do
18
- shared_examples_for "a normal module with a method that supers" do
19
- it "raises the expected error (and not SystemStackError)" do
20
- expect { __method_with_super }.to raise_error(NoMethodError) # there is no __method_with_super in an ancestor
21
- end
22
- end
23
-
24
- it_behaves_like "a normal module with a method that supers"
25
-
26
- context "when RSpec::Matchers has been included in an example group" do
27
- include RSpec::Matchers
28
- it_behaves_like "a normal module with a method that supers"
29
- end
30
-
31
- context "when a module that includes RSpec::Matchers has been included in an example group" do
32
- include RSpec::Matchers::ModThatIncludesMatchers
33
- it_behaves_like "a normal module with a method that supers"
34
- end
35
-
36
- context "when RSpec::Matchers is included via configuration", :include_rspec_matchers => true do
37
- it_behaves_like "a normal module with a method that supers"
38
- end
39
-
40
- context "when RSpec::Matchers is included in a module that is included via configuration", :include_mod_that_includes_rspec_matchers => true do
41
- it_behaves_like "a normal module with a method that supers"
42
- end
43
- end
44
- end
45
-
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module RSpec
4
- module Core
5
- describe RubyProject do
6
-
7
- describe "#determine_root" do
8
-
9
- context "with ancestor containing spec directory" do
10
- it "returns ancestor containing the spec directory" do
11
- RubyProject.stub(:ascend_until).and_return('foodir')
12
- expect(RubyProject.determine_root).to eq("foodir")
13
- end
14
- end
15
-
16
- context "without ancestor containing spec directory" do
17
- it "returns current working directory" do
18
- RubyProject.stub(:find_first_parent_containing).and_return(nil)
19
- expect(RubyProject.determine_root).to eq(".")
20
- end
21
- end
22
-
23
- end
24
- end
25
- end
26
- end