rspec-autotest 0.0.1.pre → 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +21 -0
- data/.rspec +3 -0
- data/.travis.yml +13 -0
- data/Changelog.md +4 -0
- data/Gemfile +24 -0
- data/License.txt +24 -0
- data/README.md +71 -0
- data/Rakefile +12 -0
- data/lib/autotest/discover.rb +1 -0
- data/lib/autotest/rails_rspec2.rb +1 -0
- data/lib/autotest/rspec2.rb +1 -0
- data/lib/rspec/autotest.rb +70 -0
- data/lib/rspec/autotest/version.rb +5 -0
- data/lib/rspec/rails/autotest.rb +84 -0
- data/rspec-autotest.gemspec +33 -0
- data/script/test_all +39 -0
- data/spec/autotest/discover_spec.rb +19 -0
- data/spec/autotest/failed_results_re_spec.rb +45 -0
- data/spec/autotest/rspec_rails_spec.rb +36 -0
- data/spec/autotest/rspec_spec.rb +134 -0
- data/spec/spec_helper.rb +35 -0
- data/spec/support/matchers.rb +21 -0
- metadata +122 -13
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NzRkNjFhODIxN2ZjM2Q1ZTUzNjI3NTY5OTRlNDNkOTE4MGM1MmM2OQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZGVmZTAyZmEyMzYwNTlhMDZiM2U5MjMxMTgyZjBkMjQ5ODk5NTU0Nw==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MzMwNmIzNDVjN2I4NWNjNWYwODgwMGNmYzQ0YjY0ZDZlMmZkZGU0MzNkN2E5
|
10
|
+
YWI1NjRiMWVlZjBjYzY4NWNkYTkyMTNmM2JjY2E5MTUzOGE5NDk3ODJhMDMz
|
11
|
+
YzUzY2VmNTRiZGRjYTgwYTRiMTM0OThkMzhlYjc1NTM3OWExZWY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NGY1M2I1ODUyNmJiNWY4MWUxZDgxNDk3ODEzMzU0NWM0NmNjYjYwODFkNjNl
|
14
|
+
YTI2MDBhMzI5NjZhMzRmNDM0Mjc5NjY5OWJjM2U2YjMzZTBlN2FkNDc5Mzli
|
15
|
+
MGY3NTQzNzBmNWE1YjkyZWQ4ZWJhYzllNmZhNDlkYTgwNGJjMWY=
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Changelog.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
%w[rspec rspec-core rspec-expectations rspec-mocks].each do |lib|
|
6
|
+
library_path = File.expand_path("../../#{lib}", __FILE__)
|
7
|
+
if File.exist?(library_path)
|
8
|
+
gem lib, :path => library_path
|
9
|
+
else
|
10
|
+
gem lib, :git => "git://github.com/rspec/#{lib}.git", :branch => '2-99-maintenance'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
### deps for rdoc.info
|
15
|
+
platforms :ruby do
|
16
|
+
gem 'yard', '0.8.6.1', :require => false
|
17
|
+
gem 'redcarpet', '2.1.1'
|
18
|
+
gem 'github-markup', '0.7.2'
|
19
|
+
end
|
20
|
+
|
21
|
+
### dep for ci/coverage
|
22
|
+
gem 'coveralls', :require => false
|
23
|
+
|
24
|
+
eval File.read('Gemfile-custom') if File.exist?('Gemfile-custom')
|
data/License.txt
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2009 Chad Humphries, David Chelimsky
|
4
|
+
Copyright (c) 2006 David Chelimsky, The RSpec Development Team
|
5
|
+
Copyright (c) 2005 Steven Baker
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
8
|
+
a copy of this software and associated documentation files (the
|
9
|
+
"Software"), to deal in the Software without restriction, including
|
10
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
11
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
12
|
+
permit persons to whom the Software is furnished to do so, subject to
|
13
|
+
the following conditions:
|
14
|
+
|
15
|
+
The above copyright notice and this permission notice shall be
|
16
|
+
included in all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
20
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
21
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
22
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
23
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
24
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# rspec-autotest [![Build Status](https://secure.travis-ci.org/rspec/rspec-autotest.png?branch=master)](http://travis-ci.org/rspec/rspec-autotest) [![Code Climate](https://codeclimate.com/github/rspec/rspec-autotest.png)](https://codeclimate.com/github/rspec/rspec-autotest) [![Coverage Status](https://coveralls.io/repos/rspec/rspec-autotest/badge.png?branch=master)](https://coveralls.io/r/rspec/rspec-autotest?branch=master)
|
2
|
+
|
3
|
+
rspec-autotest provides integration between autotest and RSpec
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
RSpec ships with a specialized subclass of Autotest. To use it, just add a
|
8
|
+
`.rspec` file to your project's root directory, and run the `autotest` command
|
9
|
+
as normal:
|
10
|
+
|
11
|
+
$ autotest
|
12
|
+
|
13
|
+
## Bundler
|
14
|
+
|
15
|
+
The `autotest` command generates a shell command that runs your specs. If you
|
16
|
+
are using Bundler, and you want the shell command to include `bundle exec`,
|
17
|
+
require the Autotest bundler plugin in a `.autotest` file in the project's root
|
18
|
+
directory or your home directory:
|
19
|
+
|
20
|
+
# in .autotest
|
21
|
+
require "autotest/bundler"
|
22
|
+
|
23
|
+
## Rails
|
24
|
+
|
25
|
+
To use RSpec and Rails with autotest, bring in the `autotest-rails` gem:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
# Gemfile
|
29
|
+
gem 'autotest-rails', :group => [:development, :test]
|
30
|
+
```
|
31
|
+
|
32
|
+
`autotest` will now autodetect RSpec and Rails after you run the `rails
|
33
|
+
generate rspec:install` command.
|
34
|
+
|
35
|
+
## Gotchas
|
36
|
+
|
37
|
+
### Invalid Option: --tty
|
38
|
+
|
39
|
+
The `--tty` option was [added in rspec-core-2.2.1](changelog), and is used
|
40
|
+
internally by RSpec. If you see an error citing it as an invalid option, you'll
|
41
|
+
probably see there are two or more versions of rspec-core in the backtrace: one
|
42
|
+
< 2.2.1 and one >= 2.2.1.
|
43
|
+
|
44
|
+
This usually happens because you have a newer rspec-core installed, and an
|
45
|
+
older rspec-core specified in a Bundler Gemfile. If this is the case, you can:
|
46
|
+
|
47
|
+
1. specify the newer version in the Gemfile (recommended)
|
48
|
+
2. prefix the `autotest` command with `bundle exec`
|
49
|
+
|
50
|
+
|
51
|
+
## Installation
|
52
|
+
|
53
|
+
Add this line to your application's Gemfile:
|
54
|
+
|
55
|
+
gem 'rspec-autotest'
|
56
|
+
|
57
|
+
And then execute:
|
58
|
+
|
59
|
+
$ bundle
|
60
|
+
|
61
|
+
Or install it yourself as:
|
62
|
+
|
63
|
+
$ gem install rspec-autotest
|
64
|
+
|
65
|
+
## Contributing
|
66
|
+
|
67
|
+
1. Fork it
|
68
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
69
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
70
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
71
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Autotest.add_discovery { "rspec2" } if File.exist?("./.rspec")
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'rspec/rails/autotest'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'rspec/autotest'
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'rspec/core'
|
2
|
+
require 'autotest'
|
3
|
+
|
4
|
+
# Derived from the `Autotest` class, extends the `autotest` command to work
|
5
|
+
# with RSpec.
|
6
|
+
#
|
7
|
+
class Autotest::Rspec2 < Autotest
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
super()
|
11
|
+
clear_mappings
|
12
|
+
setup_rspec_project_mappings
|
13
|
+
|
14
|
+
# Example for Ruby 1.8: http://rubular.com/r/AOXNVDrZpx
|
15
|
+
# Example for Ruby 1.9: http://rubular.com/r/85ag5AZ2jP
|
16
|
+
self.failed_results_re = /^\s*\d+\).*\n\s+(?:\e\[\d*m)?Failure.*(\n(?:\e\[\d*m)?\s+#\s(.*)?:\d+(?::.*)?(?:\e\[\d*m)?)+$/m
|
17
|
+
self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/m
|
18
|
+
end
|
19
|
+
|
20
|
+
# Adds conventional spec-to-file mappings to Autotest configuration.
|
21
|
+
def setup_rspec_project_mappings
|
22
|
+
add_mapping(%r%^spec/.*_spec\.rb$%) { |filename, _|
|
23
|
+
filename
|
24
|
+
}
|
25
|
+
add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
|
26
|
+
["spec/#{m[1]}_spec.rb"]
|
27
|
+
}
|
28
|
+
add_mapping(%r%^spec/(spec_helper|shared/.*)\.rb$%) {
|
29
|
+
files_matching %r%^spec/.*_spec\.rb$%
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Overrides Autotest's implementation to read rspec output
|
34
|
+
def consolidate_failures(failed)
|
35
|
+
filters = new_hash_of_arrays
|
36
|
+
failed.each do |spec, trace|
|
37
|
+
if trace =~ /(.*spec\.rb)/
|
38
|
+
filters[$1] << spec
|
39
|
+
end
|
40
|
+
end
|
41
|
+
return filters
|
42
|
+
end
|
43
|
+
|
44
|
+
# Overrides Autotest's implementation to generate the rspec command to run
|
45
|
+
def make_test_cmd(files_to_test)
|
46
|
+
files_to_test.empty? ? '' :
|
47
|
+
%|#{prefix}"#{ruby}"#{suffix} -S "#{RSpec::Core.path_to_executable}" --tty #{normalize(files_to_test).keys.flatten.map { |f| %|"#{f}"|}.join(' ')}|
|
48
|
+
end
|
49
|
+
|
50
|
+
# Generates a map of filenames to Arrays for Autotest
|
51
|
+
def normalize(files_to_test)
|
52
|
+
files_to_test.keys.inject({}) do |result, filename|
|
53
|
+
result.merge!(File.expand_path(filename) => [])
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def suffix
|
60
|
+
using_bundler? ? "" : defined?(:Gem) ? " -rrubygems" : ""
|
61
|
+
end
|
62
|
+
|
63
|
+
def using_bundler?
|
64
|
+
prefix =~ /bundle exec/
|
65
|
+
end
|
66
|
+
|
67
|
+
def gemfile?
|
68
|
+
File.exist?('./Gemfile')
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# (c) Copyright 2006 Nick Sieger <nicksieger@gmail.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person
|
4
|
+
# obtaining a copy of this software and associated documentation files
|
5
|
+
# (the "Software"), to deal in the Software without restriction,
|
6
|
+
# including without limitation the rights to use, copy, modify, merge,
|
7
|
+
# publish, distribute, sublicense, and/or sell copies of the Software,
|
8
|
+
# and to permit persons to whom the Software is furnished to do so,
|
9
|
+
# subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
18
|
+
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
19
|
+
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
|
23
|
+
$:.push(*Dir["vendor/rails/*/lib"])
|
24
|
+
|
25
|
+
require 'active_support/core_ext'
|
26
|
+
require 'autotest/rspec2'
|
27
|
+
|
28
|
+
class Autotest::RailsRspec2 < Autotest::Rspec2
|
29
|
+
|
30
|
+
def initialize
|
31
|
+
super
|
32
|
+
setup_rails_rspec2_mappings
|
33
|
+
end
|
34
|
+
|
35
|
+
def setup_rails_rspec2_mappings
|
36
|
+
%w{coverage/ db/ doc/ log/ public/ script/ tmp/ vendor/rails vendor/plugins vendor/gems}.each do |exception|
|
37
|
+
add_exception(/^([\.\/]*)?#{exception}/)
|
38
|
+
end
|
39
|
+
|
40
|
+
clear_mappings
|
41
|
+
|
42
|
+
add_mapping(%r%^(test|spec)/fixtures/(.*).yml$%) { |_, m|
|
43
|
+
["spec/models/#{m[2].singularize}_spec.rb"] + files_matching(%r%^spec\/views\/#{m[2]}/.*_spec\.rb$%)
|
44
|
+
}
|
45
|
+
add_mapping(%r%^spec/.*_spec\.rb$%) { |filename, _|
|
46
|
+
filename
|
47
|
+
}
|
48
|
+
add_mapping(%r%^app/models/(.*)\.rb$%) { |_, m|
|
49
|
+
["spec/models/#{m[1]}_spec.rb"]
|
50
|
+
}
|
51
|
+
add_mapping(%r%^app/views/(.*)$%) { |_, m|
|
52
|
+
files_matching %r%^spec/views/#{m[1]}_spec.rb$%
|
53
|
+
}
|
54
|
+
add_mapping(%r%^app/controllers/(.*)\.rb$%) { |_, m|
|
55
|
+
if m[1] == "application"
|
56
|
+
files_matching %r%^spec/controllers/.*_spec\.rb$%
|
57
|
+
else
|
58
|
+
["spec/controllers/#{m[1]}_spec.rb"]
|
59
|
+
end
|
60
|
+
}
|
61
|
+
add_mapping(%r%^app/helpers/(.*)_helper\.rb$%) { |_, m|
|
62
|
+
if m[1] == "application" then
|
63
|
+
files_matching(%r%^spec/(views|helpers)/.*_spec\.rb$%)
|
64
|
+
else
|
65
|
+
["spec/helpers/#{m[1]}_helper_spec.rb"] + files_matching(%r%^spec\/views\/#{m[1]}/.*_spec\.rb$%)
|
66
|
+
end
|
67
|
+
}
|
68
|
+
add_mapping(%r%^config/routes\.rb$%) {
|
69
|
+
files_matching %r%^spec/(controllers|routing|views|helpers)/.*_spec\.rb$%
|
70
|
+
}
|
71
|
+
add_mapping(%r%^config/database\.yml$%) { |_, m|
|
72
|
+
files_matching %r%^spec/models/.*_spec\.rb$%
|
73
|
+
}
|
74
|
+
add_mapping(%r%^(spec/(spec_helper|support/.*)|config/(boot|environment(s/test)?))\.rb$%) {
|
75
|
+
files_matching %r%^spec/(models|controllers|routing|views|helpers)/.*_spec\.rb$%
|
76
|
+
}
|
77
|
+
add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
|
78
|
+
["spec/lib/#{m[1]}_spec.rb"]
|
79
|
+
}
|
80
|
+
add_mapping(%r%^app/mailers/(.*)\.rb$%) { |_, m|
|
81
|
+
["spec/mailers/#{m[1]}_spec.rb"]
|
82
|
+
}
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rspec/autotest/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rspec-autotest"
|
8
|
+
spec.version = RSpec::Autotest::VERSION
|
9
|
+
spec.authors = ["Steven Baker", "David Chelimsky", "Chad Humphries"]
|
10
|
+
spec.email = "rspec-users@rubyforge.org"
|
11
|
+
spec.homepage = "https://github.com/rspec/rspec-autotest"
|
12
|
+
spec.summary = "rspec-autotest-#{RSpec::Autotest::VERSION}"
|
13
|
+
spec.description = "RSpec Autotest integration"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.rubyforge_project = "rspec"
|
17
|
+
|
18
|
+
spec.files = `git ls-files`.split($/)
|
19
|
+
spec.test_files = spec.files.grep(%r{^(spec|features)/})
|
20
|
+
spec.rdoc_options = ["--charset=UTF-8"]
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.required_ruby_version = '>= 1.8.7'
|
24
|
+
|
25
|
+
spec.add_dependency "rspec-core", ">= 2.99.0.pre"
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0.0"
|
29
|
+
spec.add_development_dependency "aruba", "~> 0.5"
|
30
|
+
spec.add_development_dependency "ZenTest", "~> 4.6"
|
31
|
+
spec.add_development_dependency "i18n", "~> 0.6.4"
|
32
|
+
spec.add_development_dependency "activesupport", "~> 3.0"
|
33
|
+
end
|
data/script/test_all
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -e -x
|
4
|
+
|
5
|
+
function is_jruby() {
|
6
|
+
if ruby -e 'exit RUBY_PLATFORM == "java"'; then
|
7
|
+
return 0
|
8
|
+
else
|
9
|
+
return 1
|
10
|
+
fi
|
11
|
+
}
|
12
|
+
|
13
|
+
# Needed by Bundler 1.3: https://github.com/carlhuda/bundler/issues/2382
|
14
|
+
export RUBYOPT='-rrbconfig'
|
15
|
+
|
16
|
+
# idea taken from: http://blog.headius.com/2010/03/jruby-startup-time-tips.html
|
17
|
+
export JRUBY_OPTS='-X-C' # disable JIT since these processes are so short lived
|
18
|
+
|
19
|
+
# force jRuby to use client mode JVM or a compilation mode thats as close as possible,
|
20
|
+
# idea taken from https://github.com/jruby/jruby/wiki/Improving-startup-time
|
21
|
+
export JAVA_OPTS='-client -XX:+TieredCompilation -XX:TieredStopAtLevel=1'
|
22
|
+
|
23
|
+
echo "Bundling Standalone so we can run the specs w/o bundler loaded"
|
24
|
+
bundle install --standalone --binstubs
|
25
|
+
|
26
|
+
echo "Running all..."
|
27
|
+
bin/rspec spec -b --format progress
|
28
|
+
|
29
|
+
echo
|
30
|
+
echo "--------------------------------------------------------------------"
|
31
|
+
echo
|
32
|
+
|
33
|
+
if is_jruby; then
|
34
|
+
echo "Skipping one-by-one spec runs due to expensive JVM load time"
|
35
|
+
else
|
36
|
+
for file in `find spec -iname '*_spec.rb'`; do
|
37
|
+
NO_COVERALLS=1 bin/rspec $file -b --format progress
|
38
|
+
done
|
39
|
+
fi
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "autotest/discover.rb" do
|
4
|
+
context "with ./.rspec present" do
|
5
|
+
it "adds 'rspec2' to the list of discoveries" do
|
6
|
+
File.stub(:exist?).with("./.rspec") { true }
|
7
|
+
Autotest.should_receive(:add_discovery)
|
8
|
+
load File.expand_path("../../../lib/autotest/discover.rb", __FILE__)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context "with ./.rspec absent" do
|
13
|
+
it "does not add 'rspec2' to the list of discoveries" do
|
14
|
+
File.stub(:exist?) { false }
|
15
|
+
Autotest.should_not_receive(:add_discovery)
|
16
|
+
load File.expand_path("../../../lib/autotest/discover.rb", __FILE__)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "failed_results_re for autotest" do
|
4
|
+
def run_example
|
5
|
+
group = RSpec::Core::ExampleGroup.describe("group")
|
6
|
+
group.example("example") { yield }
|
7
|
+
io = StringIO.new
|
8
|
+
formatter = RSpec::Core::Formatters::BaseTextFormatter.new(io)
|
9
|
+
reporter = RSpec::Core::Reporter.new(formatter)
|
10
|
+
|
11
|
+
group.run(reporter)
|
12
|
+
reporter.report(1, nil) {}
|
13
|
+
io.string
|
14
|
+
end
|
15
|
+
|
16
|
+
shared_examples "autotest failed_results_re" do
|
17
|
+
it "matches a failure" do
|
18
|
+
output = run_example { fail }
|
19
|
+
expect(output).to match(Autotest::Rspec2.new.failed_results_re)
|
20
|
+
expect(output).to include(__FILE__.sub(File.expand_path('.'),'.'))
|
21
|
+
end
|
22
|
+
|
23
|
+
it "does not match when there are no failures" do
|
24
|
+
output = run_example { } # pass
|
25
|
+
expect(output).not_to match(Autotest::Rspec2.new.failed_results_re)
|
26
|
+
expect(output).not_to include(__FILE__.sub(File.expand_path('.'),'.'))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "with color enabled" do
|
31
|
+
before do
|
32
|
+
RSpec.configuration.stub(:color_enabled? => true)
|
33
|
+
end
|
34
|
+
|
35
|
+
include_examples "autotest failed_results_re"
|
36
|
+
end
|
37
|
+
|
38
|
+
context "with color disabled " do
|
39
|
+
before do
|
40
|
+
RSpec.configuration.stub(:color_enabled? => false)
|
41
|
+
end
|
42
|
+
|
43
|
+
include_examples "autotest failed_results_re"
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "autotest/rails_rspec2"
|
3
|
+
|
4
|
+
describe Autotest::RailsRspec2 do
|
5
|
+
|
6
|
+
let(:rails_rspec2_autotest) { Autotest::RailsRspec2.new }
|
7
|
+
|
8
|
+
describe 'exceptions' do
|
9
|
+
let(:exceptions_regexp) { rails_rspec2_autotest.exceptions }
|
10
|
+
|
11
|
+
it "matches './log/test.log'" do
|
12
|
+
expect(exceptions_regexp).to match('./log/test.log')
|
13
|
+
end
|
14
|
+
|
15
|
+
it "matches 'log/test.log'" do
|
16
|
+
expect(exceptions_regexp).to match('log/test.log')
|
17
|
+
end
|
18
|
+
|
19
|
+
it "does not match './spec/models/user_spec.rb'" do
|
20
|
+
expect(exceptions_regexp).not_to match('./spec/models/user_spec.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
it "does not match 'spec/models/user_spec.rb'" do
|
24
|
+
expect(exceptions_regexp).not_to match('spec/models/user_spec.rb')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'mappings' do
|
29
|
+
it 'runs model specs when support files change' do
|
30
|
+
rails_rspec2_autotest.find_order = %w(spec/models/user_spec.rb spec/support/blueprints.rb)
|
31
|
+
expect(rails_rspec2_autotest.test_files_for('spec/support/blueprints.rb')).to(
|
32
|
+
include('spec/models/user_spec.rb'))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "autotest/rspec2"
|
3
|
+
|
4
|
+
describe Autotest::Rspec2 do
|
5
|
+
let(:rspec_autotest) { Autotest::Rspec2.new }
|
6
|
+
let(:spec_cmd) { RSpec::Core.path_to_executable }
|
7
|
+
let(:ruby_cmd) { "/path/to/ruby" }
|
8
|
+
|
9
|
+
before do
|
10
|
+
File.stub(:exist?) { false }
|
11
|
+
end
|
12
|
+
|
13
|
+
it "uses autotest's prefix" do
|
14
|
+
rspec_autotest.prefix = "this is the prefix "
|
15
|
+
expect(rspec_autotest.make_test_cmd({'a' => 'b'})).to match(/this is the prefix/)
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "commands" do
|
19
|
+
before do
|
20
|
+
rspec_autotest.stub(:ruby => ruby_cmd)
|
21
|
+
files = %w[file_one file_two]
|
22
|
+
@files_to_test = {
|
23
|
+
files[0] => [],
|
24
|
+
files[1] => []
|
25
|
+
}
|
26
|
+
# this is not the inner representation of Autotest!
|
27
|
+
rspec_autotest.files_to_test = @files_to_test
|
28
|
+
@to_test = files.map { |f| File.expand_path(f) }.join ' '
|
29
|
+
end
|
30
|
+
|
31
|
+
it "uses double quotes for windows compatibility" do
|
32
|
+
command = rspec_autotest.make_test_cmd(@files_to_test)
|
33
|
+
expect(command).to include('"')
|
34
|
+
expect(command).not_to include("'")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "makes the appropriate test command" do
|
38
|
+
actual_command = rspec_autotest.make_test_cmd(@files_to_test)
|
39
|
+
expected_command = /#{ruby_cmd}.*"#{spec_cmd}" (.*)/
|
40
|
+
|
41
|
+
expect(actual_command).to match(expected_command)
|
42
|
+
|
43
|
+
actual_command =~ expected_command
|
44
|
+
expect($1).to match(/#{File.expand_path('file_one')}/)
|
45
|
+
expect($1).to match(/#{File.expand_path('file_two')}/)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "returns a blank command for no files" do
|
49
|
+
expect(rspec_autotest.make_test_cmd({})).to eq('')
|
50
|
+
end
|
51
|
+
|
52
|
+
it "quotes the paths of files to test" do
|
53
|
+
cmd = rspec_autotest.make_test_cmd(@files_to_test)
|
54
|
+
@files_to_test.keys.each do |file_to_test|
|
55
|
+
expect(cmd).to match(/"#{File.expand_path(file_to_test)}"/)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it "quotes the path of the ruby executable" do
|
60
|
+
cmd = rspec_autotest.make_test_cmd(@files_to_test)
|
61
|
+
expect(cmd).to match(%r("/path/to/ruby"))
|
62
|
+
end
|
63
|
+
|
64
|
+
it "gives '--tty' to #{ RSpec::Core.path_to_executable }, not '--autotest'" do
|
65
|
+
cmd = rspec_autotest.make_test_cmd(@files_to_test)
|
66
|
+
expect(cmd).to match(' --tty ')
|
67
|
+
expect(cmd).not_to match(' --autotest ')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "mappings" do
|
72
|
+
before do
|
73
|
+
@lib_file = "lib/something.rb"
|
74
|
+
@spec_file = "spec/something_spec.rb"
|
75
|
+
rspec_autotest.hook :initialize
|
76
|
+
end
|
77
|
+
|
78
|
+
it "finds the spec file for a given lib file" do
|
79
|
+
expect(rspec_autotest).to map_specs([@spec_file]).to(@lib_file)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "finds the spec file if given a spec file" do
|
83
|
+
expect(rspec_autotest).to map_specs([@spec_file]).to(@spec_file)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "ignores files in spec dir that aren't specs" do
|
87
|
+
expect(rspec_autotest).to map_specs([]).to("spec/spec_helper.rb")
|
88
|
+
end
|
89
|
+
|
90
|
+
it "ignores untracked files (in @file)" do
|
91
|
+
expect(rspec_autotest).to map_specs([]).to("lib/untracked_file")
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "consolidating failures" do
|
96
|
+
let(:subject_file) { "lib/autotest/some.rb" }
|
97
|
+
let(:spec_file) { "spec/autotest/some_spec.rb" }
|
98
|
+
|
99
|
+
it "returns no failures if no failures were given in the output" do
|
100
|
+
expect(rspec_autotest.consolidate_failures([[]])).to eq({})
|
101
|
+
end
|
102
|
+
|
103
|
+
it "returns a hash with the spec filename => spec name for each failure or error" do
|
104
|
+
failures = [ [ "false should be false", spec_file ] ]
|
105
|
+
expect(rspec_autotest.consolidate_failures(failures)).to eq({
|
106
|
+
spec_file => ["false should be false"]
|
107
|
+
})
|
108
|
+
end
|
109
|
+
|
110
|
+
context "when subject file appears before the spec file in the backtrace" do
|
111
|
+
let(:failures) do
|
112
|
+
[ [ "false should be false", "#{subject_file}:143:\n#{spec_file}:203:" ] ]
|
113
|
+
end
|
114
|
+
|
115
|
+
it "excludes the subject file" do
|
116
|
+
expect(rspec_autotest.consolidate_failures(failures).keys).not_to include(subject_file)
|
117
|
+
end
|
118
|
+
|
119
|
+
it "includes the spec file" do
|
120
|
+
expect(rspec_autotest.consolidate_failures(failures).keys).to include(spec_file)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe "normalizing file names" do
|
126
|
+
it "ensures that a single file appears in files_to_test only once" do
|
127
|
+
@files_to_test = {}
|
128
|
+
['filename.rb', './filename.rb', File.expand_path('filename.rb')].each do |file|
|
129
|
+
@files_to_test[file] = []
|
130
|
+
end
|
131
|
+
expect(rspec_autotest.normalize(@files_to_test)).to have(1).file
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rspec/autorun'
|
3
|
+
require 'rspec/autotest'
|
4
|
+
require 'aruba/api'
|
5
|
+
|
6
|
+
unless ENV['NO_COVERALLS']
|
7
|
+
require 'simplecov' if RUBY_VERSION.to_f > 1.8
|
8
|
+
require 'coveralls'
|
9
|
+
Coveralls.wear! do
|
10
|
+
add_filter '/bundle/'
|
11
|
+
add_filter '/spec/'
|
12
|
+
add_filter '/tmp/'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
if RUBY_PLATFORM == 'java'
|
17
|
+
# Works around https://jira.codehaus.org/browse/JRUBY-5678
|
18
|
+
require 'fileutils'
|
19
|
+
ENV['TMPDIR'] = File.expand_path('../../tmp', __FILE__)
|
20
|
+
FileUtils.mkdir_p(ENV['TMPDIR'])
|
21
|
+
end
|
22
|
+
|
23
|
+
Dir['./spec/support/**/*.rb'].map {|f| require f}
|
24
|
+
|
25
|
+
RSpec.configure do |c|
|
26
|
+
|
27
|
+
c.expect_with :rspec do |expectations|
|
28
|
+
expectations.syntax = :expect
|
29
|
+
end
|
30
|
+
|
31
|
+
# runtime options
|
32
|
+
c.treat_symbols_as_metadata_keys_with_true_values = true
|
33
|
+
c.filter_run :focus
|
34
|
+
c.run_all_when_everything_filtered = true
|
35
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
RSpec::Matchers.define :map_specs do |specs|
|
2
|
+
match do |autotest|
|
3
|
+
@specs = specs
|
4
|
+
@autotest = prepare(autotest)
|
5
|
+
autotest.test_files_for(@file) == specs
|
6
|
+
end
|
7
|
+
|
8
|
+
chain :to do |file|
|
9
|
+
@file = file
|
10
|
+
end
|
11
|
+
|
12
|
+
failure_message_for_should do
|
13
|
+
"expected #{@autotest.class} to map #{@specs.inspect} to #{@file.inspect}\ngot #{@actual.inspect}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def prepare(autotest)
|
17
|
+
find_order = @specs.dup << @file
|
18
|
+
autotest.instance_eval { @find_order = find_order }
|
19
|
+
autotest
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-autotest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.0.1.pre
|
4
|
+
version: 1.0.0.beta1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Steven Baker
|
@@ -11,33 +10,138 @@ authors:
|
|
11
10
|
autorequire:
|
12
11
|
bindir: bin
|
13
12
|
cert_chain: []
|
14
|
-
date: 2013-
|
13
|
+
date: 2013-11-05 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec-core
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.99.0.pre
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
17
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ! '>='
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 2.99.0.pre
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: bundler
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
18
32
|
requirements:
|
19
33
|
- - ~>
|
20
34
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
22
|
-
|
35
|
+
version: '1.3'
|
36
|
+
type: :development
|
23
37
|
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '1.3'
|
43
|
+
- !ruby/object:Gem::Dependency
|
24
44
|
name: rake
|
25
45
|
requirement: !ruby/object:Gem::Requirement
|
26
46
|
requirements:
|
27
47
|
- - ~>
|
28
48
|
- !ruby/object:Gem::Version
|
29
49
|
version: 10.0.0
|
30
|
-
none: false
|
31
50
|
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 10.0.0
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: aruba
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ~>
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0.5'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ~>
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0.5'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: ZenTest
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '4.6'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ~>
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '4.6'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: i18n
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ~>
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 0.6.4
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ~>
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 0.6.4
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: activesupport
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ~>
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '3.0'
|
106
|
+
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ~>
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '3.0'
|
32
113
|
description: RSpec Autotest integration
|
33
114
|
email: rspec-users@rubyforge.org
|
34
115
|
executables: []
|
35
116
|
extensions: []
|
36
117
|
extra_rdoc_files: []
|
37
|
-
files:
|
118
|
+
files:
|
119
|
+
- .gitignore
|
120
|
+
- .rspec
|
121
|
+
- .travis.yml
|
122
|
+
- Changelog.md
|
123
|
+
- Gemfile
|
124
|
+
- License.txt
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
127
|
+
- lib/autotest/discover.rb
|
128
|
+
- lib/autotest/rails_rspec2.rb
|
129
|
+
- lib/autotest/rspec2.rb
|
130
|
+
- lib/rspec/autotest.rb
|
131
|
+
- lib/rspec/autotest/version.rb
|
132
|
+
- lib/rspec/rails/autotest.rb
|
133
|
+
- rspec-autotest.gemspec
|
134
|
+
- script/test_all
|
135
|
+
- spec/autotest/discover_spec.rb
|
136
|
+
- spec/autotest/failed_results_re_spec.rb
|
137
|
+
- spec/autotest/rspec_rails_spec.rb
|
138
|
+
- spec/autotest/rspec_spec.rb
|
139
|
+
- spec/spec_helper.rb
|
140
|
+
- spec/support/matchers.rb
|
38
141
|
homepage: https://github.com/rspec/rspec-autotest
|
39
142
|
licenses:
|
40
143
|
- MIT
|
144
|
+
metadata: {}
|
41
145
|
post_install_message:
|
42
146
|
rdoc_options:
|
43
147
|
- --charset=UTF-8
|
@@ -48,17 +152,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
48
152
|
- - ! '>='
|
49
153
|
- !ruby/object:Gem::Version
|
50
154
|
version: 1.8.7
|
51
|
-
none: false
|
52
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
156
|
requirements:
|
54
157
|
- - ! '>'
|
55
158
|
- !ruby/object:Gem::Version
|
56
159
|
version: 1.3.1
|
57
|
-
none: false
|
58
160
|
requirements: []
|
59
161
|
rubyforge_project: rspec
|
60
|
-
rubygems_version:
|
162
|
+
rubygems_version: 2.0.7
|
61
163
|
signing_key:
|
62
|
-
specification_version:
|
63
|
-
summary: rspec-autotest-0.0.
|
64
|
-
test_files:
|
164
|
+
specification_version: 4
|
165
|
+
summary: rspec-autotest-1.0.0.beta1
|
166
|
+
test_files:
|
167
|
+
- spec/autotest/discover_spec.rb
|
168
|
+
- spec/autotest/failed_results_re_spec.rb
|
169
|
+
- spec/autotest/rspec_rails_spec.rb
|
170
|
+
- spec/autotest/rspec_spec.rb
|
171
|
+
- spec/spec_helper.rb
|
172
|
+
- spec/support/matchers.rb
|
173
|
+
has_rdoc:
|