rspec-core 2.0.0.beta.4 → 2.0.0.beta.5

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0.beta.4
1
+ 2.0.0.beta.5
@@ -33,3 +33,36 @@ Feature: explicit subject
33
33
  """
34
34
  When I run "rspec nested_subject_spec.rb"
35
35
  Then I should see "1 example, 0 failures"
36
+
37
+ @wip
38
+ Scenario: access subject from before block
39
+ Given a file named "top_level_subject_spec.rb" with:
40
+ """
41
+ describe Array, "with some elements" do
42
+ subject { [] }
43
+ before { subject += [1,2,3] }
44
+ it "should have the prescribed elements" do
45
+ subject.should == [1,2,3]
46
+ end
47
+ end
48
+ """
49
+ When I run "spec top_level_subject_spec.rb"
50
+ Then I should see "1 example, 0 failures"
51
+
52
+ Scenario: subject using helper method
53
+ Given a file named "helper_subject_spec.rb" with:
54
+ """
55
+ require 'rspec/expectations'
56
+
57
+ describe Array do
58
+ def prepared_array; [1,2,3] end
59
+ subject { prepared_array }
60
+ describe "with some elements" do
61
+ it "should have the prescribed elements" do
62
+ subject.should == [1,2,3]
63
+ end
64
+ end
65
+ end
66
+ """
67
+ When I run "rspec helper_subject_spec.rb"
68
+ Then I should see "1 example, 0 failures"
@@ -38,7 +38,11 @@ class Autotest::Rspec2 < Autotest
38
38
 
39
39
  def make_test_cmd(files_to_test)
40
40
  files_to_test.empty? ? '' :
41
- "#{ruby} #{SPEC_PROGRAM} #{normalize(files_to_test).keys.flatten.join(' ')} #{add_options_if_present}"
41
+ "#{ruby} #{require_rubygems}#{SPEC_PROGRAM} #{normalize(files_to_test).keys.flatten.join(' ')}"
42
+ end
43
+
44
+ def require_rubygems
45
+ defined?(:Gem) ? "-rrubygems " : ""
42
46
  end
43
47
 
44
48
  def normalize(files_to_test)
@@ -48,7 +52,4 @@ class Autotest::Rspec2 < Autotest
48
52
  end
49
53
  end
50
54
 
51
- def add_options_if_present # :nodoc:
52
- File.exist?("spec/spec.opts") ? "-O #{File.join('spec','spec.opts')} " : ""
53
- end
54
55
  end
@@ -26,7 +26,9 @@ module Rspec
26
26
  options[:color_enabled] = o
27
27
  end
28
28
 
29
- opts.on('-f', '--formatter [FORMATTER]', 'Choose an optional formatter') do |o|
29
+ opts.on('-f', '--formatter [FORMATTER]', 'Choose a formatter',
30
+ ' [p]rogress (default - dots)',
31
+ ' [d]ocumentation (group and example names)') do |o|
30
32
  options[:formatter] = o
31
33
  end
32
34
 
@@ -10,6 +10,8 @@ module Rspec
10
10
  # Run all examples if the run is filtered, and no examples were found.
11
11
  attr_writer :run_all_when_everything_filtered
12
12
 
13
+ attr_reader :options
14
+
13
15
  def initialize
14
16
  @run_all_when_everything_filtered = false
15
17
  @hooks = {
@@ -25,6 +27,7 @@ module Rspec
25
27
  {
26
28
  :color_enabled => false,
27
29
  :mock_framework => nil,
30
+ :use_transactional_examples => true,
28
31
  :profile_examples => false,
29
32
  :files_to_run => [],
30
33
  :filename_pattern => '**/*_spec.rb',
@@ -48,31 +51,29 @@ module Rspec
48
51
 
49
52
  def mock_framework=(use_me_to_mock)
50
53
  @options[:mock_framework] = use_me_to_mock
51
-
52
- mock_framework_class = case use_me_to_mock.to_s
53
- when /rspec/i
54
- require 'rspec/core/mocking/with_rspec'
55
- Rspec::Core::Mocking::WithRspec
54
+ end
55
+
56
+ def use_transactional_examples=(value)
57
+ @options[:use_transactional_examples] = value
58
+ end
59
+
60
+ def use_transactional_examples?
61
+ @options[:use_transactional_examples]
62
+ end
63
+
64
+ def require_mock_framework_adapter
65
+ require case @options[:mock_framework].to_s
66
+ when "", /rspec/i
67
+ 'rspec/core/mocking/with_rspec'
56
68
  when /mocha/i
57
- require 'rspec/core/mocking/with_mocha'
58
- Rspec::Core::Mocking::WithMocha
69
+ 'rspec/core/mocking/with_mocha'
59
70
  when /rr/i
60
- require 'rspec/core/mocking/with_rr'
61
- Rspec::Core::Mocking::WithRR
71
+ 'rspec/core/mocking/with_rr'
62
72
  when /flexmock/i
63
- require 'rspec/core/mocking/with_flexmock'
64
- Rspec::Core::Mocking::WithFlexmock
73
+ 'rspec/core/mocking/with_flexmock'
65
74
  else
66
- require 'rspec/core/mocking/with_absolutely_nothing'
67
- Rspec::Core::Mocking::WithAbsolutelyNothing
75
+ 'rspec/core/mocking/with_absolutely_nothing'
68
76
  end
69
-
70
- @options[:mock_framework_class] = mock_framework_class
71
- Rspec::Core::ExampleGroup.send(:include, mock_framework_class)
72
- end
73
-
74
- def mock_framework
75
- @options[:mock_framework]
76
77
  end
77
78
 
78
79
  def filename_pattern
@@ -136,7 +137,7 @@ EOM
136
137
 
137
138
  def formatter=(formatter_to_use)
138
139
  formatter_class = case formatter_to_use.to_s
139
- when /doc/, 's', 'n'
140
+ when 'd', 'doc', 'documentation', 's', 'n', 'spec', 'nested'
140
141
  Rspec::Core::Formatters::DocumentationFormatter
141
142
  when 'progress'
142
143
  Rspec::Core::Formatters::ProgressFormatter
@@ -224,6 +225,11 @@ EOM
224
225
  end.map { |filters, block| block }
225
226
  end
226
227
 
228
+ def configure_mock_framework
229
+ require_mock_framework_adapter
230
+ Rspec::Core::ExampleGroup.send(:include, Rspec::Core::MockFrameworkAdapter)
231
+ end
232
+
227
233
  end
228
234
  end
229
235
  end
@@ -110,7 +110,7 @@ module Rspec
110
110
  @_subclass_count ||= 0
111
111
  @_subclass_count += 1
112
112
  const_set(
113
- "NestedLevel_#{@_subclass_count}",
113
+ "Nested_#{@_subclass_count}",
114
114
  _build(Class.new(self), caller, args, &example_group_block)
115
115
  )
116
116
  end
@@ -9,7 +9,7 @@ module Rspec
9
9
  end
10
10
 
11
11
  def subject
12
- @subject ||= self.class.subject.call
12
+ @subject ||= instance_eval(&self.class.subject)
13
13
  end
14
14
 
15
15
  # When +should+ is called with no explicit receiver, the call is
@@ -52,8 +52,7 @@ module Rspec
52
52
  #
53
53
  # See +ExampleMethods#should+ for more information about this approach.
54
54
  def subject(&block)
55
- block.nil? ?
56
- explicit_subject || implicit_subject : @explicit_subject_block = block
55
+ block ? @explicit_subject_block = block : explicit_subject || implicit_subject
57
56
  end
58
57
 
59
58
  attr_reader :explicit_subject_block # :nodoc:
@@ -69,12 +68,9 @@ module Rspec
69
68
  end
70
69
 
71
70
  def implicit_subject
71
+ described = describes || description
72
72
  Class === described ? lambda { described.new } : lambda { described }
73
73
  end
74
-
75
- def described
76
- @described ||= describes || description
77
- end
78
74
  end
79
75
  end
80
76
  end
@@ -1,3 +1,4 @@
1
+ require 'rspec/core/formatters/helpers'
1
2
  require 'rspec/core/formatters/base_formatter'
2
3
  require 'rspec/core/formatters/base_text_formatter'
3
4
  require 'rspec/core/formatters/documentation_formatter'
@@ -5,6 +5,7 @@ module Rspec
5
5
  module Formatters
6
6
 
7
7
  class BaseFormatter
8
+ include Helpers
8
9
  attr_accessor :example_group
9
10
  attr_reader :example_count, :duration, :examples
10
11
 
@@ -98,6 +99,7 @@ module Rspec
98
99
 
99
100
  def backtrace_line(line)
100
101
  return nil if configuration.cleaned_from_backtrace?(line)
102
+ line.sub!(File.expand_path("."), ".")
101
103
  line.sub!(/\A([^:]+:\d+)$/, '\\1')
102
104
  return nil if line == '-e:1'
103
105
  line
@@ -122,4 +124,4 @@ module Rspec
122
124
  end
123
125
  end
124
126
 
125
- end
127
+ end
@@ -31,12 +31,13 @@ module Rspec
31
31
  def colorise(s, failure)
32
32
  red(s)
33
33
  end
34
-
34
+
35
35
  def dump_summary
36
36
  failure_count = failed_examples.size
37
37
  pending_count = pending_examples.size
38
+
38
39
 
39
- output.puts "\nFinished in #{duration} seconds\n"
40
+ output.puts "\nFinished in #{format_seconds(duration)} seconds\n"
40
41
 
41
42
  summary = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count} failures"
42
43
  summary << ", #{pending_count} pending" if pending_count > 0
@@ -56,7 +57,7 @@ module Rspec
56
57
  sorted_examples = examples.sort_by { |example| example.execution_result[:run_time] }.reverse.first(10)
57
58
  output.puts "\nTop #{sorted_examples.size} slowest examples:\n"
58
59
  sorted_examples.each do |example|
59
- output.puts " (#{sprintf("%.7f", example.execution_result[:run_time])} seconds) #{example}"
60
+ output.puts " (#{format_seconds(duration, 7)} seconds) #{example}"
60
61
  output.puts grey(" # #{format_caller(example.metadata[:caller])}")
61
62
  end
62
63
  end
@@ -64,11 +65,6 @@ module Rspec
64
65
  output.flush
65
66
  end
66
67
 
67
- # def textmate_link_backtrace(path)
68
- # file, line = path.split(':')
69
- # "txmt://open/?url=file://#{File.expand_path(file)}&line=#{line}"
70
- # end
71
-
72
68
  def format_caller(caller_info)
73
69
  caller_info.to_s.split(':in `block').first
74
70
  end
@@ -0,0 +1,27 @@
1
+ module Rspec
2
+
3
+ module Core
4
+
5
+ module Formatters
6
+
7
+ module Helpers
8
+ SUB_SECOND_PRECISION = 5
9
+ DEFAULT_PRECISION = 2
10
+
11
+ def format_seconds(float, precision = nil)
12
+ precision ||= (float < 1) ? SUB_SECOND_PRECISION : DEFAULT_PRECISION
13
+ formatted = sprintf("%.#{precision}f", float)
14
+ strip_trailing_zeroes(formatted)
15
+ end
16
+
17
+ def strip_trailing_zeroes(string)
18
+ string.sub(/[^1-9]+$/, '')
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -130,19 +130,24 @@ EOM
130
130
  end
131
131
 
132
132
  def file_path_from(metadata, given_file_path=nil)
133
- given_file_path || file_and_line_number(metadata)[0].strip
133
+ return given_file_path if given_file_path
134
+ file = file_and_line_number(metadata)[0] if file_and_line_number(metadata)
135
+ file.strip if file
134
136
  end
135
137
 
136
138
  def line_number_from(metadata, given_line_number=nil)
137
- given_line_number || file_and_line_number(metadata)[1].to_i
139
+ return given_line_number if given_line_number
140
+ line_number = file_and_line_number(metadata)[1] if file_and_line_number(metadata)
141
+ line_number && line_number.to_i
138
142
  end
139
-
143
+
140
144
  def location_from(metadata)
141
145
  "#{metadata[:file_path]}:#{metadata[:line_number]}"
142
146
  end
143
147
 
144
148
  def file_and_line_number(metadata)
145
- candidate_entries_from_caller(metadata).first.split(':')
149
+ entry = candidate_entries_from_caller(metadata).first
150
+ entry && entry.split(":")
146
151
  end
147
152
 
148
153
  def candidate_entries_from_caller(metadata)
@@ -1,13 +1,11 @@
1
1
  module Rspec
2
2
  module Core
3
- module Mocking
4
- module WithAbsolutelyNothing
3
+ module MockFrameworkAdapter
5
4
 
6
- def _setup_mocks; end
7
- def _verify_mocks; end
8
- def _teardown_mocks; end
5
+ def _setup_mocks; end
6
+ def _verify_mocks; end
7
+ def _teardown_mocks; end
9
8
 
10
- end
11
9
  end
12
10
  end
13
- end
11
+ end
@@ -7,19 +7,19 @@ require 'flexmock/rspec'
7
7
 
8
8
  module Rspec
9
9
  module Core
10
- module Mocking
11
- module WithFlexmock
12
- include FlexMock::MockContainer
13
- def setup_mocks_for_rspec
14
- # No setup required
15
- end
16
- def verify_mocks_for_rspec
17
- flexmock_verify
18
- end
19
- def teardown_mocks_for_rspec
20
- flexmock_close
21
- end
10
+ module MockFrameworkAdapter
11
+
12
+ include FlexMock::MockContainer
13
+ def setup_mocks_for_rspec
14
+ # No setup required
15
+ end
16
+ def verify_mocks_for_rspec
17
+ flexmock_verify
22
18
  end
19
+ def teardown_mocks_for_rspec
20
+ flexmock_close
21
+ end
22
+
23
23
  end
24
24
  end
25
- end
25
+ end
@@ -3,20 +3,19 @@ require 'mocha/object'
3
3
 
4
4
  module Rspec
5
5
  module Core
6
- module Mocking
7
- module WithMocha
8
- # Mocha::Standalone was deprecated as of Mocha 0.9.7.
9
- begin
10
- include Mocha::API
11
- rescue NameError
12
- include Mocha::Standalone
13
- end
14
-
15
- alias :_setup_mocks :mocha_setup
16
- alias :_verify_mocks :mocha_verify
17
- alias :_teardown_mocks :mocha_teardown
6
+ module MockFrameworkAdapter
18
7
 
8
+ # Mocha::Standalone was deprecated as of Mocha 0.9.7.
9
+ begin
10
+ include Mocha::API
11
+ rescue NameError
12
+ include Mocha::Standalone
19
13
  end
14
+
15
+ alias :_setup_mocks :mocha_setup
16
+ alias :_verify_mocks :mocha_verify
17
+ alias :_teardown_mocks :mocha_teardown
18
+
20
19
  end
21
20
  end
22
- end
21
+ end
@@ -4,23 +4,22 @@ Rspec.configuration.backtrace_clean_patterns.push(RR::Errors::BACKTRACE_IDENTIFI
4
4
 
5
5
  module Rspec
6
6
  module Core
7
- module Mocking
8
- module WithRR
9
- include RR::Extensions::InstanceMethods
7
+ module MockFrameworkAdapter
10
8
 
11
- def _setup_mocks
12
- RR::Space.instance.reset
13
- end
9
+ include RR::Extensions::InstanceMethods
14
10
 
15
- def _verify_mocks
16
- RR::Space.instance.verify_doubles
17
- end
11
+ def _setup_mocks
12
+ RR::Space.instance.reset
13
+ end
18
14
 
19
- def _teardown_mocks
20
- RR::Space.instance.reset
21
- end
15
+ def _verify_mocks
16
+ RR::Space.instance.verify_doubles
17
+ end
22
18
 
19
+ def _teardown_mocks
20
+ RR::Space.instance.reset
23
21
  end
22
+
24
23
  end
25
24
  end
26
- end
25
+ end
@@ -3,19 +3,19 @@ require 'rspec/mocks/extensions'
3
3
 
4
4
  module Rspec
5
5
  module Core
6
- module Mocking
7
- module WithRspec
8
- include Rspec::Mocks::ExampleMethods
9
- def _setup_mocks
10
- $rspec_mocks ||= Rspec::Mocks::Space.new
11
- end
12
- def _verify_mocks
13
- $rspec_mocks.verify_all
14
- end
15
- def _teardown_mocks
16
- $rspec_mocks.reset_all
17
- end
6
+ module MockFrameworkAdapter
7
+
8
+ include Rspec::Mocks::ExampleMethods
9
+ def _setup_mocks
10
+ $rspec_mocks ||= Rspec::Mocks::Space.new
11
+ end
12
+ def _verify_mocks
13
+ $rspec_mocks.verify_all
18
14
  end
15
+ def _teardown_mocks
16
+ $rspec_mocks.reset_all
17
+ end
18
+
19
19
  end
20
20
  end
21
21
  end
@@ -29,6 +29,8 @@ module Rspec
29
29
  Rspec::Core::CommandLineOptions.parse(args).apply(configuration)
30
30
 
31
31
  require_all_files(configuration)
32
+
33
+ configuration.configure_mock_framework
32
34
 
33
35
  total_examples_to_run = Rspec::Core.world.total_examples_to_run
34
36
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rspec-core}
8
- s.version = "2.0.0.beta.4"
8
+ s.version = "2.0.0.beta.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Chad Humphries", "David Chelimsky"]
12
- s.date = %q{2010-03-15}
12
+ s.date = %q{2010-04-04}
13
13
  s.description = %q{Rspec runner and example group classes}
14
14
  s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
15
15
  s.executables = ["rspec", "spec"]
@@ -111,6 +111,7 @@ Gem::Specification.new do |s|
111
111
  "lib/rspec/core/formatters/base_formatter.rb",
112
112
  "lib/rspec/core/formatters/base_text_formatter.rb",
113
113
  "lib/rspec/core/formatters/documentation_formatter.rb",
114
+ "lib/rspec/core/formatters/helpers.rb",
114
115
  "lib/rspec/core/formatters/progress_formatter.rb",
115
116
  "lib/rspec/core/hooks.rb",
116
117
  "lib/rspec/core/kernel_extensions.rb",
@@ -139,7 +140,9 @@ Gem::Specification.new do |s|
139
140
  "spec/rspec/core/example_group_subject_spec.rb",
140
141
  "spec/rspec/core/example_spec.rb",
141
142
  "spec/rspec/core/formatters/base_formatter_spec.rb",
143
+ "spec/rspec/core/formatters/base_text_formatter_spec.rb",
142
144
  "spec/rspec/core/formatters/documentation_formatter_spec.rb",
145
+ "spec/rspec/core/formatters/helpers_spec.rb",
143
146
  "spec/rspec/core/formatters/progress_formatter_spec.rb",
144
147
  "spec/rspec/core/kernel_extensions_spec.rb",
145
148
  "spec/rspec/core/metadata_spec.rb",
@@ -163,7 +166,7 @@ Gem::Specification.new do |s|
163
166
  s.homepage = %q{http://github.com/rspec/core}
164
167
  s.post_install_message = %q{**************************************************
165
168
 
166
- Thank you for installing rspec-core-2.0.0.beta.4
169
+ Thank you for installing rspec-core-2.0.0.beta.5
167
170
 
168
171
  This is beta software. If you are looking
169
172
  for a supported production release, please
@@ -175,7 +178,7 @@ Gem::Specification.new do |s|
175
178
  s.require_paths = ["lib"]
176
179
  s.rubyforge_project = %q{rspec}
177
180
  s.rubygems_version = %q{1.3.6}
178
- s.summary = %q{rspec-core-2.0.0.beta.4}
181
+ s.summary = %q{rspec-core-2.0.0.beta.5}
179
182
  s.test_files = [
180
183
  "spec/autotest/failed_results_re_spec.rb",
181
184
  "spec/autotest/rspec_spec.rb",
@@ -185,7 +188,9 @@ Gem::Specification.new do |s|
185
188
  "spec/rspec/core/example_group_subject_spec.rb",
186
189
  "spec/rspec/core/example_spec.rb",
187
190
  "spec/rspec/core/formatters/base_formatter_spec.rb",
191
+ "spec/rspec/core/formatters/base_text_formatter_spec.rb",
188
192
  "spec/rspec/core/formatters/documentation_formatter_spec.rb",
193
+ "spec/rspec/core/formatters/helpers_spec.rb",
189
194
  "spec/rspec/core/formatters/progress_formatter_spec.rb",
190
195
  "spec/rspec/core/kernel_extensions_spec.rb",
191
196
  "spec/rspec/core/metadata_spec.rb",
@@ -211,19 +216,19 @@ Gem::Specification.new do |s|
211
216
  s.specification_version = 3
212
217
 
213
218
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
214
- s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.4"])
215
- s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.4"])
219
+ s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.5"])
220
+ s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.5"])
216
221
  s.add_development_dependency(%q<cucumber>, [">= 0.5.3"])
217
222
  s.add_development_dependency(%q<autotest>, [">= 4.2.9"])
218
223
  else
219
- s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.4"])
220
- s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.4"])
224
+ s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.5"])
225
+ s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.5"])
221
226
  s.add_dependency(%q<cucumber>, [">= 0.5.3"])
222
227
  s.add_dependency(%q<autotest>, [">= 4.2.9"])
223
228
  end
224
229
  else
225
- s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.4"])
226
- s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.4"])
230
+ s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.5"])
231
+ s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.5"])
227
232
  s.add_dependency(%q<cucumber>, [">= 0.5.3"])
228
233
  s.add_dependency(%q<autotest>, [">= 4.2.9"])
229
234
  end
@@ -1,31 +1,13 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Autotest::Rspec do
4
- describe "adding spec.opts --options" do
5
- before(:each) do
6
- @rspec_autotest = Autotest::Rspec2.new
7
- end
8
-
9
- it "should return the command line option to add spec.opts if the options file exists" do
10
- File.stub!(:exist?).and_return true
11
- @rspec_autotest.add_options_if_present.should == "-O spec/spec.opts "
12
- end
13
-
14
- it "should return an empty string if no spec.opts exists" do
15
- File.stub!(:exist?).and_return false
16
- Autotest::Rspec2.new.add_options_if_present.should == ""
17
- end
18
- end
19
-
3
+ describe Autotest::Rspec2 do
20
4
  describe "commands" do
21
5
  before(:each) do
22
6
  @rspec_autotest = Autotest::Rspec2.new
23
7
  @rspec_autotest.stub!(:ruby).and_return "ruby"
24
- @rspec_autotest.stub!(:add_options_if_present).and_return "-O spec/spec.opts"
25
8
 
26
9
  @ruby = @rspec_autotest.ruby
27
10
  @spec_cmd = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'rspec'))
28
- @options = @rspec_autotest.add_options_if_present
29
11
  files = %w[file_one file_two]
30
12
  @files_to_test = {
31
13
  files[0] => [],
@@ -38,7 +20,7 @@ describe Autotest::Rspec do
38
20
 
39
21
  it "should make the appropriate test command" do
40
22
  actual = @rspec_autotest.make_test_cmd(@files_to_test)
41
- expected = /#{@ruby} #{@spec_cmd} (.*) #{@options}/
23
+ expected = /#{@ruby}.*#{@spec_cmd} (.*)/
42
24
 
43
25
  actual.should match(expected)
44
26
 
@@ -6,28 +6,34 @@ module Rspec::Core
6
6
 
7
7
  let(:config) { Configuration.new }
8
8
 
9
- context "setting the mock framework" do
9
+ describe "#mock_framework_class" do
10
+ before(:each) do
11
+ config.stub(:require)
12
+ end
10
13
 
11
- it "requires and includes the rspec adapter when the mock_framework is :rspec" do
14
+ it "defaults to :rspec" do
12
15
  config.should_receive(:require).with('rspec/core/mocking/with_rspec')
13
- ExampleGroup.should_receive(:send)
14
- config.mock_framework = :rspec
16
+ config.require_mock_framework_adapter
15
17
  end
16
18
 
17
- it "supports mock_with for backward compatibility with rspec-1.x" do
18
- config.stub!(:require)
19
- ExampleGroup.stub!(:send)
20
- config.mock_with :rspec
19
+ [:rspec, :mocha, :rr, :flexmock].each do |framework|
20
+ it "uses #{framework.inspect} framework when set explicitly" do
21
+ config.should_receive(:require).with("rspec/core/mocking/with_#{framework}")
22
+ config.mock_framework = framework
23
+ config.require_mock_framework_adapter
24
+ end
21
25
  end
22
-
23
- it "includes the null adapter when the mock_framework is not :rspec, :mocha, or :rr" do
24
- ExampleGroup.should_receive(:send).with(:include, Mocking::WithAbsolutelyNothing)
26
+
27
+ it "uses the null adapter when set to any unknown key" do
28
+ config.should_receive(:require).with('rspec/core/mocking/with_absolutely_nothing')
25
29
  config.mock_framework = :crazy_new_mocking_framework_ive_not_yet_heard_of
30
+ config.require_mock_framework_adapter
26
31
  end
27
32
 
28
- pending "includes the rspec adapter when the mock_framework is not set" do
29
- ExampleGroup.stub!(:send)
30
- config.mock_framework.should == :rspec
33
+ it "supports mock_with for backward compatibility with rspec-1.x" do
34
+ config.should_receive(:require).with('rspec/core/mocking/with_rspec')
35
+ config.mock_with :rspec
36
+ config.require_mock_framework_adapter
31
37
  end
32
38
 
33
39
  end
@@ -231,6 +237,19 @@ module Rspec::Core
231
237
  end
232
238
  end
233
239
 
240
+
241
+ context "transactional examples" do
242
+ it "defaults to use transactional examples" do
243
+ config.use_transactional_examples?.should be_true
244
+ end
245
+ describe "#use_transactional_examples=" do
246
+ it "remembers that I don't want transactional exmaples" do
247
+ config.use_transactional_examples = false
248
+ config.use_transactional_examples?.should be_false
249
+ end
250
+ end
251
+ end
252
+
234
253
  end
235
254
 
236
255
  end
@@ -37,9 +37,13 @@ describe Rspec::Core::Formatters::BaseFormatter do
37
37
  end
38
38
 
39
39
  describe '#format_backtrace' do
40
-
41
40
  it "displays the full backtrace when the example is given the :full_backtrace => true option", :full_backtrace => true
42
-
41
+ end
42
+
43
+ describe "backtrace_line" do
44
+ it "trims current working directory" do
45
+ formatter.__send__(:backtrace_line, File.expand_path(__FILE__)).should == "./spec/rspec/core/formatters/base_formatter_spec.rb"
46
+ end
43
47
  end
44
48
 
45
49
  end
@@ -0,0 +1,5 @@
1
+ require "spec_helper"
2
+
3
+ describe Rspec::Core::Formatters::BaseTextFormatter do
4
+
5
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+ require 'stringio'
3
+
4
+ describe Rspec::Core::Formatters::Helpers do
5
+ let(:helper) { helper = Object.new.extend(Rspec::Core::Formatters::Helpers) }
6
+
7
+ describe "format seconds" do
8
+ pending "uses passed in precision if specified" do
9
+ # can't get regex right to handle this case where we don't want it to consume all zeroes
10
+ helper.format_seconds(0.00005, 2).should == "0.00"
11
+ end
12
+
13
+ context "sub second times" do
14
+ it "returns 5 digits of precision" do
15
+ helper.format_seconds(0.000005).should == "0.00001"
16
+ end
17
+
18
+ it "strips off trailing zeroes" do
19
+ helper.format_seconds(0.02000).should == "0.02"
20
+ end
21
+ end
22
+
23
+ context "second and greater times" do
24
+
25
+ it "returns 2 digits of precision" do
26
+ helper.format_seconds(50.330340).should == "50.33"
27
+ end
28
+
29
+ it "returns human friendly elasped time" do
30
+ helper.format_seconds(50.1).should == "50.1"
31
+ helper.format_seconds(5).should == "5"
32
+ helper.format_seconds(5.0).should == "5"
33
+ end
34
+ end
35
+ end
36
+
37
+
38
+ end
@@ -4,7 +4,7 @@ module Rspec
4
4
  module Core
5
5
  describe Metadata do
6
6
 
7
- describe "#process" do
7
+ describe "process" do
8
8
  Metadata::RESERVED_KEYS.each do |key|
9
9
  it "prohibits :#{key} as a hash key" do
10
10
  m = Metadata.new
@@ -15,7 +15,7 @@ module Rspec
15
15
  end
16
16
  end
17
17
 
18
- describe "[:description]" do
18
+ describe "description" do
19
19
  it "just has the example description" do
20
20
  m = Metadata.new
21
21
  m.process('group')
@@ -25,7 +25,7 @@ module Rspec
25
25
  end
26
26
  end
27
27
 
28
- describe "[:full_description]" do
28
+ describe "full description" do
29
29
  it "concats the example group name and description" do
30
30
  m = Metadata.new
31
31
  m.process('group')
@@ -35,7 +35,7 @@ module Rspec
35
35
  end
36
36
  end
37
37
 
38
- describe "[:example_group][:description]" do
38
+ describe "description" do
39
39
  context "with a string" do
40
40
  it "provides the submitted description" do
41
41
  m = Metadata.new
@@ -64,7 +64,7 @@ module Rspec
64
64
  end
65
65
  end
66
66
 
67
- describe "[:example_group][:full_description]" do
67
+ describe "full description" do
68
68
  it "concats the nested example group descriptions" do
69
69
  parent = Metadata.new
70
70
  parent.process(Object, 'parent')
@@ -76,7 +76,7 @@ module Rspec
76
76
  end
77
77
  end
78
78
 
79
- describe "#determine_file_path" do
79
+ describe "file path" do
80
80
  it "finds the first spec file in the caller array" do
81
81
  m = Metadata.new
82
82
  m.process(:caller => [
@@ -87,9 +87,18 @@ module Rspec
87
87
  ])
88
88
  m[:example_group][:file_path].should == __FILE__
89
89
  end
90
+ it "is nil if there are no spec files found", :full_backtrace => true do
91
+ m = Metadata.new
92
+ m.process(:caller => [
93
+ "foo",
94
+ "metadata_example.rb:#{__LINE__}",
95
+ "baz"
96
+ ])
97
+ m[:example_group][:file_path].should be_nil
98
+ end
90
99
  end
91
100
 
92
- describe "#determine_line_number" do
101
+ describe "line number" do
93
102
  it "finds the line number with the first spec file " do
94
103
  m = Metadata.new
95
104
  m.process(:caller => [
@@ -112,7 +121,7 @@ module Rspec
112
121
  end
113
122
  end
114
123
 
115
- describe "#metadata_for_example" do
124
+ describe "metadata for example" do
116
125
  let(:caller_for_example) { caller(0) }
117
126
  let(:line_number) { __LINE__ - 1 }
118
127
  let(:metadata) { Metadata.new.process("group description") }
@@ -151,7 +160,7 @@ module Rspec
151
160
  end
152
161
  end
153
162
 
154
- describe "#apply_condition" do
163
+ describe "apply_condition" do
155
164
  let(:group_metadata) { Metadata.new.process('group', :caller => ["foo_spec.rb:#{__LINE__}"]) }
156
165
  let(:group_line_number) { __LINE__ -1 }
157
166
  let(:example_metadata) { group_metadata.for_example('example', :caller => ["foo_spec.rb:#{__LINE__}"]) }
@@ -144,10 +144,10 @@ module Rspec::Core
144
144
  end
145
145
 
146
146
  describe "running shared examples" do
147
- module RunningSharedExamplesJustForTesting; end
147
+ module ::RunningSharedExamplesJustForTesting; end
148
148
 
149
149
  share_examples_for("it runs shared examples") do
150
- include RunningSharedExamplesJustForTesting
150
+ include ::RunningSharedExamplesJustForTesting
151
151
 
152
152
  class << self
153
153
  def magic
@@ -9,13 +9,11 @@ require 'rspec/mocks'
9
9
  begin
10
10
  require 'autotest'
11
11
  rescue LoadError
12
- raise "You must install ZenTest to use autotest"
12
+ raise "You must install autotest to use it"
13
13
  end
14
14
 
15
15
  require 'autotest/rspec2'
16
16
 
17
- Rspec::Core::ExampleGroup.send(:include, Rspec::Matchers)
18
-
19
17
  Dir['./spec/support/**/*.rb'].map {|f| require f}
20
18
 
21
19
  module Rspec
@@ -45,7 +43,6 @@ def in_editor?
45
43
  end
46
44
 
47
45
  Rspec.configure do |c|
48
- c.mock_framework = :rspec
49
46
  c.color_enabled = !in_editor?
50
47
  c.exclusion_filter = { :ruby => lambda {|version|
51
48
  !(RUBY_VERSION.to_s =~ /^#{version.to_s}/)
metadata CHANGED
@@ -7,8 +7,8 @@ version: !ruby/object:Gem::Version
7
7
  - 0
8
8
  - 0
9
9
  - beta
10
- - 4
11
- version: 2.0.0.beta.4
10
+ - 5
11
+ version: 2.0.0.beta.5
12
12
  platform: ruby
13
13
  authors:
14
14
  - Chad Humphries
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-03-15 00:00:00 -05:00
20
+ date: 2010-04-04 00:00:00 -03:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -32,8 +32,8 @@ dependencies:
32
32
  - 0
33
33
  - 0
34
34
  - beta
35
- - 4
36
- version: 2.0.0.beta.4
35
+ - 5
36
+ version: 2.0.0.beta.5
37
37
  type: :development
38
38
  version_requirements: *id001
39
39
  - !ruby/object:Gem::Dependency
@@ -48,8 +48,8 @@ dependencies:
48
48
  - 0
49
49
  - 0
50
50
  - beta
51
- - 4
52
- version: 2.0.0.beta.4
51
+ - 5
52
+ version: 2.0.0.beta.5
53
53
  type: :development
54
54
  version_requirements: *id002
55
55
  - !ruby/object:Gem::Dependency
@@ -184,6 +184,7 @@ files:
184
184
  - lib/rspec/core/formatters/base_formatter.rb
185
185
  - lib/rspec/core/formatters/base_text_formatter.rb
186
186
  - lib/rspec/core/formatters/documentation_formatter.rb
187
+ - lib/rspec/core/formatters/helpers.rb
187
188
  - lib/rspec/core/formatters/progress_formatter.rb
188
189
  - lib/rspec/core/hooks.rb
189
190
  - lib/rspec/core/kernel_extensions.rb
@@ -212,7 +213,9 @@ files:
212
213
  - spec/rspec/core/example_group_subject_spec.rb
213
214
  - spec/rspec/core/example_spec.rb
214
215
  - spec/rspec/core/formatters/base_formatter_spec.rb
216
+ - spec/rspec/core/formatters/base_text_formatter_spec.rb
215
217
  - spec/rspec/core/formatters/documentation_formatter_spec.rb
218
+ - spec/rspec/core/formatters/helpers_spec.rb
216
219
  - spec/rspec/core/formatters/progress_formatter_spec.rb
217
220
  - spec/rspec/core/kernel_extensions_spec.rb
218
221
  - spec/rspec/core/metadata_spec.rb
@@ -239,7 +242,7 @@ licenses: []
239
242
  post_install_message: |
240
243
  **************************************************
241
244
 
242
- Thank you for installing rspec-core-2.0.0.beta.4
245
+ Thank you for installing rspec-core-2.0.0.beta.5
243
246
 
244
247
  This is beta software. If you are looking
245
248
  for a supported production release, please
@@ -273,7 +276,7 @@ rubyforge_project: rspec
273
276
  rubygems_version: 1.3.6
274
277
  signing_key:
275
278
  specification_version: 3
276
- summary: rspec-core-2.0.0.beta.4
279
+ summary: rspec-core-2.0.0.beta.5
277
280
  test_files:
278
281
  - spec/autotest/failed_results_re_spec.rb
279
282
  - spec/autotest/rspec_spec.rb
@@ -283,7 +286,9 @@ test_files:
283
286
  - spec/rspec/core/example_group_subject_spec.rb
284
287
  - spec/rspec/core/example_spec.rb
285
288
  - spec/rspec/core/formatters/base_formatter_spec.rb
289
+ - spec/rspec/core/formatters/base_text_formatter_spec.rb
286
290
  - spec/rspec/core/formatters/documentation_formatter_spec.rb
291
+ - spec/rspec/core/formatters/helpers_spec.rb
287
292
  - spec/rspec/core/formatters/progress_formatter_spec.rb
288
293
  - spec/rspec/core/kernel_extensions_spec.rb
289
294
  - spec/rspec/core/metadata_spec.rb