rspec-core 2.0.0.beta.15 → 2.0.0.beta.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/Gemfile +2 -0
  2. data/VERSION +1 -1
  3. data/features/README.markdown +12 -0
  4. data/features/command_line/example_name_option.feature +9 -9
  5. data/features/command_line/line_number_appended_to_path.feature +44 -44
  6. data/features/command_line/line_number_option.feature +4 -4
  7. data/features/configuration/custom_settings.feature +3 -3
  8. data/features/configuration/options_file.feature +3 -3
  9. data/features/example_groups/describe_aliases.feature +1 -1
  10. data/features/example_groups/nested_groups.feature +7 -7
  11. data/features/filtering/inclusion_filters.feature +10 -10
  12. data/features/formatters/custom_formatter.feature +1 -1
  13. data/features/hooks/around_hooks.feature +13 -13
  14. data/features/hooks/before_and_after_hooks.feature +38 -16
  15. data/features/hooks/described_class.feature +1 -1
  16. data/features/hooks/halt.feature +1 -1
  17. data/features/mock_framework_integration/use_flexmock.feature +1 -1
  18. data/features/mock_framework_integration/use_mocha.feature +1 -1
  19. data/features/mock_framework_integration/use_rr.feature +1 -1
  20. data/features/mock_framework_integration/use_rspec.feature +1 -1
  21. data/features/pending/pending_examples.feature +13 -13
  22. data/features/subject/explicit_subject.feature +4 -4
  23. data/features/subject/implicit_subject.feature +2 -2
  24. data/lib/rspec/core/backward_compatibility.rb +0 -6
  25. data/lib/rspec/core/command_line.rb +16 -27
  26. data/lib/rspec/core/configuration.rb +13 -4
  27. data/lib/rspec/core/example.rb +3 -2
  28. data/lib/rspec/core/formatters.rb +2 -11
  29. data/lib/rspec/core/formatters/base_formatter.rb +7 -3
  30. data/lib/rspec/core/formatters/base_text_formatter.rb +4 -0
  31. data/lib/rspec/core/formatters/html_formatter.rb +350 -0
  32. data/lib/rspec/core/formatters/snippet_extractor.rb +52 -0
  33. data/lib/rspec/core/formatters/text_mate_formatter.rb +18 -0
  34. data/lib/rspec/core/mocking/with_rspec.rb +6 -6
  35. data/lib/rspec/core/option_parser.rb +2 -0
  36. data/lib/rspec/core/runner.rb +11 -11
  37. data/lib/rspec/core/world.rb +10 -13
  38. data/rspec-core.gemspec +26 -10
  39. data/spec/rspec/core/command_line_spec.rb +1 -9
  40. data/spec/rspec/core/configuration_spec.rb +31 -15
  41. data/spec/rspec/core/drb_command_line_spec.rb +42 -34
  42. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +280 -0
  43. data/spec/rspec/core/formatters/html_formatted-1.9.1.html +260 -0
  44. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +260 -0
  45. data/spec/rspec/core/formatters/html_formatter_spec.rb +71 -0
  46. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +18 -0
  47. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +280 -0
  48. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +67 -0
  49. data/spec/rspec/core/resources/formatter_specs.rb +36 -0
  50. data/spec/rspec/core/shared_example_group_spec.rb +12 -12
  51. data/spec/spec_helper.rb +26 -21
  52. metadata +28 -12
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+ require 'nokogiri'
3
+
4
+ module RSpec
5
+ module Core
6
+ module Formatters
7
+ describe TextMateFormatter do
8
+ let(:jruby?) { ::RUBY_PLATFORM == 'java' }
9
+ let(:root) { File.expand_path("#{File.dirname(__FILE__)}/../../../..") }
10
+ let(:suffix) { jruby? ? '-jruby' : '' }
11
+
12
+ let(:expected_file) do
13
+ "#{File.dirname(__FILE__)}/text_mate_formatted-#{::RUBY_VERSION}#{suffix}.html"
14
+ end
15
+
16
+ let(:generated_html) do
17
+ options = RSpec::Core::ConfigurationOptions.new(
18
+ %w[spec/rspec/core/resources/formatter_specs.rb --format textmate]
19
+ )
20
+ options.parse_options
21
+ err, out = StringIO.new, StringIO.new
22
+ command_line = RSpec::Core::CommandLine.new(options)
23
+ command_line.run(err, out)
24
+ out.string.gsub /\d+\.\d+ seconds/, 'x seconds'
25
+ end
26
+
27
+ let(:expected_html) do
28
+ raise "There is no HTML file with expected content for this platform: #{expected_file}" unless File.file?(expected_file)
29
+ File.read(expected_file)
30
+ end
31
+
32
+ before do
33
+ RSpec.configuration.stub(:require_files_to_run) do
34
+ RSpec.configuration.files_to_run.map {|f| load File.expand_path(f) }
35
+ end
36
+ end
37
+
38
+ # Uncomment this group temporarily in order to overwrite the expected
39
+ # with actual. Use with care!!!
40
+ # describe "file generator" do
41
+ # it "generates a new comparison file" do
42
+ # Dir.chdir(root) do
43
+ # File.open(expected_file, 'w') {|io| io.write(generated_html)}
44
+ # end
45
+ # end
46
+ # end
47
+
48
+ it "should produce HTML identical to the one we designed manually" do
49
+ Dir.chdir(root) do
50
+ actual_doc = Nokogiri::HTML(generated_html)
51
+ backtrace_lines = actual_doc.search("div.backtrace a")
52
+ actual_doc.search("div.backtrace").remove
53
+
54
+ expected_doc = Nokogiri::HTML(expected_html)
55
+ expected_doc.search("div.backtrace").remove
56
+
57
+ actual_doc.inner_html.should == expected_doc.inner_html
58
+
59
+ backtrace_lines.each do |backtrace_line|
60
+ backtrace_line['href'].should include("txmt://open?url=")
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,36 @@
1
+ # Deliberately named _specs.rb to avoid being loaded except when specified
2
+
3
+
4
+ describe "pending spec with no implementation" do
5
+ it "is pending"
6
+ end
7
+
8
+ describe "pending command with block format" do
9
+ context "with content that would fail" do
10
+ it "is pending" do
11
+ pending do
12
+ 1.should eq(2)
13
+ end
14
+ end
15
+ end
16
+
17
+ context "with content that would pass" do
18
+ it "fails" do
19
+ pending do
20
+ 1.should eq(1)
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ describe "passing spec" do
27
+ it "passes" do
28
+ 1.should eq(1)
29
+ end
30
+ end
31
+
32
+ describe "failing spec" do
33
+ it "fails" do
34
+ 1.should eq(2)
35
+ end
36
+ end
@@ -3,7 +3,6 @@ require 'spec_helper'
3
3
  module RSpec::Core
4
4
 
5
5
  describe SharedExampleGroup do
6
-
7
6
  it "should add the 'share_examples_for' method to the global namespace" do
8
7
  Kernel.should respond_to(:share_examples_for)
9
8
  end
@@ -131,8 +130,12 @@ module RSpec::Core
131
130
  describe "running shared examples" do
132
131
  module ::RunningSharedExamplesJustForTesting; end
133
132
 
133
+ let(:group) do
134
+ ExampleGroup.describe("example group")
135
+ end
136
+
134
137
  before(:each) do
135
- share_examples_for("it runs shared examples") do
138
+ group.share_examples_for("it runs shared examples") do
136
139
  include ::RunningSharedExamplesJustForTesting
137
140
 
138
141
  class << self
@@ -166,19 +169,16 @@ module RSpec::Core
166
169
  end
167
170
  end
168
171
 
169
- let(:group) do
170
- group = ExampleGroup.describe("example group") do
171
- it_should_behave_like "it runs shared examples"
172
- it "has one example" do; end
173
- it "has another example" do; end
174
- it "includes modules, included into shared example_group, into current example_group", :compat => 'rspec-1.2' do
175
- raise "FAIL" unless example.example_group.included_modules.include?(RunningSharedExamplesJustForTesting)
176
- end
172
+ before do
173
+ group.it_should_behave_like "it runs shared examples"
174
+ group.it "has one example" do; end
175
+ group.it "has another example" do; end
176
+ group.it "includes modules, included into shared example_group, into current example_group", :compat => 'rspec-1.2' do
177
+ raise "FAIL" unless example.example_group.included_modules.include?(RunningSharedExamplesJustForTesting)
177
178
  end
179
+ group.run_all
178
180
  end
179
181
 
180
- before { group.run_all }
181
-
182
182
  it "runs before(:all) only once from shared example_group", :compat => 'rspec-1.2' do
183
183
  group.magic[:before_all].should eq("before all 1")
184
184
  end
@@ -1,19 +1,9 @@
1
- require 'rubygems'
1
+ require 'bundler'
2
+ Bundler.setup
2
3
 
3
- $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
4
+ # TODO (DC 2010-07-04) This next line is necessary when running 'rake spec'.
5
+ # Why doesn't the rspec-core ref in Gemfile handle this.
4
6
  require 'rspec/core'
5
-
6
- $LOAD_PATH << File.expand_path('../../../rspec-expectations/lib', __FILE__)
7
- $LOAD_PATH << File.expand_path('../../../rspec-mocks/lib', __FILE__)
8
- require 'rspec/expectations'
9
- require 'rspec/mocks'
10
-
11
- begin
12
- require 'autotest'
13
- rescue LoadError
14
- raise "Could not load autotest."
15
- end
16
-
17
7
  require 'autotest/rspec2'
18
8
 
19
9
  Dir['./spec/support/**/*.rb'].map {|f| require f}
@@ -44,6 +34,25 @@ class RSpec::Core::ExampleGroup
44
34
  end
45
35
  end
46
36
 
37
+ def sandboxed(&block)
38
+ begin
39
+ @orig_config = RSpec.configuration
40
+ @orig_world = RSpec.world
41
+ new_config = RSpec::Core::Configuration.new
42
+ new_world = RSpec::Core::World.new(new_config)
43
+ RSpec.instance_variable_set(:@configuration, new_config)
44
+ RSpec.instance_variable_set(:@world, new_world)
45
+ object = Object.new
46
+ object.extend(RSpec::Core::ObjectExtensions)
47
+ object.extend(RSpec::Core::SharedExampleGroup)
48
+
49
+ object.instance_eval(&block)
50
+ ensure
51
+ RSpec.instance_variable_set(:@configuration, @orig_config)
52
+ RSpec.instance_variable_set(:@world, @orig_world)
53
+ end
54
+ end
55
+
47
56
  def in_editor?
48
57
  ENV.has_key?('TM_MODE') || ENV.has_key?('EMACS') || ENV.has_key?('VIM')
49
58
  end
@@ -54,17 +63,13 @@ RSpec.configure do |c|
54
63
  c.run_all_when_everything_filtered = true
55
64
  c.filter_run_excluding :ruby => lambda {|version|
56
65
  case version.to_s
57
- when "!ruby"
66
+ when "!jruby"
58
67
  RUBY_ENGINE != "jruby"
59
68
  else
60
69
  !(RUBY_VERSION.to_s =~ /^#{version.to_s}/)
61
70
  end
62
71
  }
63
- c.before(:each) do
64
- @real_world = RSpec.world
65
- RSpec.instance_variable_set(:@world, RSpec::Core::World.new)
66
- end
67
- c.after(:each) do
68
- RSpec.instance_variable_set(:@world, @real_world)
72
+ c.around do |example|
73
+ sandboxed { example.run }
69
74
  end
70
75
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-core
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196477
4
+ hash: 62196419
5
5
  prerelease: true
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
9
  - 0
10
10
  - beta
11
- - 15
12
- version: 2.0.0.beta.15
11
+ - 16
12
+ version: 2.0.0.beta.16
13
13
  platform: ruby
14
14
  authors:
15
15
  - Chad Humphries
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2010-06-30 00:00:00 -05:00
21
+ date: 2010-07-06 00:00:00 -05:00
22
22
  default_executable: rspec
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- hash: 62196477
33
+ hash: 62196419
34
34
  segments:
35
35
  - 2
36
36
  - 0
37
37
  - 0
38
38
  - beta
39
- - 15
40
- version: 2.0.0.beta.15
39
+ - 16
40
+ version: 2.0.0.beta.16
41
41
  requirement: *id001
42
42
  - !ruby/object:Gem::Dependency
43
43
  type: :development
@@ -48,14 +48,14 @@ dependencies:
48
48
  requirements:
49
49
  - - ">="
50
50
  - !ruby/object:Gem::Version
51
- hash: 62196477
51
+ hash: 62196419
52
52
  segments:
53
53
  - 2
54
54
  - 0
55
55
  - 0
56
56
  - beta
57
- - 15
58
- version: 2.0.0.beta.15
57
+ - 16
58
+ version: 2.0.0.beta.16
59
59
  requirement: *id002
60
60
  - !ruby/object:Gem::Dependency
61
61
  type: :development
@@ -111,6 +111,7 @@ files:
111
111
  - autotest/discover.rb
112
112
  - bin/rspec
113
113
  - cucumber.yml
114
+ - features/README.markdown
114
115
  - features/command_line/example_name_option.feature
115
116
  - features/command_line/exit_status.feature
116
117
  - features/command_line/line_number_appended_to_path.feature
@@ -151,7 +152,10 @@ files:
151
152
  - lib/rspec/core/formatters/base_text_formatter.rb
152
153
  - lib/rspec/core/formatters/documentation_formatter.rb
153
154
  - lib/rspec/core/formatters/helpers.rb
155
+ - lib/rspec/core/formatters/html_formatter.rb
154
156
  - lib/rspec/core/formatters/progress_formatter.rb
157
+ - lib/rspec/core/formatters/snippet_extractor.rb
158
+ - lib/rspec/core/formatters/text_mate_formatter.rb
155
159
  - lib/rspec/core/hooks.rb
156
160
  - lib/rspec/core/kernel_extensions.rb
157
161
  - lib/rspec/core/let.rb
@@ -190,7 +194,14 @@ files:
190
194
  - spec/rspec/core/formatters/base_text_formatter_spec.rb
191
195
  - spec/rspec/core/formatters/documentation_formatter_spec.rb
192
196
  - spec/rspec/core/formatters/helpers_spec.rb
197
+ - spec/rspec/core/formatters/html_formatted-1.8.7.html
198
+ - spec/rspec/core/formatters/html_formatted-1.9.1.html
199
+ - spec/rspec/core/formatters/html_formatted-1.9.2.html
200
+ - spec/rspec/core/formatters/html_formatter_spec.rb
193
201
  - spec/rspec/core/formatters/progress_formatter_spec.rb
202
+ - spec/rspec/core/formatters/snippet_extractor_spec.rb
203
+ - spec/rspec/core/formatters/text_mate_formatted-1.8.7.html
204
+ - spec/rspec/core/formatters/text_mate_formatter_spec.rb
194
205
  - spec/rspec/core/hooks_spec.rb
195
206
  - spec/rspec/core/kernel_extensions_spec.rb
196
207
  - spec/rspec/core/let_spec.rb
@@ -201,6 +212,7 @@ files:
201
212
  - spec/rspec/core/resources/a_foo.rb
202
213
  - spec/rspec/core/resources/a_spec.rb
203
214
  - spec/rspec/core/resources/custom_example_group_runner.rb
215
+ - spec/rspec/core/resources/formatter_specs.rb
204
216
  - spec/rspec/core/resources/utf8_encoded.rb
205
217
  - spec/rspec/core/ruby_project_spec.rb
206
218
  - spec/rspec/core/runner_spec.rb
@@ -218,7 +230,7 @@ licenses: []
218
230
  post_install_message: |
219
231
  **************************************************
220
232
 
221
- Thank you for installing rspec-core-2.0.0.beta.15
233
+ Thank you for installing rspec-core-2.0.0.beta.16
222
234
 
223
235
  **************************************************
224
236
 
@@ -252,7 +264,7 @@ rubyforge_project: rspec
252
264
  rubygems_version: 1.3.7
253
265
  signing_key:
254
266
  specification_version: 3
255
- summary: rspec-core-2.0.0.beta.15
267
+ summary: rspec-core-2.0.0.beta.16
256
268
  test_files:
257
269
  - spec/autotest/failed_results_re_spec.rb
258
270
  - spec/autotest/rspec_spec.rb
@@ -268,7 +280,10 @@ test_files:
268
280
  - spec/rspec/core/formatters/base_text_formatter_spec.rb
269
281
  - spec/rspec/core/formatters/documentation_formatter_spec.rb
270
282
  - spec/rspec/core/formatters/helpers_spec.rb
283
+ - spec/rspec/core/formatters/html_formatter_spec.rb
271
284
  - spec/rspec/core/formatters/progress_formatter_spec.rb
285
+ - spec/rspec/core/formatters/snippet_extractor_spec.rb
286
+ - spec/rspec/core/formatters/text_mate_formatter_spec.rb
272
287
  - spec/rspec/core/hooks_spec.rb
273
288
  - spec/rspec/core/kernel_extensions_spec.rb
274
289
  - spec/rspec/core/let_spec.rb
@@ -279,6 +294,7 @@ test_files:
279
294
  - spec/rspec/core/resources/a_foo.rb
280
295
  - spec/rspec/core/resources/a_spec.rb
281
296
  - spec/rspec/core/resources/custom_example_group_runner.rb
297
+ - spec/rspec/core/resources/formatter_specs.rb
282
298
  - spec/rspec/core/resources/utf8_encoded.rb
283
299
  - spec/rspec/core/ruby_project_spec.rb
284
300
  - spec/rspec/core/runner_spec.rb