generative 0.2.0.pre2 → 0.2.0.pre3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -3
- data/CHANGELOG.md +4 -0
- data/README.md +0 -14
- data/Rakefile +17 -6
- data/generative.gemspec +2 -9
- data/lib/generative/dsl.rb +1 -5
- data/lib/generative/formatters.rb +33 -12
- data/lib/generative/ordering.rb +7 -9
- data/lib/generative/rake_task.rb +1 -1
- data/spec/generative/ordering_spec.rb +24 -0
- data/spec/generative/rake_task_spec.rb +39 -0
- metadata +19 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5faa370af27a180158e8c85e3fd490e17705d648
|
4
|
+
data.tar.gz: cf64fb8e0597e19ab5008e85178307ba1f8a9be9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fe5857f7cbf5ed68100cb824b3c4a2c77b8aee62b8c55e44b3cad2aa61180a2a089f95c846bf8eec88674c7b436cf233afbe9f86d00f9458be25a86bb1749d5
|
7
|
+
data.tar.gz: 9ddf3005b3c3be9064cd6f0c5bc8cf6b5bc8a6c8c50c09af960252b552e96829cc23dcd40fd6b8786c9d4b79eb80b3169c5b7d9a587b839142efc68411ebfaf7
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -38,20 +38,6 @@ RSpec::Core::RakeTask.new
|
|
38
38
|
Generative::RakeTask.new
|
39
39
|
```
|
40
40
|
|
41
|
-
### Remove any random/other ordering
|
42
|
-
|
43
|
-
If using RSpec 2, you'll need to make sure you remove `config.order =
|
44
|
-
'random'`, or any other ordering strategies, from your spec helper. You can
|
45
|
-
also use `Generative.running?` to only disable random ordering during
|
46
|
-
Generative runs:
|
47
|
-
|
48
|
-
```rb
|
49
|
-
config.order = :random unless Generative.running?
|
50
|
-
```
|
51
|
-
|
52
|
-
In RSpec 3, this is not necessary, because each example group (the `generative`
|
53
|
-
block) can override ordering for that group.
|
54
|
-
|
55
41
|
## Usage
|
56
42
|
|
57
43
|
### Specs
|
data/Rakefile
CHANGED
@@ -10,16 +10,27 @@ Generative::RakeTask.new
|
|
10
10
|
|
11
11
|
desc "Verify all spec commands behave properly"
|
12
12
|
task :acceptance do
|
13
|
+
ENV.delete('GENERATIVE_COUNT')
|
14
|
+
|
13
15
|
[
|
14
|
-
['rspec', '
|
15
|
-
['rake spec', '
|
16
|
+
['rspec', '13'],
|
17
|
+
['rake spec', '13'],
|
16
18
|
['rake generative', '30000'],
|
17
19
|
['bin/generative', '30000']
|
18
|
-
].each do |command,
|
19
|
-
|
20
|
+
].each do |command, expected_example_count|
|
21
|
+
puts "Checking output of `#{command}`"
|
22
|
+
output = %x{#{command}}
|
23
|
+
pattern = /(\d+) examples, (\d+) failures/
|
24
|
+
_, example_count, failure_count = output.match(pattern).to_a
|
25
|
+
|
26
|
+
unless failure_count == '0'
|
27
|
+
fail "`#{command}` had #{failure_count} failures"
|
28
|
+
end
|
20
29
|
|
21
|
-
unless
|
22
|
-
fail "`#{command}` had an incorrect example count"
|
30
|
+
unless example_count == expected_example_count
|
31
|
+
fail "`#{command}` had an incorrect example count, " \
|
32
|
+
"expected #{expected_example_count}, " \
|
33
|
+
"but got #{example_count}"
|
23
34
|
end
|
24
35
|
end
|
25
36
|
|
data/generative.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = 'generative'
|
7
|
-
gem.version = '0.2.0.
|
7
|
+
gem.version = '0.2.0.pre3'
|
8
8
|
gem.authors = ["Justin Campbell", "Dan McClory"]
|
9
9
|
gem.email = ["justin@justincampbell.me", "danmcclory@gmail.com"]
|
10
10
|
gem.description = "Generative testing for RSpec"
|
@@ -17,14 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
-
|
21
|
-
when '2'
|
22
|
-
gem.add_dependency 'rspec', '~> 2.0'
|
23
|
-
when '3'
|
24
|
-
gem.add_dependency 'rspec', '3.0.0.beta1'
|
25
|
-
else
|
26
|
-
gem.add_dependency 'rspec'
|
27
|
-
end
|
20
|
+
gem.add_dependency 'rspec', '>= 3.0'
|
28
21
|
|
29
22
|
gem.add_development_dependency 'rake'
|
30
23
|
end
|
data/lib/generative/dsl.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
class RSpec::Core::ExampleGroup
|
2
|
-
def self.generative(name = nil, &block)
|
3
|
-
name = "(#{name})" if name
|
4
|
-
name = "\033[36mgenerative#{name}\033[0m"
|
5
2
|
|
6
|
-
|
7
|
-
end
|
3
|
+
define_example_group_method :generative, { generative: true, order: :generative}
|
8
4
|
|
9
5
|
class << self
|
10
6
|
alias_method :data, :let
|
@@ -1,13 +1,16 @@
|
|
1
1
|
require 'rspec/core/formatters/progress_formatter'
|
2
|
+
require 'rspec/core/formatters/console_codes'
|
2
3
|
|
3
4
|
class RSpec::Core::Formatters::ProgressFormatter
|
4
|
-
|
5
|
-
|
5
|
+
alias_method :super_example_passed, :example_passed
|
6
|
+
|
7
|
+
def example_passed(notification)
|
8
|
+
example = notification.example
|
6
9
|
|
7
10
|
if example.metadata[:generative]
|
8
|
-
output.print
|
11
|
+
output.print RSpec::Core::Formatters::ConsoleCodes.wrap('.', :cyan)
|
9
12
|
else
|
10
|
-
|
13
|
+
super_example_passed(notification)
|
11
14
|
end
|
12
15
|
end
|
13
16
|
end
|
@@ -16,11 +19,19 @@ require 'rspec/core/formatters/documentation_formatter'
|
|
16
19
|
|
17
20
|
module Generative
|
18
21
|
class Formatter < RSpec::Core::Formatters::DocumentationFormatter
|
22
|
+
RSpec::Core::Formatters.register self,
|
23
|
+
:example_failed,
|
24
|
+
:example_group_started,
|
25
|
+
:example_passed,
|
26
|
+
:example_pending
|
27
|
+
|
19
28
|
def initialize(output)
|
20
|
-
super
|
29
|
+
super
|
21
30
|
end
|
22
31
|
|
23
|
-
def example_group_started(
|
32
|
+
def example_group_started(notification)
|
33
|
+
example_group = notification.group
|
34
|
+
|
24
35
|
@example_group = example_group
|
25
36
|
|
26
37
|
output.puts if @group_level == 0
|
@@ -41,28 +52,38 @@ module Generative
|
|
41
52
|
@group_level += 1
|
42
53
|
end
|
43
54
|
|
44
|
-
def example_passed(
|
55
|
+
def example_passed(notification)
|
56
|
+
example = notification.example
|
57
|
+
|
45
58
|
return if generative?(example)
|
46
59
|
|
47
|
-
super
|
60
|
+
super
|
48
61
|
end
|
49
62
|
|
50
|
-
def example_pending(
|
63
|
+
def example_pending(notification)
|
64
|
+
example = notification.example
|
65
|
+
|
51
66
|
return if generative?(example)
|
52
67
|
|
53
|
-
super
|
68
|
+
super
|
54
69
|
end
|
55
70
|
|
56
|
-
def example_failed(
|
71
|
+
def example_failed(notification)
|
72
|
+
example = notification.example
|
73
|
+
|
57
74
|
if generative?(example)
|
58
75
|
RSpec.wants_to_quit = true
|
59
76
|
end
|
60
77
|
|
61
|
-
super
|
78
|
+
super
|
62
79
|
end
|
63
80
|
|
64
81
|
private
|
65
82
|
|
83
|
+
def detail_color(text)
|
84
|
+
RSpec::Core::Formatters::ConsoleCodes.wrap(text, :cyan)
|
85
|
+
end
|
86
|
+
|
66
87
|
def generative?(example)
|
67
88
|
example.metadata[:generative]
|
68
89
|
end
|
data/lib/generative/ordering.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
Generative::ORDERING = ->(examples) {
|
2
|
+
generative, regular = examples.partition { |example|
|
3
|
+
example.metadata[:generative]
|
4
|
+
}
|
5
|
+
|
2
6
|
number_of_examples = ENV.fetch('GENERATIVE_COUNT', '1').to_i
|
3
|
-
|
7
|
+
|
8
|
+
regular + generative * number_of_examples
|
4
9
|
}
|
5
10
|
|
6
11
|
RSpec.configure do |rspec|
|
7
|
-
|
8
|
-
when /^2/
|
9
|
-
rspec.order_examples(&Generative::ORDERING) if ENV['GENERATIVE_COUNT']
|
10
|
-
when /^3/
|
11
|
-
rspec.register_ordering(:generative, &Generative::ORDERING)
|
12
|
-
else
|
13
|
-
puts "Generative was unable to determine the RSpec version."
|
14
|
-
end
|
12
|
+
rspec.register_ordering(:generative, &Generative::ORDERING)
|
15
13
|
end
|
data/lib/generative/rake_task.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Generative::ORDERING do
|
4
|
+
let(:ordering) { Generative::ORDERING }
|
5
|
+
|
6
|
+
around do |example|
|
7
|
+
previous = ENV['GENERATIVE_COUNT']
|
8
|
+
ENV['GENERATIVE_COUNT'] = '10'
|
9
|
+
|
10
|
+
example.call
|
11
|
+
|
12
|
+
ENV['GENERATIVE_COUNT'] = previous
|
13
|
+
end
|
14
|
+
|
15
|
+
it "does not duplicate regular specs" do
|
16
|
+
spec = double(metadata: {})
|
17
|
+
expect(ordering.call([spec])).to eq([spec])
|
18
|
+
end
|
19
|
+
|
20
|
+
it "duplicates generative specs" do
|
21
|
+
spec = double(metadata: { generative: true })
|
22
|
+
expect(ordering.call([spec]).count).to eq(10)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'generative/rake_task'
|
3
|
+
|
4
|
+
describe Generative::RakeTask do
|
5
|
+
let(:task) { Generative::RakeTask.new(*args) }
|
6
|
+
let(:args) { [] }
|
7
|
+
|
8
|
+
describe "name" do
|
9
|
+
subject(:name) { task.name }
|
10
|
+
|
11
|
+
it "has a default" do
|
12
|
+
expect(name).to eq(:generative)
|
13
|
+
end
|
14
|
+
|
15
|
+
context "when passed a name" do
|
16
|
+
let(:args) { [:properties] }
|
17
|
+
|
18
|
+
it "uses that name" do
|
19
|
+
expect(name).to eq(:properties)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "rspec_opts" do
|
25
|
+
subject(:rspec_opts) { task.rspec_opts }
|
26
|
+
|
27
|
+
it "require generative" do
|
28
|
+
expect(rspec_opts).to include("--require generative")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "format with Generative::Formatter" do
|
32
|
+
expect(rspec_opts).to include("--format Generative::Formatter")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "only run specs tagged with generative" do
|
36
|
+
expect(rspec_opts).to include("--format Generative::Formatter")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: generative
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0.
|
4
|
+
version: 0.2.0.pre3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Campbell
|
@@ -9,34 +9,34 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-08-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - '>='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '0'
|
20
|
+
version: '3.0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - '>='
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '0'
|
27
|
+
version: '3.0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - '>='
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - '>='
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
description: Generative testing for RSpec
|
@@ -48,9 +48,9 @@ executables:
|
|
48
48
|
extensions: []
|
49
49
|
extra_rdoc_files: []
|
50
50
|
files:
|
51
|
-
-
|
52
|
-
-
|
53
|
-
-
|
51
|
+
- .gitignore
|
52
|
+
- .rspec
|
53
|
+
- .travis.yml
|
54
54
|
- CHANGELOG.md
|
55
55
|
- Gemfile
|
56
56
|
- LICENSE.txt
|
@@ -64,6 +64,8 @@ files:
|
|
64
64
|
- lib/generative/ordering.rb
|
65
65
|
- lib/generative/rake_task.rb
|
66
66
|
- lib/generative/version.rb
|
67
|
+
- spec/generative/ordering_spec.rb
|
68
|
+
- spec/generative/rake_task_spec.rb
|
67
69
|
- spec/generative_spec.rb
|
68
70
|
- spec/spec_helper.rb
|
69
71
|
homepage: https://github.com/justincampbell/generative
|
@@ -76,20 +78,23 @@ require_paths:
|
|
76
78
|
- lib
|
77
79
|
required_ruby_version: !ruby/object:Gem::Requirement
|
78
80
|
requirements:
|
79
|
-
- -
|
81
|
+
- - '>='
|
80
82
|
- !ruby/object:Gem::Version
|
81
83
|
version: '0'
|
82
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
85
|
requirements:
|
84
|
-
- -
|
86
|
+
- - '>'
|
85
87
|
- !ruby/object:Gem::Version
|
86
88
|
version: 1.3.1
|
87
89
|
requirements: []
|
88
90
|
rubyforge_project:
|
89
|
-
rubygems_version: 2.
|
91
|
+
rubygems_version: 2.0.14
|
90
92
|
signing_key:
|
91
93
|
specification_version: 4
|
92
94
|
summary: Generative testing for RSpec
|
93
95
|
test_files:
|
96
|
+
- spec/generative/ordering_spec.rb
|
97
|
+
- spec/generative/rake_task_spec.rb
|
94
98
|
- spec/generative_spec.rb
|
95
99
|
- spec/spec_helper.rb
|
100
|
+
has_rdoc:
|