rspec-search-and-destroy 0.0.2 → 0.0.3
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/.travis.yml +1 -1
- data/README.md +3 -0
- data/Rakefile +10 -0
- data/bin/rspec-sad +21 -2
- data/features/alternate_command.feature +31 -0
- data/features/before_all_blocks_are_disabled.feature +1 -8
- data/features/bisecting_a_single_file.feature +1 -8
- data/features/bisecting_multiple_files.feature +1 -8
- data/features/running_rspec_without_sad.feature +10 -0
- data/features/support/steps.rb +12 -0
- data/lib/rspec-search-and-destroy/order_formatter.rb +9 -3
- data/lib/rspec-search-and-destroy/rspec_driver.rb +13 -8
- data/lib/rspec-search-and-destroy/version.rb +1 -1
- data/rspec-search-and-destroy.gemspec +1 -0
- metadata +22 -2
data/.travis.yml
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/bin/rspec-sad
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
$LOAD_PATH << "$PWD/../lib/"
|
4
3
|
require 'rspec-sad'
|
5
4
|
|
6
5
|
require 'rspec-search-and-destroy/binary_chop_example_selector'
|
@@ -17,9 +16,29 @@ class TTYOutput
|
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
19
|
+
require 'optparse'
|
20
|
+
|
21
|
+
driver_options = {}
|
22
|
+
|
23
|
+
option_parser = OptionParser.new do |opts|
|
24
|
+
opts.banner = <<BANNER
|
25
|
+
Find RSpec test order bugs
|
26
|
+
|
27
|
+
Usage: #{opts.program_name} [options]
|
28
|
+
|
29
|
+
BANNER
|
30
|
+
|
31
|
+
opts.on("--rspec-command COMMAND",
|
32
|
+
"Command to run instead of `rspec`") do |cmd|
|
33
|
+
driver_options[:command] = cmd
|
34
|
+
end
|
35
|
+
end
|
36
|
+
option_parser.parse!
|
37
|
+
|
38
|
+
|
20
39
|
output = TTYOutput.new
|
21
40
|
selector = BinaryChopExampleSelector.new
|
22
|
-
driver = RSpecDriver.new
|
41
|
+
driver = RSpecDriver.new(driver_options)
|
23
42
|
|
24
43
|
driver.initial_run
|
25
44
|
results = driver.load_run_results
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Feature: A command other than `rspec` can be run
|
2
|
+
|
3
|
+
Scenario: Run it
|
4
|
+
Given a configured spec/spec_helper.rb
|
5
|
+
And a file named "intermediate_runner.sh" with:
|
6
|
+
"""
|
7
|
+
echo 'Running the intermediate script'
|
8
|
+
rspec
|
9
|
+
"""
|
10
|
+
And a file named "spec/example_spec.rb" with:
|
11
|
+
"""ruby
|
12
|
+
require 'spec_helper'
|
13
|
+
|
14
|
+
describe "Tests that fail when run in a specific order" do
|
15
|
+
it "leaves bad global state" do
|
16
|
+
$global_state = true
|
17
|
+
expect($global_state).to be true
|
18
|
+
end
|
19
|
+
|
20
|
+
it "just takes up space" do
|
21
|
+
expect(true).to be true
|
22
|
+
end
|
23
|
+
|
24
|
+
it "fails when run last" do
|
25
|
+
expect($global_state).to be false
|
26
|
+
end
|
27
|
+
end
|
28
|
+
"""
|
29
|
+
When I run `rspec-sad --rspec-command='bash ./intermediate_runner.sh'`
|
30
|
+
Then the output should contain "Running the intermediate script"
|
31
|
+
And the output should contain "Culprit found"
|
@@ -1,14 +1,7 @@
|
|
1
1
|
Feature: `before(:all)` blocks are disabled when all of the examples are also disabled
|
2
2
|
|
3
3
|
Scenario: Run it
|
4
|
-
Given a
|
5
|
-
"""ruby
|
6
|
-
require 'rspec-sad'
|
7
|
-
|
8
|
-
RSpec.configure do |config|
|
9
|
-
RSpecSearchAndDestroy.configure(config)
|
10
|
-
end
|
11
|
-
"""
|
4
|
+
Given a configured spec/spec_helper.rb
|
12
5
|
And a file named "spec/before_all_spec.rb" with:
|
13
6
|
"""ruby
|
14
7
|
require 'spec_helper'
|
@@ -1,14 +1,7 @@
|
|
1
1
|
Feature: Bisecting a single file
|
2
2
|
|
3
3
|
Scenario: Run it
|
4
|
-
Given a
|
5
|
-
"""ruby
|
6
|
-
require 'rspec-sad'
|
7
|
-
|
8
|
-
RSpec.configure do |config|
|
9
|
-
RSpecSearchAndDestroy.configure(config)
|
10
|
-
end
|
11
|
-
"""
|
4
|
+
Given a configured spec/spec_helper.rb
|
12
5
|
And a file named "spec/single_file_spec.rb" with:
|
13
6
|
"""ruby
|
14
7
|
require 'spec_helper'
|
@@ -1,14 +1,7 @@
|
|
1
1
|
Feature: Bisecting multiple files
|
2
2
|
|
3
3
|
Scenario: Run it
|
4
|
-
Given a
|
5
|
-
"""ruby
|
6
|
-
require 'rspec-sad'
|
7
|
-
|
8
|
-
RSpec.configure do |config|
|
9
|
-
RSpecSearchAndDestroy.configure(config)
|
10
|
-
end
|
11
|
-
"""
|
4
|
+
Given a configured spec/spec_helper.rb
|
12
5
|
And a file named "spec/file_1_spec.rb" with:
|
13
6
|
"""ruby
|
14
7
|
require 'spec_helper'
|
data/features/support/steps.rb
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
Given(/^a configured spec\/spec_helper\.rb$/) do
|
2
|
+
config = <<CONFIG
|
3
|
+
require 'rspec-sad'
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
RSpecSearchAndDestroy.configure(config)
|
7
|
+
end
|
8
|
+
CONFIG
|
9
|
+
|
10
|
+
write_file("spec/spec_helper.rb", config )
|
11
|
+
end
|
12
|
+
|
1
13
|
Then(/^the output should contain "(.*?)" (\d+) times?$/) do |expected_output, expected_count|
|
2
14
|
actual_count = all_output.scan(expected_output).length
|
3
15
|
expect(actual_count).to eql expected_count.to_i
|
@@ -3,8 +3,10 @@ require 'rspec/core/formatters/base_formatter'
|
|
3
3
|
module RSpecSearchAndDestroy
|
4
4
|
class OrderFormatter < RSpec::Core::Formatters::BaseFormatter
|
5
5
|
def stop
|
6
|
-
|
7
|
-
|
6
|
+
if enabled?
|
7
|
+
File.open(filename, 'wb') do |f|
|
8
|
+
Marshal.dump(results, f)
|
9
|
+
end
|
8
10
|
end
|
9
11
|
|
10
12
|
super
|
@@ -12,8 +14,12 @@ module RSpecSearchAndDestroy
|
|
12
14
|
|
13
15
|
private
|
14
16
|
|
17
|
+
def enabled?
|
18
|
+
filename
|
19
|
+
end
|
20
|
+
|
15
21
|
def filename
|
16
|
-
ENV['RSPEC_SAD_RESULTS']
|
22
|
+
ENV['RSPEC_SAD_RESULTS']
|
17
23
|
end
|
18
24
|
|
19
25
|
def results
|
@@ -1,10 +1,17 @@
|
|
1
1
|
require_relative 'rspec_results'
|
2
|
+
require 'childprocess'
|
2
3
|
|
3
4
|
module RSpecSearchAndDestroy
|
4
5
|
class RSpecDriver
|
5
6
|
RESULT_FILE = '/tmp/example-results'
|
6
7
|
EXAMPLE_FILE = '/tmp/examples-to-run'
|
7
8
|
|
9
|
+
attr_reader :rspec_command
|
10
|
+
|
11
|
+
def initialize(options = {})
|
12
|
+
@rspec_command = options.fetch(:command, 'rspec').split(/\s/)
|
13
|
+
end
|
14
|
+
|
8
15
|
def load_run_results
|
9
16
|
unless File.exist? RESULT_FILE
|
10
17
|
raise <<ERR
|
@@ -42,15 +49,13 @@ ERR
|
|
42
49
|
private
|
43
50
|
|
44
51
|
def run_rspec
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
cmd = "rspec"
|
50
|
-
|
51
|
-
success = system(env, cmd)
|
52
|
+
process = ChildProcess.build(*rspec_command)
|
53
|
+
process.io.inherit!
|
54
|
+
process.environment["RSPEC_SAD_EXAMPLES"] = EXAMPLE_FILE
|
55
|
+
process.environment["RSPEC_SAD_RESULTS"] = RESULT_FILE
|
52
56
|
|
53
|
-
|
57
|
+
process.start
|
58
|
+
process.wait
|
54
59
|
end
|
55
60
|
end
|
56
61
|
end
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
21
|
+
gem.add_dependency('childprocess', '~> 0.3')
|
21
22
|
gem.add_dependency('rspec', '~> 2.12')
|
22
23
|
|
23
24
|
gem.add_development_dependency('rspec', '~> 2.14')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-search-and-destroy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: childprocess
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.3'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.3'
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: rspec
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,9 +91,11 @@ files:
|
|
75
91
|
- README.md
|
76
92
|
- Rakefile
|
77
93
|
- bin/rspec-sad
|
94
|
+
- features/alternate_command.feature
|
78
95
|
- features/before_all_blocks_are_disabled.feature
|
79
96
|
- features/bisecting_a_single_file.feature
|
80
97
|
- features/bisecting_multiple_files.feature
|
98
|
+
- features/running_rspec_without_sad.feature
|
81
99
|
- features/support/env.rb
|
82
100
|
- features/support/steps.rb
|
83
101
|
- lib/rspec-sad.rb
|
@@ -120,9 +138,11 @@ signing_key:
|
|
120
138
|
specification_version: 3
|
121
139
|
summary: Finds RSpec test ordering bugs
|
122
140
|
test_files:
|
141
|
+
- features/alternate_command.feature
|
123
142
|
- features/before_all_blocks_are_disabled.feature
|
124
143
|
- features/bisecting_a_single_file.feature
|
125
144
|
- features/bisecting_multiple_files.feature
|
145
|
+
- features/running_rspec_without_sad.feature
|
126
146
|
- features/support/env.rb
|
127
147
|
- features/support/steps.rb
|
128
148
|
- spec/binary_chop_example_selector_spec.rb
|