rspec 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +17 -0
- data/Rakefile +7 -4
- data/failing_examples/README.txt +7 -0
- data/failing_examples/diffing_spec.rb +36 -0
- data/failing_examples/failing_autogenerated_docstrings_example.rb +19 -0
- data/failing_examples/failure_in_setup.rb +10 -0
- data/failing_examples/failure_in_teardown.rb +10 -0
- data/failing_examples/mocking_example.rb +40 -0
- data/failing_examples/mocking_with_flexmock.rb +26 -0
- data/failing_examples/mocking_with_mocha.rb +25 -0
- data/failing_examples/mocking_with_rr.rb +27 -0
- data/failing_examples/partial_mock_example.rb +20 -0
- data/failing_examples/predicate_example.rb +29 -0
- data/failing_examples/raising_example.rb +47 -0
- data/failing_examples/spec_helper.rb +3 -0
- data/failing_examples/syntax_error_example.rb +7 -0
- data/failing_examples/team_spec.rb +44 -0
- data/failing_examples/timeout_behaviour.rb +7 -0
- data/lib/autotest/rspec.rb +21 -35
- data/lib/spec.rb +0 -7
- data/lib/spec/example/example_group_methods.rb +10 -4
- data/lib/spec/example/example_methods.rb +4 -0
- data/lib/spec/interop/test.rb +3 -1
- data/lib/spec/interop/test/unit/ui/console/testrunner.rb +1 -0
- data/lib/spec/matchers/raise_error.rb +19 -15
- data/lib/spec/runner.rb +14 -0
- data/lib/spec/runner/formatter/story/html_formatter.rb +3 -0
- data/lib/spec/runner/formatter/story/plain_text_formatter.rb +4 -1
- data/lib/spec/runner/option_parser.rb +5 -33
- data/lib/spec/runner/options.rb +51 -18
- data/lib/spec/runner/spec_parser.rb +49 -31
- data/lib/spec/story/runner.rb +0 -2
- data/lib/spec/story/step.rb +8 -6
- data/lib/spec/story/world.rb +1 -0
- data/lib/spec/version.rb +22 -22
- data/pre_commit/lib/pre_commit.rb +4 -0
- data/pre_commit/lib/pre_commit/core.rb +50 -0
- data/pre_commit/lib/pre_commit/pre_commit.rb +54 -0
- data/pre_commit/lib/pre_commit/rspec.rb +111 -0
- data/pre_commit/lib/pre_commit/rspec_on_rails.rb +313 -0
- data/pre_commit/spec/pre_commit/pre_commit_spec.rb +15 -0
- data/pre_commit/spec/pre_commit/rspec_on_rails_spec.rb +36 -0
- data/pre_commit/spec/spec_helper.rb +3 -0
- data/pre_commit/spec/spec_suite.rb +11 -0
- data/rake_tasks/examples.rake +7 -0
- data/rake_tasks/examples_with_rcov.rake +9 -0
- data/rake_tasks/failing_examples_with_html.rake +9 -0
- data/rake_tasks/verify_rcov.rake +7 -0
- data/spec/README.jruby +15 -0
- data/spec/autotest/rspec_spec.rb +11 -80
- data/spec/autotest_helper.rb +2 -1
- data/spec/autotest_matchers.rb +47 -0
- data/spec/rspec_suite.rb +1 -1
- data/spec/spec.opts +6 -0
- data/spec/spec/example/example_group_methods_spec.rb +11 -2
- data/spec/spec/example/example_methods_spec.rb +69 -56
- data/spec/spec/interop/test/unit/resources/spec_that_fails.rb +10 -0
- data/spec/spec/interop/test/unit/resources/spec_that_passes.rb +10 -0
- data/spec/spec/interop/test/unit/resources/spec_with_errors.rb +10 -0
- data/spec/spec/interop/test/unit/resources/test_case_that_fails.rb +10 -0
- data/spec/spec/interop/test/unit/resources/test_case_that_passes.rb +10 -0
- data/spec/spec/interop/test/unit/resources/test_case_with_errors.rb +10 -0
- data/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb +38 -0
- data/spec/spec/interop/test/unit/spec_spec.rb +45 -0
- data/spec/spec/interop/test/unit/testcase_spec.rb +39 -4
- data/spec/spec/interop/test/unit/testsuite_adapter_spec.rb +1 -1
- data/spec/spec/matchers/raise_error_spec.rb +7 -1
- data/spec/spec/mocks/bug_report_10263.rb +1 -1
- data/spec/spec/runner/command_line_spec.rb +3 -2
- data/spec/spec/runner/empty_file.txt +0 -0
- data/spec/spec/runner/examples.txt +2 -0
- data/spec/spec/runner/failed.txt +3 -0
- data/spec/spec/runner/formatter/html_formatted-1.8.4.html +365 -0
- data/spec/spec/runner/formatter/html_formatted-1.8.5-jruby.html +387 -0
- data/spec/spec/runner/formatter/html_formatted-1.8.5.html +371 -0
- data/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html +381 -0
- data/spec/spec/runner/formatter/html_formatted-1.8.6.html +365 -0
- data/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +54 -54
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.4.html +365 -0
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +365 -0
- data/spec/spec/runner/option_parser_spec.rb +50 -49
- data/spec/spec/runner/options_spec.rb +72 -2
- data/spec/spec/runner/resources/a_bar.rb +0 -0
- data/spec/spec/runner/resources/a_foo.rb +0 -0
- data/spec/spec/runner/resources/a_spec.rb +1 -0
- data/spec/spec/runner/spec.opts +2 -0
- data/spec/spec/runner/spec_parser/spec_parser_fixture.rb +70 -0
- data/spec/spec/runner/spec_parser_spec.rb +31 -76
- data/spec/spec/runner/spec_spaced.opts +2 -0
- data/spec/spec/spec_classes.rb +4 -0
- data/spec/spec/story/step_spec.rb +22 -0
- data/spec/spec/story/world_spec.rb +7 -0
- data/stories/interop/test_case_with_should_methods +1 -1
- metadata +85 -5
- data/spec/spec/interop/test/unit/testcase_spec_with_test_unit.rb +0 -20
- data/spec/spec/interop/test/unit/testsuite_adapter_spec_with_test_unit.rb +0 -34
data/CHANGES
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
== Version 1.1.3
|
2
|
+
|
3
|
+
Maintenance release.
|
4
|
+
|
5
|
+
* Tightened up exceptions list in autotest/rails_spec. Closes #264.
|
6
|
+
* Applied patch from Ryan Davis for ZenTest-3.9.0 compatibility
|
7
|
+
* Applied patch from Kero to add step_upcoming to story listeners. Closes #253.
|
8
|
+
* Fixed bug where the wrong named error was not always caught by "should raise_error"
|
9
|
+
* Applied patch from Luis Lavena: No coloured output on Windows due missing RUBYOPT. Closes #244.
|
10
|
+
* Applied patch from Craig Demyanovich to add support for "should_not render_template" to rspec_on_rails. Closes #241.
|
11
|
+
* Added --pattern (-p for short) option to control what files get loaded. Defaults to '**/*_spec.rb'
|
12
|
+
* Exit with non-0 exit code if examples *or tests* (in test/unit interop mode) fail. Closes #203.
|
13
|
+
* Moved at_exit hook to a method in Spec::Runner which only runs if specs get loaded. Closes #242.
|
14
|
+
* Applied patch from kakutani ensuring that base_view_path gets cleared after each view example. Closes #235.
|
15
|
+
* More tweaks to regexp step names
|
16
|
+
* Fixed focused specs in nested ExampleGroups. Closes #225.
|
17
|
+
|
1
18
|
== Version 1.1.2
|
2
19
|
|
3
20
|
Minor bug fixes/enhancements.
|
data/Rakefile
CHANGED
@@ -7,7 +7,7 @@ require 'rake/rdoctask'
|
|
7
7
|
require 'rake/testtask'
|
8
8
|
require 'spec/version'
|
9
9
|
dir = File.dirname(__FILE__)
|
10
|
-
$LOAD_PATH.unshift(File.expand_path("#{dir}
|
10
|
+
$LOAD_PATH.unshift(File.expand_path("#{dir}/pre_commit/lib"))
|
11
11
|
require "pre_commit"
|
12
12
|
|
13
13
|
# Some of the tasks are in separate files since they are also part of the website documentation
|
@@ -22,10 +22,13 @@ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
|
22
22
|
PKG_FILES = FileList[
|
23
23
|
'[A-Z]*',
|
24
24
|
'lib/**/*.rb',
|
25
|
-
'spec
|
25
|
+
'spec/**/*',
|
26
26
|
'examples/**/*',
|
27
|
+
'failing_examples/**/*',
|
27
28
|
'plugins/**/*',
|
28
|
-
'stories/**/*'
|
29
|
+
'stories/**/*',
|
30
|
+
'pre_commit/**/*',
|
31
|
+
'rake_tasks/**/*'
|
29
32
|
]
|
30
33
|
|
31
34
|
task :default => [:verify_rcov]
|
@@ -34,7 +37,7 @@ task :verify_rcov => [:spec, :stories]
|
|
34
37
|
desc "Run all specs"
|
35
38
|
Spec::Rake::SpecTask.new do |t|
|
36
39
|
t.spec_files = FileList['spec/**/*_spec.rb']
|
37
|
-
t.spec_opts = ['--options', 'spec.opts']
|
40
|
+
t.spec_opts = ['--options', 'spec/spec.opts']
|
38
41
|
unless ENV['NO_RCOV']
|
39
42
|
t.rcov = true
|
40
43
|
t.rcov_dir = '../doc/output/coverage'
|
@@ -0,0 +1,7 @@
|
|
1
|
+
"Why have failing examples?", you might ask.
|
2
|
+
|
3
|
+
They allow us to see failure messages. RSpec wants to provide meaningful and helpful failure messages. The failures in this directory not only provide you a way of seeing the failure messages, but they provide RSpec's own specs a way of describing what they should look like and ensuring they stay correct.
|
4
|
+
|
5
|
+
To see the types of messages you can expect, stand in this directory and run:
|
6
|
+
|
7
|
+
../bin/spec ./*.rb
|
@@ -0,0 +1,36 @@
|
|
1
|
+
describe "Running specs with --diff" do
|
2
|
+
it "should print diff of different strings" do
|
3
|
+
uk = <<-EOF
|
4
|
+
RSpec is a
|
5
|
+
behaviour driven development
|
6
|
+
framework for Ruby
|
7
|
+
EOF
|
8
|
+
usa = <<-EOF
|
9
|
+
RSpec is a
|
10
|
+
behavior driven development
|
11
|
+
framework for Ruby
|
12
|
+
EOF
|
13
|
+
usa.should == uk
|
14
|
+
end
|
15
|
+
|
16
|
+
class Animal
|
17
|
+
def initialize(name,species)
|
18
|
+
@name,@species = name,species
|
19
|
+
end
|
20
|
+
|
21
|
+
def inspect
|
22
|
+
<<-EOA
|
23
|
+
<Animal
|
24
|
+
name=#{@name},
|
25
|
+
species=#{@species}
|
26
|
+
>
|
27
|
+
EOA
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should print diff of different objects' pretty representation" do
|
32
|
+
expected = Animal.new "bob", "giraffe"
|
33
|
+
actual = Animal.new "bob", "tortoise"
|
34
|
+
expected.should eql(actual)
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
# Run spec w/ -fs to see the output of this file
|
4
|
+
|
5
|
+
describe "Failing examples with no descriptions" do
|
6
|
+
|
7
|
+
# description is auto-generated as "should equal(5)" based on the last #should
|
8
|
+
it do
|
9
|
+
3.should equal(2)
|
10
|
+
5.should equal(5)
|
11
|
+
end
|
12
|
+
|
13
|
+
it { 3.should be > 5 }
|
14
|
+
|
15
|
+
it { ["a"].should include("b") }
|
16
|
+
|
17
|
+
it { [1,2,3].should_not respond_to(:size) }
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "Mocker" do
|
4
|
+
|
5
|
+
it "should be able to call mock()" do
|
6
|
+
mock = mock("poke me")
|
7
|
+
mock.should_receive(:poke)
|
8
|
+
mock.poke
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should fail when expected message not received" do
|
12
|
+
mock = mock("poke me")
|
13
|
+
mock.should_receive(:poke)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should fail when messages are received out of order" do
|
17
|
+
mock = mock("one two three")
|
18
|
+
mock.should_receive(:one).ordered
|
19
|
+
mock.should_receive(:two).ordered
|
20
|
+
mock.should_receive(:three).ordered
|
21
|
+
mock.one
|
22
|
+
mock.three
|
23
|
+
mock.two
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should get yelled at when sending unexpected messages" do
|
27
|
+
mock = mock("don't talk to me")
|
28
|
+
mock.should_not_receive(:any_message_at_all)
|
29
|
+
mock.any_message_at_all
|
30
|
+
end
|
31
|
+
|
32
|
+
it "has a bug we need to fix" do
|
33
|
+
pending "here is the bug" do
|
34
|
+
# Actually, no. It's fixed. This will fail because it passes :-)
|
35
|
+
mock = mock("Bug")
|
36
|
+
mock.should_receive(:hello)
|
37
|
+
mock.hello
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# stub frameworks like to gum up Object, so this is deliberately
|
2
|
+
# set NOT to run so that you don't accidentally run it when you
|
3
|
+
# run this dir.
|
4
|
+
|
5
|
+
# To run it, stand in this directory and say:
|
6
|
+
#
|
7
|
+
# RUN_FLEXMOCK_EXAMPLE=true ruby ../bin/spec mocking_with_flexmock.rb
|
8
|
+
|
9
|
+
if ENV['RUN_FLEXMOCK_EXAMPLE']
|
10
|
+
Spec::Runner.configure do |config|
|
11
|
+
config.mock_with :flexmock
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "Flexmocks" do
|
15
|
+
it "should fail when the expected message is received with wrong arguments" do
|
16
|
+
m = flexmock("now flex!")
|
17
|
+
m.should_receive(:msg).with("arg").once
|
18
|
+
m.msg("other arg")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should fail when the expected message is not received at all" do
|
22
|
+
m = flexmock("now flex!")
|
23
|
+
m.should_receive(:msg).with("arg").once
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# stub frameworks like to gum up Object, so this is deliberately
|
2
|
+
# set NOT to run so that you don't accidentally run it when you
|
3
|
+
# run this dir.
|
4
|
+
|
5
|
+
# To run it, stand in this directory and say:
|
6
|
+
#
|
7
|
+
# RUN_MOCHA_EXAMPLE=true ruby ../bin/spec mocking_with_mocha.rb
|
8
|
+
|
9
|
+
if ENV['RUN_MOCHA_EXAMPLE']
|
10
|
+
Spec::Runner.configure do |config|
|
11
|
+
config.mock_with :mocha
|
12
|
+
end
|
13
|
+
describe "Mocha framework" do
|
14
|
+
it "should should be made available by saying config.mock_with :mocha" do
|
15
|
+
m = mock()
|
16
|
+
m.expects(:msg).with("arg")
|
17
|
+
m.msg
|
18
|
+
end
|
19
|
+
it "should should be made available by saying config.mock_with :mocha" do
|
20
|
+
o = Object.new
|
21
|
+
o.expects(:msg).with("arg")
|
22
|
+
o.msg
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# stub frameworks like to gum up Object, so this is deliberately
|
2
|
+
# set NOT to run so that you don't accidentally run it when you
|
3
|
+
# run this dir.
|
4
|
+
|
5
|
+
# To run it, stand in this directory and say:
|
6
|
+
#
|
7
|
+
# RUN_RR_EXAMPLE=true ruby ../bin/spec mocking_with_rr.rb
|
8
|
+
|
9
|
+
if ENV['RUN_RR_EXAMPLE']
|
10
|
+
Spec::Runner.configure do |config|
|
11
|
+
config.mock_with :rr
|
12
|
+
end
|
13
|
+
describe "RR framework" do
|
14
|
+
it "should should be made available by saying config.mock_with :rr" do
|
15
|
+
o = Object.new
|
16
|
+
mock(o).msg("arg")
|
17
|
+
o.msg
|
18
|
+
end
|
19
|
+
it "should should be made available by saying config.mock_with :rr" do
|
20
|
+
o = Object.new
|
21
|
+
mock(o) do |m|
|
22
|
+
m.msg("arg")
|
23
|
+
end
|
24
|
+
o.msg
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
class MockableClass
|
4
|
+
def self.find id
|
5
|
+
return :original_return
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "A partial mock" do
|
10
|
+
|
11
|
+
it "should work at the class level (but fail here due to the type mismatch)" do
|
12
|
+
MockableClass.should_receive(:find).with(1).and_return {:stub_return}
|
13
|
+
MockableClass.find("1").should equal(:stub_return)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should revert to the original after each spec" do
|
17
|
+
MockableClass.find(1).should equal(:original_return)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
class BddFramework
|
4
|
+
def intuitive?
|
5
|
+
true
|
6
|
+
end
|
7
|
+
|
8
|
+
def adopted_quickly?
|
9
|
+
#this will cause failures because it reallly SHOULD be adopted quickly
|
10
|
+
false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "BDD framework" do
|
15
|
+
|
16
|
+
before(:each) do
|
17
|
+
@bdd_framework = BddFramework.new
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should be adopted quickly" do
|
21
|
+
#this will fail because it reallly SHOULD be adopted quickly
|
22
|
+
@bdd_framework.should be_adopted_quickly
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should be intuitive" do
|
26
|
+
@bdd_framework.should be_intuitive
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
describe "This example" do
|
2
|
+
|
3
|
+
it "should show that a NoMethodError is raised but an Exception was expected" do
|
4
|
+
proc { ''.nonexistent_method }.should raise_error
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should pass" do
|
8
|
+
proc { ''.nonexistent_method }.should raise_error(NoMethodError)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should show that a NoMethodError is raised but a SyntaxError was expected" do
|
12
|
+
proc { ''.nonexistent_method }.should raise_error(SyntaxError)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should show that nothing is raised when SyntaxError was expected" do
|
16
|
+
proc { }.should raise_error(SyntaxError)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should show that a NoMethodError is raised but a Exception was expected" do
|
20
|
+
proc { ''.nonexistent_method }.should_not raise_error
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should show that a NoMethodError is raised" do
|
24
|
+
proc { ''.nonexistent_method }.should_not raise_error(NoMethodError)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should also pass" do
|
28
|
+
proc { ''.nonexistent_method }.should_not raise_error(SyntaxError)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should show that a NoMethodError is raised when nothing expected" do
|
32
|
+
proc { ''.nonexistent_method }.should_not raise_error(Exception)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should show that the wrong message was received" do
|
36
|
+
proc { raise StandardError.new("what is an enterprise?") }.should raise_error(StandardError, "not this")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should show that the unexpected error/message was thrown" do
|
40
|
+
proc { raise StandardError.new("abc") }.should_not raise_error(StandardError, "abc")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should pass too" do
|
44
|
+
proc { raise StandardError.new("abc") }.should_not raise_error(StandardError, "xyz")
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
class Team
|
5
|
+
attr_reader :players
|
6
|
+
def initialize
|
7
|
+
@players = Players.new
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Players
|
12
|
+
def initialize
|
13
|
+
@players = []
|
14
|
+
end
|
15
|
+
def size
|
16
|
+
@players.size
|
17
|
+
end
|
18
|
+
def include? player
|
19
|
+
raise "player must be a string" unless player.is_a?(String)
|
20
|
+
@players.include? player
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "A new team" do
|
25
|
+
|
26
|
+
before(:each) do
|
27
|
+
@team = Team.new
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should have 3 players (failing example)" do
|
31
|
+
@team.should have(3).players
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should include some player (failing example)" do
|
35
|
+
@team.players.should include("Some Player")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should include 5 (failing example)" do
|
39
|
+
@team.players.should include(5)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should have no players"
|
43
|
+
|
44
|
+
end
|
data/lib/autotest/rspec.rb
CHANGED
@@ -18,35 +18,20 @@ end
|
|
18
18
|
class RspecCommandError < StandardError; end
|
19
19
|
|
20
20
|
class Autotest::Rspec < Autotest
|
21
|
-
|
22
|
-
def tests_for_file(filename)
|
23
|
-
super.select { |f| @files.has_key? f }
|
24
|
-
end
|
25
|
-
|
26
|
-
alias :specs_for_file :tests_for_file
|
27
|
-
|
28
|
-
def failed_results(results)
|
29
|
-
results.scan(/^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m)
|
30
|
-
end
|
31
21
|
|
32
|
-
def
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
hook :green
|
38
|
-
end unless $TESTING
|
39
|
-
@tainted = true unless @files_to_test.empty?
|
22
|
+
def initialize
|
23
|
+
super
|
24
|
+
|
25
|
+
self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m
|
26
|
+
self.completed_re = /\Z/ # FIX: some sort of summary line at the end?
|
40
27
|
end
|
41
28
|
|
42
29
|
def consolidate_failures(failed)
|
43
30
|
filters = Hash.new { |h,k| h[k] = [] }
|
44
31
|
failed.each do |spec, failed_trace|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
break
|
49
|
-
end
|
32
|
+
if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } then
|
33
|
+
filters[f] << spec
|
34
|
+
break
|
50
35
|
end
|
51
36
|
end
|
52
37
|
return filters
|
@@ -60,19 +45,21 @@ class Autotest::Rspec < Autotest
|
|
60
45
|
File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : ""
|
61
46
|
end
|
62
47
|
|
63
|
-
# Finds the proper spec command to use. Precendence
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
def spec_command
|
68
|
-
@spec_command
|
69
|
-
|
70
|
-
|
71
|
-
|
48
|
+
# Finds the proper spec command to use. Precendence is set in the
|
49
|
+
# lazily-evaluated method spec_commands. Alias + Override that in
|
50
|
+
# ~/.autotest to provide a different spec command then the default
|
51
|
+
# paths provided.
|
52
|
+
def spec_command(separator=File::ALT_SEPARATOR)
|
53
|
+
unless defined? @spec_command then
|
54
|
+
@spec_command = spec_commands.find { |cmd| File.exists? cmd }
|
55
|
+
|
56
|
+
raise RspecCommandError, "No spec command could be found!" unless @spec_command
|
57
|
+
|
58
|
+
@spec_command.gsub! File::SEPARATOR, separator if separator
|
72
59
|
end
|
73
|
-
|
60
|
+
@spec_command
|
74
61
|
end
|
75
|
-
|
62
|
+
|
76
63
|
# Autotest will look for spec commands in the following
|
77
64
|
# locations, in this order:
|
78
65
|
#
|
@@ -84,5 +71,4 @@ class Autotest::Rspec < Autotest
|
|
84
71
|
File.join(Config::CONFIG['bindir'], 'spec')
|
85
72
|
]
|
86
73
|
end
|
87
|
-
|
88
74
|
end
|