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

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -23,6 +23,7 @@ begin
23
23
  gem.add_development_dependency "rspec-expectations", ">= #{Rspec::Core::Version::STRING}"
24
24
  gem.add_development_dependency "rspec-mocks", ">= #{Rspec::Core::Version::STRING}"
25
25
  gem.add_development_dependency('cucumber', '>= 0.5.3')
26
+ gem.add_development_dependency('autotest', '>= 4.2.9')
26
27
  gem.post_install_message = <<-EOM
27
28
  #{"*"*50}
28
29
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0.beta.3
1
+ 2.0.0.beta.4
@@ -0,0 +1,2 @@
1
+ Autotest.add_discovery { "rspec2" }
2
+
@@ -22,7 +22,7 @@ Feature: spec/spec.opts
22
22
  describe "color_enabled" do
23
23
  context "when set with Rspec.configure" do
24
24
  it "is true" do
25
- Rspec::Core.configuration.color_enabled?.should be_true
25
+ Rspec.configuration.color_enabled?.should be_true
26
26
  end
27
27
  end
28
28
  end
@@ -42,7 +42,7 @@ Feature: spec/spec.opts
42
42
  describe "color_enabled" do
43
43
  context "when set with Rspec.configure" do
44
44
  it "is true" do
45
- Rspec::Core.configuration.color_enabled?.should be_true
45
+ Rspec.configuration.color_enabled?.should be_true
46
46
  end
47
47
  end
48
48
  end
@@ -68,7 +68,7 @@ Feature: spec/spec.opts
68
68
  describe "formatter" do
69
69
  context "when set with Rspec.configure and in spec.opts" do
70
70
  it "takes the value set in spec.opts" do
71
- Rspec::Core.configuration.formatter.should be_an(Rspec::Core::Formatters::DocumentationFormatter)
71
+ Rspec.configuration.formatter.should be_an(Rspec::Core::Formatters::DocumentationFormatter)
72
72
  end
73
73
  end
74
74
  end
@@ -4,11 +4,11 @@ Feature: custom formatters
4
4
  As an RSpec user
5
5
  I want to create my own custom output formatters
6
6
 
7
+ @wip
7
8
  Scenario: specdoc format
8
9
  Given a file named "custom_formatter.rb" with:
9
10
  """
10
- require "rspec/expectations"
11
- require "spec/runner/formatter/base_formatter"
11
+ require "rspec/runner/formatter/base_formatter"
12
12
 
13
13
  class CustomFormatter < Spec::Runner::Formatter::BaseFormatter
14
14
  def initialize(options, output)
@@ -28,5 +28,5 @@ Feature: custom formatters
28
28
  """
29
29
 
30
30
  When I run "rspec simple_example_spec.rb --require custom_formatter.rb --format CustomFormatter"
31
- Then the exit code should be 0
32
- And the stdout should match "example: my example"
31
+ Then I should see "example: my example"
32
+ And the exit status should be 0
@@ -0,0 +1,68 @@
1
+ @wip
2
+ Feature: pending examples
3
+
4
+ Rspec offers three ways to indicate that an example is disabled pending
5
+ some action.
6
+
7
+ Scenario: pending implementation
8
+ Given a file named "example_without_block_spec.rb" with:
9
+ """
10
+ describe "an example" do
11
+ it "has not yet been implemented"
12
+ end
13
+ """
14
+ When I run "spec example_without_block_spec.rb"
15
+ Then the exit status should be 0
16
+ And I should see "1 example, 0 failures, 1 pending"
17
+ And I should see "Not Yet Implemented"
18
+ And I should see "example_without_block_spec.rb:2"
19
+
20
+ Scenario: pending any arbitary reason, with no block
21
+ Given a file named "pending_without_block_spec.rb" with:
22
+ """
23
+ describe "an example" do
24
+ it "is implemented but waiting" do
25
+ pending("something else getting finished")
26
+ end
27
+ end
28
+ """
29
+ When I run "spec pending_without_block_spec.rb"
30
+ Then the exit status should be 0
31
+ And I should see "1 example, 0 failures, 1 pending"
32
+ And I should see "(something else getting finished)"
33
+ And I should see "pending_without_block_spec.rb:2"
34
+
35
+ Scenario: pending any arbitary reason, with a block that fails
36
+ Given a file named "pending_with_failing_block_spec.rb" with:
37
+ """
38
+ describe "an example" do
39
+ it "is implemented but waiting" do
40
+ pending("something else getting finished") do
41
+ raise "this is the failure"
42
+ end
43
+ end
44
+ end
45
+ """
46
+ When I run "spec pending_with_failing_block_spec.rb"
47
+ Then the exit status should be 0
48
+ And I should see "1 example, 0 failures, 1 pending"
49
+ And I should see "(something else getting finished)"
50
+ And I should see "pending_with_failing_block_spec.rb:2"
51
+
52
+ Scenario: pending any arbitary reason, with a block that passes
53
+ Given a file named "pending_with_passing_block_spec.rb" with:
54
+ """
55
+ describe "an example" do
56
+ it "is implemented but waiting" do
57
+ pending("something else getting finished") do
58
+ true.should be(true)
59
+ end
60
+ end
61
+ end
62
+ """
63
+ When I run "spec pending_with_passing_block_spec.rb"
64
+ Then the exit status should not be 0
65
+ And I should see "1 example, 1 failure"
66
+ And I should see "FIXED"
67
+ And I should see "Expected pending 'something else getting finished' to fail. No Error was raised."
68
+ And I should see "pending_with_passing_block_spec.rb:3"
@@ -0,0 +1,54 @@
1
+ require 'autotest'
2
+
3
+ Autotest.add_hook :initialize do |at|
4
+ at.clear_mappings
5
+ # watch out for Ruby bug (1.8.6): %r(/) != /\//
6
+ at.add_mapping(%r%^spec/.*_spec\.rb$%) { |filename, _|
7
+ filename
8
+ }
9
+ at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
10
+ ["spec/#{m[1]}_spec.rb"]
11
+ }
12
+ at.add_mapping(%r%^spec/(spec_helper|shared/.*)\.rb$%) {
13
+ at.files_matching %r%^spec/.*_spec\.rb$%
14
+ }
15
+ end
16
+
17
+ class RspecCommandError < StandardError; end
18
+
19
+ class Autotest::Rspec2 < Autotest
20
+
21
+ SPEC_PROGRAM = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'rspec'))
22
+
23
+ def initialize
24
+ super
25
+ self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n\n?(.*?(\n\n\(.*?)?)\n\n/m
26
+ self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/m
27
+ end
28
+
29
+ def consolidate_failures(failed)
30
+ filters = new_hash_of_arrays
31
+ failed.each do |spec, trace|
32
+ if trace =~ /\n(\.\/)?(.*spec\.rb):[\d]+:/
33
+ filters[$2] << spec
34
+ end
35
+ end
36
+ return filters
37
+ end
38
+
39
+ def make_test_cmd(files_to_test)
40
+ files_to_test.empty? ? '' :
41
+ "#{ruby} #{SPEC_PROGRAM} #{normalize(files_to_test).keys.flatten.join(' ')} #{add_options_if_present}"
42
+ end
43
+
44
+ def normalize(files_to_test)
45
+ files_to_test.keys.inject({}) do |result, filename|
46
+ result[File.expand_path(filename)] = []
47
+ result
48
+ end
49
+ end
50
+
51
+ def add_options_if_present # :nodoc:
52
+ File.exist?("spec/spec.opts") ? "-O #{File.join('spec','spec.opts')} " : ""
53
+ end
54
+ end
@@ -23,7 +23,8 @@ module Rspec
23
23
  end
24
24
 
25
25
  def self.configuration
26
- @configuration ||= Rspec::Core::Configuration.new
26
+ Rspec.deprecate('Rspec::Core.configuration', 'Rspec.configuration', '2.0.0')
27
+ Rspec.configuration
27
28
  end
28
29
 
29
30
  def self.configure
@@ -37,8 +38,12 @@ module Rspec
37
38
 
38
39
  end
39
40
 
41
+ def self.configuration
42
+ @configuration ||= Rspec::Core::Configuration.new
43
+ end
44
+
40
45
  def self.configure
41
- yield Core.configuration if block_given?
46
+ yield configuration if block_given?
42
47
  end
43
48
  end
44
49
 
@@ -46,8 +46,12 @@ module Rspec
46
46
  alias_example_to :pending, :pending => true
47
47
 
48
48
  def self.it_should_behave_like(*names)
49
- Rspec::Core.world.shared_example_groups.each do |name, block|
50
- module_eval(&block) if names.include?(name)
49
+ names.each do |name|
50
+ begin
51
+ module_eval &Rspec::Core.world.shared_example_groups[name]
52
+ rescue ArgumentError
53
+ raise "Could not find shared example group named #{name.inspect}"
54
+ end
51
55
  end
52
56
  end
53
57
 
@@ -118,7 +122,7 @@ module Rspec
118
122
  def self._build(klass, given_caller, args, &example_group_block)
119
123
  args << {} unless args.last.is_a?(Hash)
120
124
  args.last.update(:example_group_block => example_group_block, :caller => given_caller)
121
- args.unshift Rspec::Core.configuration unless args.first.is_a?(Rspec::Core::Configuration)
125
+ args.unshift Rspec.configuration unless args.first.is_a?(Rspec::Core::Configuration)
122
126
  klass.set_it_up(*args)
123
127
  klass.module_eval(&example_group_block) if example_group_block
124
128
  klass
@@ -15,15 +15,15 @@ module Rspec
15
15
  end
16
16
 
17
17
  def configuration
18
- Rspec::Core.configuration
18
+ Rspec.configuration
19
19
  end
20
20
 
21
21
  def output
22
- Rspec::Core.configuration.output
22
+ Rspec.configuration.output
23
23
  end
24
24
 
25
25
  def profile_examples?
26
- Rspec::Core.configuration.profile_examples
26
+ Rspec.configuration.profile_examples
27
27
  end
28
28
 
29
29
  def color_enabled?
@@ -1,6 +1,6 @@
1
1
  require 'rr'
2
2
 
3
- Rspec::Core.configuration.backtrace_clean_patterns.push(RR::Errors::BACKTRACE_IDENTIFIER)
3
+ Rspec.configuration.backtrace_clean_patterns.push(RR::Errors::BACKTRACE_IDENTIFIER)
4
4
 
5
5
  module Rspec
6
6
  module Core
@@ -14,7 +14,7 @@ module Rspec
14
14
  end
15
15
 
16
16
  def configuration
17
- Rspec::Core.configuration
17
+ Rspec.configuration
18
18
  end
19
19
 
20
20
  def reporter
@@ -9,11 +9,11 @@ module Rspec
9
9
  end
10
10
 
11
11
  def filter
12
- Rspec::Core.configuration.filter
12
+ Rspec.configuration.filter
13
13
  end
14
14
 
15
15
  def exclusion_filter
16
- Rspec::Core.configuration.exclusion_filter
16
+ Rspec.configuration.exclusion_filter
17
17
  end
18
18
 
19
19
  def shared_example_groups
@@ -26,13 +26,13 @@ module Rspec
26
26
  if filter || exclusion_filter
27
27
  @example_groups_to_run = filter_example_groups
28
28
 
29
- if @example_groups_to_run.size == 0 && Rspec::Core.configuration.run_all_when_everything_filtered?
30
- Rspec::Core.configuration.puts "No examples were matched by #{filter.inspect}, running all"
29
+ if @example_groups_to_run.size == 0 && Rspec.configuration.run_all_when_everything_filtered?
30
+ Rspec.configuration.puts "No examples were matched by #{filter.inspect}, running all"
31
31
  # reset the behaviour list to all example groups, and add back all examples
32
32
  @example_groups_to_run = @example_groups
33
33
  @example_groups.each { |b| b.examples_to_run.replace(b.examples) }
34
34
  else
35
- Rspec::Core.configuration.puts "Run filtered using #{filter.inspect}"
35
+ Rspec.configuration.puts "Run filtered using #{filter.inspect}"
36
36
  end
37
37
  else
38
38
  @example_groups_to_run = @example_groups
@@ -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.3"
8
+ s.version = "2.0.0.beta.4"
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-08}
12
+ s.date = %q{2010-03-15}
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"]
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
26
26
  "TODO.markdown",
27
27
  "Upgrade.markdown",
28
28
  "VERSION",
29
+ "autotest/discover.rb",
29
30
  "bin/rspec",
30
31
  "bin/spec",
31
32
  "cucumber.yml",
@@ -76,20 +77,13 @@ Gem::Specification.new do |s|
76
77
  "example_specs/passing/yielding_example.rb",
77
78
  "example_specs/ruby1.9.compatibility/access_to_constants_spec.rb",
78
79
  "example_specs/spec_helper.rb",
79
- "features-pending/formatters/custom_formatter.feature",
80
- "features-pending/heckle/heckle.feature",
81
- "features-pending/interop/examples_and_tests_together.feature",
82
- "features-pending/interop/rspec_output.feature",
83
- "features-pending/interop/test_but_not_test_unit.feature",
84
- "features-pending/interop/test_case_with_should_methods.feature",
85
- "features-pending/mocks/stub_implementation.feature",
86
- "features-pending/pending/pending_examples.feature",
87
80
  "features/command_line/example_name_option.feature",
88
81
  "features/command_line/line_number_appended_to_path.feature",
89
82
  "features/command_line/line_number_option.feature",
90
83
  "features/configuration/spec_opts.feature",
91
84
  "features/example_groups/describe_aliases.feature",
92
85
  "features/example_groups/nested_groups.feature",
86
+ "features/formatters/custom_formatter.feature",
93
87
  "features/hooks/around_hook.feature",
94
88
  "features/hooks/before_and_after_hooks.feature",
95
89
  "features/hooks/described_class.feature",
@@ -98,9 +92,11 @@ Gem::Specification.new do |s|
98
92
  "features/mock_framework_integration/use_mocha.feature",
99
93
  "features/mock_framework_integration/use_rr.feature",
100
94
  "features/mock_framework_integration/use_rspec.feature",
95
+ "features/pending/pending_examples.feature",
101
96
  "features/subject/explicit_subject.feature",
102
97
  "features/subject/implicit_subject.feature",
103
98
  "features/support/env.rb",
99
+ "lib/autotest/rspec2.rb",
104
100
  "lib/rspec/autorun.rb",
105
101
  "lib/rspec/core.rb",
106
102
  "lib/rspec/core/around_proxy.rb",
@@ -135,6 +131,8 @@ Gem::Specification.new do |s|
135
131
  "lib/rspec/core/world.rb",
136
132
  "rspec-core.gemspec",
137
133
  "script/console",
134
+ "spec/autotest/failed_results_re_spec.rb",
135
+ "spec/autotest/rspec_spec.rb",
138
136
  "spec/rspec/core/command_line_options_spec.rb",
139
137
  "spec/rspec/core/configuration_spec.rb",
140
138
  "spec/rspec/core/example_group_spec.rb",
@@ -159,12 +157,13 @@ Gem::Specification.new do |s|
159
157
  "spec/rspec/core_spec.rb",
160
158
  "spec/ruby_forker.rb",
161
159
  "spec/spec_helper.rb",
160
+ "spec/support/matchers.rb",
162
161
  "specs.watchr"
163
162
  ]
164
163
  s.homepage = %q{http://github.com/rspec/core}
165
164
  s.post_install_message = %q{**************************************************
166
165
 
167
- Thank you for installing rspec-core-2.0.0.beta.3
166
+ Thank you for installing rspec-core-2.0.0.beta.4
168
167
 
169
168
  This is beta software. If you are looking
170
169
  for a supported production release, please
@@ -176,9 +175,11 @@ Gem::Specification.new do |s|
176
175
  s.require_paths = ["lib"]
177
176
  s.rubyforge_project = %q{rspec}
178
177
  s.rubygems_version = %q{1.3.6}
179
- s.summary = %q{rspec-core-2.0.0.beta.3}
178
+ s.summary = %q{rspec-core-2.0.0.beta.4}
180
179
  s.test_files = [
181
- "spec/rspec/core/command_line_options_spec.rb",
180
+ "spec/autotest/failed_results_re_spec.rb",
181
+ "spec/autotest/rspec_spec.rb",
182
+ "spec/rspec/core/command_line_options_spec.rb",
182
183
  "spec/rspec/core/configuration_spec.rb",
183
184
  "spec/rspec/core/example_group_spec.rb",
184
185
  "spec/rspec/core/example_group_subject_spec.rb",
@@ -201,7 +202,8 @@ Gem::Specification.new do |s|
201
202
  "spec/rspec/core/world_spec.rb",
202
203
  "spec/rspec/core_spec.rb",
203
204
  "spec/ruby_forker.rb",
204
- "spec/spec_helper.rb"
205
+ "spec/spec_helper.rb",
206
+ "spec/support/matchers.rb"
205
207
  ]
206
208
 
207
209
  if s.respond_to? :specification_version then
@@ -209,18 +211,21 @@ Gem::Specification.new do |s|
209
211
  s.specification_version = 3
210
212
 
211
213
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
212
- s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.3"])
213
- s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.3"])
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"])
214
216
  s.add_development_dependency(%q<cucumber>, [">= 0.5.3"])
217
+ s.add_development_dependency(%q<autotest>, [">= 4.2.9"])
215
218
  else
216
- s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.3"])
217
- s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.3"])
219
+ s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.4"])
220
+ s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.4"])
218
221
  s.add_dependency(%q<cucumber>, [">= 0.5.3"])
222
+ s.add_dependency(%q<autotest>, [">= 4.2.9"])
219
223
  end
220
224
  else
221
- s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.3"])
222
- s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.3"])
225
+ s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.4"])
226
+ s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.4"])
223
227
  s.add_dependency(%q<cucumber>, [">= 0.5.3"])
228
+ s.add_dependency(%q<autotest>, [">= 4.2.9"])
224
229
  end
225
230
  end
226
231
 
@@ -0,0 +1,31 @@
1
+ require "spec_helper"
2
+
3
+ describe "failed_results_re" do
4
+ it "should match a failure" do
5
+ re = Autotest::Rspec2.new.failed_results_re
6
+ re =~ "1)\n'this example' FAILED\nreason\n/path.rb:37:\n\n"
7
+ $1.should == "this example"
8
+ $2.should == "reason\n/path.rb:37:"
9
+ end
10
+
11
+ it "should match a failure when matcher outputs multiple lines" do
12
+ re = Autotest::Rspec2.new.failed_results_re
13
+ re =~ "1)\n'other example' FAILED\n\nreason line 1\nreason line 2\n\n(additional info)\n/path.rb:37:\n\n"
14
+ $1.should == "other example"
15
+ $2.should == "reason line 1\nreason line 2\n\n(additional info)\n/path.rb:37:"
16
+ end
17
+
18
+ it "should match an Error" do
19
+ re = Autotest::Rspec2.new.failed_results_re
20
+ re =~ "1)\nRuntimeError in 'this example'\nreason\n/path.rb:37:\n\n"
21
+ $1.should == "this example"
22
+ $2.should == "reason\n/path.rb:37:"
23
+ end
24
+
25
+ it "should match an Error that doesn't end in Error" do
26
+ re = Autotest::Rspec2.new.failed_results_re
27
+ re =~ "1)\nInvalidArgument in 'this example'\nreason\n/path.rb:37:\n\n"
28
+ $1.should == "this example"
29
+ $2.should == "reason\n/path.rb:37:"
30
+ end
31
+ end