rspec-core 2.11.1 → 2.12.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 (116) hide show
  1. data/Changelog.md +59 -0
  2. data/README.md +22 -0
  3. data/features/command_line/example_name_option.feature +5 -5
  4. data/features/command_line/exit_status.feature +6 -6
  5. data/features/command_line/format_option.feature +2 -2
  6. data/features/command_line/line_number_appended_to_path.feature +2 -2
  7. data/features/command_line/line_number_option.feature +2 -2
  8. data/features/command_line/pattern_option.feature +2 -2
  9. data/features/command_line/rake_task.feature +62 -8
  10. data/features/command_line/ruby.feature +1 -1
  11. data/features/command_line/tag.feature +1 -1
  12. data/features/configuration/alias_example_to.feature +2 -2
  13. data/features/configuration/custom_settings.feature +3 -3
  14. data/features/configuration/default_path.feature +3 -3
  15. data/features/configuration/fail_fast.feature +5 -5
  16. data/features/configuration/read_options_from_file.feature +4 -4
  17. data/features/example_groups/basic_structure.feature +2 -2
  18. data/features/example_groups/shared_context.feature +3 -3
  19. data/features/example_groups/shared_examples.feature +25 -7
  20. data/features/expectation_framework_integration/configure_expectation_framework.feature +6 -6
  21. data/features/filtering/exclusion_filters.feature +5 -5
  22. data/features/filtering/if_and_unless.feature +5 -5
  23. data/features/filtering/inclusion_filters.feature +5 -5
  24. data/features/filtering/run_all_when_everything_filtered.feature +3 -3
  25. data/features/formatters/custom_formatter.feature +2 -2
  26. data/features/formatters/json_formatter.feature +30 -0
  27. data/features/formatters/text_formatter.feature +5 -5
  28. data/features/helper_methods/arbitrary_methods.feature +2 -2
  29. data/features/helper_methods/let.feature +2 -2
  30. data/features/helper_methods/modules.feature +6 -6
  31. data/features/hooks/around_hooks.feature +11 -11
  32. data/features/hooks/before_and_after_hooks.feature +15 -11
  33. data/features/hooks/filtering.feature +6 -6
  34. data/features/metadata/current_example.feature +1 -1
  35. data/features/metadata/described_class.feature +1 -1
  36. data/features/metadata/user_defined.feature +4 -4
  37. data/features/mock_framework_integration/use_any_framework.feature +6 -6
  38. data/features/mock_framework_integration/use_flexmock.feature +5 -5
  39. data/features/mock_framework_integration/use_mocha.feature +5 -5
  40. data/features/mock_framework_integration/use_rr.feature +5 -5
  41. data/features/mock_framework_integration/use_rspec.feature +5 -5
  42. data/features/pending/pending_examples.feature +11 -11
  43. data/features/spec_files/arbitrary_file_suffix.feature +1 -1
  44. data/features/step_definitions/additional_cli_steps.rb +2 -0
  45. data/features/subject/attribute_of_subject.feature +5 -5
  46. data/features/subject/explicit_subject.feature +5 -5
  47. data/features/subject/implicit_receiver.feature +2 -2
  48. data/features/subject/implicit_subject.feature +3 -3
  49. data/lib/autotest/rspec2.rb +1 -1
  50. data/lib/rspec/core.rb +53 -32
  51. data/lib/rspec/core/configuration.rb +123 -15
  52. data/lib/rspec/core/configuration_options.rb +17 -2
  53. data/lib/rspec/core/example.rb +5 -4
  54. data/lib/rspec/core/example_group.rb +19 -9
  55. data/lib/rspec/core/extensions/ordered.rb +12 -6
  56. data/lib/rspec/core/formatters.rb +55 -0
  57. data/lib/rspec/core/formatters/base_formatter.rb +43 -38
  58. data/lib/rspec/core/formatters/base_text_formatter.rb +9 -5
  59. data/lib/rspec/core/formatters/documentation_formatter.rb +1 -1
  60. data/lib/rspec/core/formatters/helpers.rb +30 -5
  61. data/lib/rspec/core/formatters/html_formatter.rb +58 -368
  62. data/lib/rspec/core/formatters/html_printer.rb +407 -0
  63. data/lib/rspec/core/formatters/json_formatter.rb +73 -0
  64. data/lib/rspec/core/formatters/snippet_extractor.rb +3 -1
  65. data/lib/rspec/core/hooks.rb +4 -4
  66. data/lib/rspec/core/metadata.rb +14 -6
  67. data/lib/rspec/core/mocking/with_mocha.rb +25 -2
  68. data/lib/rspec/core/mocking/with_rspec.rb +6 -2
  69. data/lib/rspec/core/option_parser.rb +28 -7
  70. data/lib/rspec/core/project_initializer.rb +0 -1
  71. data/lib/rspec/core/rake_task.rb +49 -38
  72. data/lib/rspec/core/reporter.rb +2 -2
  73. data/lib/rspec/core/shared_example_group.rb +89 -41
  74. data/lib/rspec/core/subject.rb +6 -2
  75. data/lib/rspec/core/version.rb +1 -1
  76. data/lib/rspec/core/world.rb +2 -2
  77. data/spec/autotest/rspec_spec.rb +6 -1
  78. data/spec/command_line/order_spec.rb +67 -0
  79. data/spec/rspec/core/configuration_options_spec.rb +45 -38
  80. data/spec/rspec/core/configuration_spec.rb +219 -44
  81. data/spec/rspec/core/deprecations_spec.rb +9 -0
  82. data/spec/rspec/core/drb_command_line_spec.rb +1 -7
  83. data/spec/rspec/core/drb_options_spec.rb +1 -1
  84. data/spec/rspec/core/dsl_spec.rb +17 -9
  85. data/spec/rspec/core/example_group_spec.rb +51 -5
  86. data/spec/rspec/core/example_spec.rb +39 -7
  87. data/spec/rspec/core/filter_manager_spec.rb +20 -30
  88. data/spec/rspec/core/formatters/base_formatter_spec.rb +29 -1
  89. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +6 -2
  90. data/spec/rspec/core/formatters/helpers_spec.rb +12 -0
  91. data/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +462 -0
  92. data/spec/rspec/core/formatters/html_formatted-1.9.2-jruby.html +410 -0
  93. data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +462 -0
  94. data/spec/rspec/core/formatters/html_formatter_spec.rb +11 -3
  95. data/spec/rspec/core/formatters/json_formatter_spec.rb +110 -0
  96. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +8 -0
  97. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-rbx.html +462 -0
  98. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2-jruby.html +410 -0
  99. data/spec/rspec/core/formatters/text_mate_formatted-1.9.3-rbx.html +462 -0
  100. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +11 -3
  101. data/spec/rspec/core/hooks_filtering_spec.rb +6 -6
  102. data/spec/rspec/core/metadata_spec.rb +29 -0
  103. data/spec/rspec/core/option_parser_spec.rb +42 -0
  104. data/spec/rspec/core/project_initializer_spec.rb +2 -2
  105. data/spec/rspec/core/rake_task_spec.rb +60 -17
  106. data/spec/rspec/core/reporter_spec.rb +17 -0
  107. data/spec/rspec/core/runner_spec.rb +1 -0
  108. data/spec/rspec/core/shared_example_group_spec.rb +17 -5
  109. data/spec/rspec/core/subject_spec.rb +11 -0
  110. data/spec/spec_helper.rb +32 -2
  111. data/spec/support/config_options_helper.rb +1 -10
  112. data/spec/support/helper_methods.rb +13 -0
  113. data/spec/support/isolated_directory.rb +10 -0
  114. data/spec/support/isolated_home_directory.rb +16 -0
  115. metadata +145 -148
  116. data/lib/rspec/core/extensions.rb +0 -4
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'spec_helper'
2
3
  require 'rspec/core/formatters/text_mate_formatter'
3
4
  require 'nokogiri'
@@ -6,10 +7,17 @@ module RSpec
6
7
  module Core
7
8
  module Formatters
8
9
  describe TextMateFormatter do
9
- let(:jruby?) { ::RUBY_PLATFORM == 'java' }
10
- let(:root) { File.expand_path("#{File.dirname(__FILE__)}/../../../..") }
11
- let(:suffix) { jruby? ? '-jruby' : '' }
10
+ let(:suffix) {
11
+ if ::RUBY_PLATFORM == 'java'
12
+ "-jruby"
13
+ elsif defined?(Rubinius)
14
+ "-rbx"
15
+ else
16
+ ""
17
+ end
18
+ }
12
19
 
20
+ let(:root) { File.expand_path("#{File.dirname(__FILE__)}/../../../..") }
13
21
  let(:expected_file) do
14
22
  "#{File.dirname(__FILE__)}/text_mate_formatted-#{::RUBY_VERSION}#{suffix}.html"
15
23
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  module RSpec::Core
4
4
  describe "config block hook filtering" do
5
5
  describe "unfiltered hooks" do
6
- it "should be ran" do
6
+ it "is run" do
7
7
  filters = []
8
8
  RSpec.configure do |c|
9
9
  c.before(:all) { filters << "before all in config"}
@@ -28,7 +28,7 @@ module RSpec::Core
28
28
  describe "hooks with single filters" do
29
29
 
30
30
  context "with no scope specified" do
31
- it "should be ran around|before|after :each if the filter matches the example group's filter" do
31
+ it "is run around|before|after :each if the filter matches the example group's filter" do
32
32
  filters = []
33
33
  RSpec.configure do |c|
34
34
  c.around(:match => true) {|example| filters << "around each in config"; example.run}
@@ -46,7 +46,7 @@ module RSpec::Core
46
46
  end
47
47
  end
48
48
 
49
- it "should be ran if the filter matches the example group's filter" do
49
+ it "is run if the filter matches the example group's filter" do
50
50
  filters = []
51
51
  RSpec.configure do |c|
52
52
  c.before(:all, :match => true) { filters << "before all in config"}
@@ -116,7 +116,7 @@ module RSpec::Core
116
116
  filters.should eq([:before_all, :after_all])
117
117
  end
118
118
 
119
- it "should not be ran if the filter doesn't match the example group's filter" do
119
+ it "does not run if the filter doesn't match the example group's filter" do
120
120
  filters = []
121
121
  RSpec.configure do |c|
122
122
  c.before(:all, :match => false) { filters << "before all in config"}
@@ -187,7 +187,7 @@ module RSpec::Core
187
187
  end
188
188
 
189
189
  describe "hooks with multiple filters" do
190
- it "should be ran if all hook filters match the group's filters" do
190
+ it "is run if all hook filters match the group's filters" do
191
191
  filters = []
192
192
  RSpec.configure do |c|
193
193
  c.before(:all, :one => 1) { filters << "before all in config"}
@@ -208,7 +208,7 @@ module RSpec::Core
208
208
  ])
209
209
  end
210
210
 
211
- it "should not be ran if some hook filters don't match the group's filters" do
211
+ it "does not run if some hook filters don't match the group's filters" do
212
212
  filters = []
213
213
  RSpec.configure do |c|
214
214
  c.before(:all, :one => 1, :four => 4) { filters << "before all in config"}
@@ -4,6 +4,28 @@ module RSpec
4
4
  module Core
5
5
  describe Metadata do
6
6
 
7
+ describe '.relative_path' do
8
+ let(:here) { File.expand_path(".") }
9
+ it "transforms absolute paths to relative paths" do
10
+ Metadata.relative_path(here).should == "."
11
+ end
12
+ it "transforms absolute paths to relative paths anywhere in its argument" do
13
+ Metadata.relative_path("foo #{here} bar").should == "foo . bar"
14
+ end
15
+ it "returns nil if passed an unparseable file:line combo" do
16
+ Metadata.relative_path("-e:1").should be_nil
17
+ end
18
+ # I have no idea what line = line.sub(/\A([^:]+:\d+)$/, '\\1') is supposed to do
19
+ it "gracefully returns nil if run in a secure thread" do
20
+ safely do
21
+ value = Metadata.relative_path(".")
22
+ # on some rubies, File.expand_path is not a security error, so accept "." as well
23
+ [nil, "."].should include(value)
24
+ end
25
+ end
26
+
27
+ end
28
+
7
29
  describe "#process" do
8
30
  Metadata::RESERVED_KEYS.each do |key|
9
31
  it "prohibits :#{key} as a hash key" do
@@ -186,26 +208,32 @@ module RSpec
186
208
  let(:line_number) { __LINE__ - 1 }
187
209
 
188
210
  it "stores the description" do
211
+ mfe.fetch(:description).should eq("example description")
189
212
  mfe[:description].should eq("example description")
190
213
  end
191
214
 
192
215
  it "stores the full_description (group description + example description)" do
216
+ mfe.fetch(:full_description).should eq("group description example description")
193
217
  mfe[:full_description].should eq("group description example description")
194
218
  end
195
219
 
196
220
  it "creates an empty execution result" do
221
+ mfe.fetch(:execution_result).should eq({})
197
222
  mfe[:execution_result].should eq({})
198
223
  end
199
224
 
200
225
  it "extracts file path from caller" do
226
+ mfe.fetch(:file_path).should eq(relative_path(__FILE__))
201
227
  mfe[:file_path].should eq(relative_path(__FILE__))
202
228
  end
203
229
 
204
230
  it "extracts line number from caller" do
231
+ mfe.fetch(:line_number).should eq(line_number)
205
232
  mfe[:line_number].should eq(line_number)
206
233
  end
207
234
 
208
235
  it "extracts location from caller" do
236
+ mfe.fetch(:location).should eq("#{relative_path(__FILE__)}:#{line_number}")
209
237
  mfe[:location].should eq("#{relative_path(__FILE__)}:#{line_number}")
210
238
  end
211
239
 
@@ -215,6 +243,7 @@ module RSpec
215
243
  end
216
244
 
217
245
  it "merges arbitrary options" do
246
+ mfe.fetch(:arbitrary).should eq(:options)
218
247
  mfe[:arbitrary].should eq(:options)
219
248
  end
220
249
 
@@ -15,6 +15,17 @@ module RSpec::Core
15
15
  parser.parse!([])
16
16
  end
17
17
 
18
+ it "proposes you to use --help and returns an error on incorrect argument" do
19
+ parser = Parser.new
20
+ option = "--my_wrong_arg"
21
+
22
+ parser.should_receive(:abort) do |msg|
23
+ expect(msg).to include('use --help', option)
24
+ end
25
+
26
+ parser.parse!([option])
27
+ end
28
+
18
29
  describe "--formatter" do
19
30
  it "is deprecated" do
20
31
  RSpec.should_receive(:deprecate)
@@ -27,6 +38,37 @@ module RSpec::Core
27
38
  end
28
39
  end
29
40
 
41
+ describe "--default_path" do
42
+ it "gets converted to --default-path" do
43
+ options = Parser.parse!(%w[--default_path foo])
44
+ options[:default_path].should == "foo"
45
+ end
46
+ end
47
+
48
+ describe "--line_number" do
49
+ it "gets converted to --line-number" do
50
+ options = Parser.parse!(%w[--line_number 3])
51
+ options[:line_numbers].should == ["3"]
52
+ end
53
+ end
54
+
55
+
56
+ describe "--default-path" do
57
+ it "sets the default path where RSpec looks for examples" do
58
+ options = Parser.parse!(%w[--default-path foo])
59
+ options[:default_path].should == "foo"
60
+ end
61
+ end
62
+
63
+ %w[--line-number -l].each do |option|
64
+ describe option do
65
+ it "sets the line number of an example to run" do
66
+ options = Parser.parse!([option, "3"])
67
+ options[:line_numbers].should == ["3"]
68
+ end
69
+ end
70
+ end
71
+
30
72
  %w[--format -f].each do |option|
31
73
  describe option do
32
74
  it "defines the formatter" do
@@ -1,7 +1,8 @@
1
1
  require "spec_helper"
2
2
 
3
3
  module RSpec::Core
4
- describe ProjectInitializer, :fakefs do
4
+ describe ProjectInitializer, :isolated_directory => true do
5
+
5
6
  describe "#run" do
6
7
  context "with no args" do
7
8
  let(:command_line_config) { ProjectInitializer.new }
@@ -121,7 +122,6 @@ module RSpec::Core
121
122
  config = ProjectInitializer.new("another_arg")
122
123
  config.stub(:puts)
123
124
  config.stub(:gets => 'no')
124
- config.should_receive(:warn).with(/no longer.*another_arg was ignored/)
125
125
  config.run
126
126
  end
127
127
  end
@@ -19,6 +19,25 @@ module RSpec::Core
19
19
  task.__send__(:spec_command)
20
20
  end
21
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
+ task.name.should == :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
+ args[:files].should == "first_spec.rb"
34
+ end
35
+
36
+ task.should_receive(:run_task) { true }
37
+ Rake.application.invoke_task("rake_task_args[first_spec.rb]").should be_true
38
+ end
39
+ end
40
+
22
41
  context "default" do
23
42
  it "renders rspec" do
24
43
  spec_command.should =~ /^#{ruby} -S rspec/
@@ -27,10 +46,10 @@ module RSpec::Core
27
46
 
28
47
  context "with rcov" do
29
48
  it "renders rcov" do
30
- with_rcov do
31
- spec_command.should =~ /^#{ruby} -S rcov/
32
- end
49
+ with_rcov do
50
+ spec_command.should =~ /^#{ruby} -S rcov/
33
51
  end
52
+ end
34
53
  end
35
54
 
36
55
  context "with ruby options" do
@@ -80,31 +99,55 @@ module RSpec::Core
80
99
  end
81
100
  end
82
101
 
83
- context "with SPEC=path/to/file" do
84
- before do
85
- @orig_spec = ENV["SPEC"]
86
- ENV["SPEC"] = "path/to/file"
102
+ def specify_consistent_ordering_of_files_to_run(pattern, task)
103
+ orderings = [
104
+ %w[ a/1.rb a/2.rb a/3.rb ],
105
+ %w[ a/2.rb a/1.rb a/3.rb ],
106
+ %w[ a/3.rb a/2.rb a/1.rb ]
107
+ ].map do |files|
108
+ FileList.should_receive(:[]).with(pattern) { files }
109
+ task.__send__(:files_to_run)
87
110
  end
88
111
 
89
- after do
90
- ENV["SPEC"] = @orig_spec
91
- end
112
+ orderings.uniq.size.should eq(1)
113
+ end
92
114
 
115
+ context "with SPEC env var set" do
93
116
  it "sets files to run" do
94
- task.__send__(:files_to_run).should eq(["path/to/file"])
117
+ with_env_vars 'SPEC' => 'path/to/file' do
118
+ task.__send__(:files_to_run).should eq(["path/to/file"])
119
+ end
95
120
  end
96
- end
97
121
 
98
- context "with paths with quotes" do
99
- it "escapes the quotes" do
100
- task = RakeTask.new do |t|
101
- t.pattern = File.join(Dir.tmpdir, "*spec.rb")
122
+ it "sets the files to run in a consistent order, regardless of the underlying FileList ordering" do
123
+ with_env_vars 'SPEC' => 'a/*.rb' do
124
+ specify_consistent_ordering_of_files_to_run('a/*.rb', task)
102
125
  end
103
- ["first_spec.rb", "second_\"spec.rb", "third_\'spec.rb"].each do |file_name|
126
+ end
127
+ end
128
+
129
+ it "sets the files to run in a consistent order, regardless of the underlying FileList ordering" do
130
+ task = RakeTask.new(:consistent_file_order) do |t|
131
+ t.pattern = 'a/*.rb'
132
+ end
133
+
134
+ # since the config block is deferred til task invocation, must fake
135
+ # calling the task so the expected pattern is picked up
136
+ task.should_receive(:run_task) { true }
137
+ Rake.application.invoke_task(task.name).should be_true
138
+
139
+ specify_consistent_ordering_of_files_to_run('a/*.rb', task)
140
+ end
141
+
142
+ context "with paths with quotes or spaces" do
143
+ it "escapes the quotes and spaces" do
144
+ task.pattern = File.join(Dir.tmpdir, "*spec.rb")
145
+ ["first_spec.rb", "second_\"spec.rb", "third_\'spec.rb", "fourth spec.rb"].each do |file_name|
104
146
  FileUtils.touch(File.join(Dir.tmpdir, file_name))
105
147
  end
106
148
  task.__send__(:files_to_run).sort.should eq([
107
149
  File.join(Dir.tmpdir, "first_spec.rb"),
150
+ File.join(Dir.tmpdir, "fourth\\ spec.rb"),
108
151
  File.join(Dir.tmpdir, "second_\\\"spec.rb"),
109
152
  File.join(Dir.tmpdir, "third_\\\'spec.rb")
110
153
  ])
@@ -99,5 +99,22 @@ module RSpec::Core
99
99
  yielded.should eq(reporter)
100
100
  end
101
101
  end
102
+
103
+ describe "timing" do
104
+ it "uses RSpec::Core::Time as to not be affected by changes to time in examples" do
105
+ formatter = double(:formatter).as_null_object
106
+ reporter = Reporter.new formatter
107
+ reporter.start 1
108
+ Time.stub(:now => Time.utc(2012, 10, 1))
109
+
110
+ duration = nil
111
+ formatter.stub(:dump_summary) do |dur, _, _, _|
112
+ duration = dur
113
+ end
114
+
115
+ reporter.finish 1234
116
+ duration.should be < 0.2
117
+ end
118
+ end
102
119
  end
103
120
  end
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'rspec/core/drb_command_line'
2
3
 
3
4
  module RSpec::Core
4
5
  describe Runner do
@@ -6,18 +6,28 @@ module RSpec::Core
6
6
  ExampleModule = Module.new
7
7
  ExampleClass = Class.new
8
8
 
9
+ it 'does not add a bunch of private methods to Module' do
10
+ seg_methods = RSpec::Core::SharedExampleGroup.private_instance_methods
11
+ expect(Module.private_methods & seg_methods).to eq([])
12
+ end
13
+
9
14
  %w[share_examples_for shared_examples_for shared_examples shared_context].each do |shared_method_name|
10
15
  describe shared_method_name do
11
16
  it "is exposed to the global namespace" do
12
17
  Kernel.should respond_to(shared_method_name)
13
18
  end
14
19
 
15
- it "raises an ArgumentError when adding a second shared example group with the same name" do
20
+ it "displays a warning when adding a second shared example group with the same name" do
16
21
  group = ExampleGroup.describe('example group')
17
- group.send(shared_method_name, 'shared group') {}
18
- lambda do
19
- group.send(shared_method_name, 'shared group') {}
20
- end.should raise_error(ArgumentError, "Shared example group 'shared group' already exists")
22
+ group.send(shared_method_name, 'some shared group') {}
23
+ original_declaration = [__FILE__, __LINE__ - 1].join(':')
24
+
25
+ warning = nil
26
+ Kernel.stub(:warn) { |msg| warning = msg }
27
+
28
+ group.send(shared_method_name, 'some shared group') {}
29
+ second_declaration = [__FILE__, __LINE__ - 1].join(':')
30
+ warning.should include('some shared group', original_declaration, second_declaration)
21
31
  end
22
32
 
23
33
  ["name", :name, ExampleModule, ExampleClass].each do |object|
@@ -62,6 +72,8 @@ module RSpec::Core
62
72
  end
63
73
 
64
74
  describe "#share_as" do
75
+ before { RSpec.stub(:warn) }
76
+
65
77
  it "is exposed to the global namespace" do
66
78
  Kernel.should respond_to("share_as")
67
79
  end
@@ -91,6 +91,17 @@ module RSpec::Core
91
91
  end
92
92
  group.run.should be_true
93
93
  end
94
+
95
+ it "is referred from inside subject by the name" do
96
+ group = ExampleGroup.describe do
97
+ subject(:list) { [1,2,3] }
98
+ describe 'first' do
99
+ subject(:first_element) { list.first }
100
+ it { should eq(1) }
101
+ end
102
+ end
103
+ group.run.should be_true
104
+ end
94
105
  end
95
106
  end
96
107
 
@@ -18,7 +18,13 @@ Spork.prefork do
18
18
  require 'rspec/autorun'
19
19
  require 'autotest/rspec2'
20
20
  require 'aruba/api'
21
- require 'fakefs/spec_helpers'
21
+
22
+ if RUBY_PLATFORM == 'java'
23
+ # Works around https://jira.codehaus.org/browse/JRUBY-5678
24
+ require 'fileutils'
25
+ ENV['TMPDIR'] = File.expand_path('../../tmp', __FILE__)
26
+ FileUtils.mkdir_p(ENV['TMPDIR'])
27
+ end
22
28
 
23
29
  Dir['./spec/support/**/*.rb'].map {|f| require f}
24
30
 
@@ -66,6 +72,30 @@ Spork.prefork do
66
72
  ENV.has_key?('TM_MODE') || ENV.has_key?('EMACS') || ENV.has_key?('VIM')
67
73
  end
68
74
 
75
+ module EnvHelpers
76
+ def with_env_vars(vars)
77
+ original = ENV.to_hash
78
+ vars.each { |k, v| ENV[k] = v }
79
+
80
+ begin
81
+ yield
82
+ ensure
83
+ ENV.replace(original)
84
+ end
85
+ end
86
+
87
+ def without_env_vars(*vars)
88
+ original = ENV.to_hash
89
+ vars.each { |k| ENV.delete(k) }
90
+
91
+ begin
92
+ yield
93
+ ensure
94
+ ENV.replace(original)
95
+ end
96
+ end
97
+ end
98
+
69
99
  RSpec.configure do |c|
70
100
  # structural
71
101
  c.alias_it_behaves_like_to 'it_has_behavior'
@@ -79,7 +109,7 @@ Spork.prefork do
79
109
  c.treat_symbols_as_metadata_keys_with_true_values = true
80
110
  c.color = !in_editor?
81
111
  c.filter_run :focus
82
- c.include FakeFS::SpecHelpers, :fakefs
112
+ c.include EnvHelpers
83
113
  c.run_all_when_everything_filtered = true
84
114
  c.filter_run_excluding :ruby => lambda {|version|
85
115
  case version.to_s