generative 0.1.0 → 0.2.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +39 -17
- data/Rakefile +21 -7
- data/bin/generative +19 -0
- data/generative.gemspec +2 -1
- data/lib/generative.rb +8 -0
- data/lib/generative/formatters.rb +36 -34
- data/lib/generative/rake_task.rb +28 -0
- data/spec/generative_spec.rb +1 -1
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91579b9cbddd9ab1a63136fd9466b779dce20ce5
|
4
|
+
data.tar.gz: 35947c6dd629fe09df3c2d5d08ce2ad84bedfb3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b3e014eb4add9e5e87b633720418f1926646d4c8cd4447cc5042a0904465eb93deb19dd4b878b736920a09836cd64c97857cb2b25f71efe97e965bba78ded11
|
7
|
+
data.tar.gz: 9763f83d3d197452d419a4ad20de6a5c816fa1dc12b398c4ee07dd85e049cea097e9d4ea46b50f23de91d634ce09369cd37a60f595acd71b9bc0cab23272b80f
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -26,30 +26,27 @@ end
|
|
26
26
|
--require generative
|
27
27
|
```
|
28
28
|
|
29
|
-
###
|
29
|
+
### (Optional) Require the Generative Rake task in your `Rakefile`:
|
30
30
|
|
31
31
|
```rb
|
32
|
-
require 'bundler/gem_tasks'
|
33
32
|
require 'rspec/core/rake_task'
|
33
|
+
require 'generative/rake_task'
|
34
34
|
|
35
|
-
task
|
36
|
-
|
37
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
38
|
-
t.rspec_opts = '--format documentation --tag ~generative --order random'
|
39
|
-
end
|
40
|
-
|
41
|
-
RSpec::Core::RakeTask.new(:generative) do |t|
|
42
|
-
ENV['GENERATIVE_COUNT'] = '10_000'
|
43
|
-
t.rspec_opts = '--format Generative --tag generative'
|
44
|
-
end
|
35
|
+
task(:default).enhance [:spec, :generative]
|
45
36
|
```
|
46
37
|
|
47
38
|
### Remove any random/other ordering
|
48
39
|
|
49
40
|
If using RSpec 2, you'll need to make sure you remove `config.order =
|
50
|
-
'random'`, or any other ordering strategies, from your spec helper.
|
41
|
+
'random'`, or any other ordering strategies, from your spec helper. You can
|
42
|
+
also use `Generative.running?` to only disable random ordering during
|
43
|
+
Generative runs:
|
44
|
+
|
45
|
+
```rb
|
46
|
+
config.order = :random unless Generative.running?
|
47
|
+
```
|
51
48
|
|
52
|
-
In RSpec 3, this is not
|
49
|
+
In RSpec 3, this is not necessary, because each example group (the `generative`
|
53
50
|
block) can override ordering for that group.
|
54
51
|
|
55
52
|
## Usage
|
@@ -85,13 +82,38 @@ describe String do
|
|
85
82
|
end
|
86
83
|
```
|
87
84
|
|
88
|
-
|
85
|
+
### Running
|
86
|
+
|
87
|
+
Generative comes with a `generative` command, which simply runs rspec with the
|
88
|
+
required arguments:
|
89
|
+
|
90
|
+
```
|
91
|
+
$ generative
|
92
|
+
+ GENERATIVE_COUNT=10_000
|
93
|
+
+ rspec --require generative --format Generative --tag generative
|
94
|
+
Run options: include {:generative=>true}
|
95
|
+
|
96
|
+
String
|
97
|
+
#length
|
98
|
+
generative
|
99
|
+
is never negative
|
100
|
+
#reverse
|
101
|
+
generative
|
102
|
+
maintains length
|
103
|
+
is not destructive
|
104
|
+
|
105
|
+
Finished in 2.28 seconds
|
106
|
+
30000 examples, 0 failures
|
107
|
+
```
|
108
|
+
|
109
|
+
If you've added the Generative task to your `Rakefile`, you can also simply run
|
110
|
+
`rake ` to run all tests, including Generative ones.
|
89
111
|
|
90
112
|
### Number of Tests
|
91
113
|
|
92
114
|
Generative uses the `GENERATIVE_COUNT` environment variable to control how many
|
93
|
-
tests to run for each example.
|
94
|
-
`Rakefile` above
|
115
|
+
tests to run for each example. Both the `generative` command and the example
|
116
|
+
`Rakefile` above set it to 10,000.
|
95
117
|
|
96
118
|
### Formatters
|
97
119
|
|
data/Rakefile
CHANGED
@@ -1,13 +1,27 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'rspec/core/rake_task'
|
3
|
+
require 'generative/rake_task'
|
3
4
|
|
4
|
-
task default: [:spec, :generative]
|
5
|
+
task default: [:spec, :generative, :acceptance]
|
6
|
+
task ci: [:spec, :generative]
|
5
7
|
|
6
|
-
RSpec::Core::RakeTask.new(:spec)
|
7
|
-
|
8
|
-
|
8
|
+
RSpec::Core::RakeTask.new(:spec)
|
9
|
+
Generative::RakeTask.new(:generative)
|
10
|
+
|
11
|
+
desc "Verify all spec commands behave properly"
|
12
|
+
task :acceptance do
|
13
|
+
[
|
14
|
+
['rspec', '6'],
|
15
|
+
['rake spec', '6'],
|
16
|
+
['rake generative', '30000'],
|
17
|
+
['bin/generative', '30000']
|
18
|
+
].each do |command, example_count|
|
19
|
+
result = system %{#{command} | grep "#{example_count} examples, 0 failures"}
|
20
|
+
|
21
|
+
unless result
|
22
|
+
fail "`#{command}` had an incorrect example count"
|
23
|
+
end
|
24
|
+
end
|
9
25
|
|
10
|
-
|
11
|
-
ENV['GENERATIVE_COUNT'] ||= '10_000'
|
12
|
-
t.rspec_opts = '--format Generative --tag generative'
|
26
|
+
puts "Yay!"
|
13
27
|
end
|
data/bin/generative
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$: << File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
|
4
|
+
|
5
|
+
require 'generative'
|
6
|
+
|
7
|
+
ENV['GENERATIVE_COUNT'] ||= '10_000'
|
8
|
+
|
9
|
+
command = %w[
|
10
|
+
rspec
|
11
|
+
--require generative
|
12
|
+
--format Generative::Formatter
|
13
|
+
--tag generative
|
14
|
+
].join(' ')
|
15
|
+
|
16
|
+
command = "GENERATIVE_COUNT=#{ENV['GENERATIVE_COUNT']} #{command}"
|
17
|
+
|
18
|
+
puts command
|
19
|
+
system command
|
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.
|
7
|
+
gem.version = '0.2.0.pre1'
|
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"
|
@@ -13,6 +13,7 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.license = 'MIT'
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |file| File.basename file }
|
16
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
18
|
gem.require_paths = ["lib"]
|
18
19
|
|
data/lib/generative.rb
CHANGED
@@ -14,55 +14,57 @@ end
|
|
14
14
|
|
15
15
|
require 'rspec/core/formatters/documentation_formatter'
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
module Generative
|
18
|
+
class Formatter < RSpec::Core::Formatters::DocumentationFormatter
|
19
|
+
def initialize(output)
|
20
|
+
super(output)
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
def example_group_started(example_group)
|
24
|
+
@example_group = example_group
|
24
25
|
|
25
|
-
|
26
|
+
output.puts if @group_level == 0
|
26
27
|
|
27
|
-
|
28
|
-
|
28
|
+
if generative?(example_group)
|
29
|
+
output.puts "#{current_indentation}#{detail_color('generative')}"
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
@group_level += 1
|
32
|
+
example_group.examples.each do |example|
|
33
|
+
output.puts "#{current_indentation}#{detail_color(example.description)}"
|
34
|
+
end
|
35
|
+
|
36
|
+
@group_level -= 1
|
37
|
+
else
|
38
|
+
output.puts "#{current_indentation}#{example_group.description.strip}"
|
33
39
|
end
|
34
40
|
|
35
|
-
@group_level
|
36
|
-
else
|
37
|
-
output.puts "#{current_indentation}#{example_group.description.strip}"
|
41
|
+
@group_level += 1
|
38
42
|
end
|
39
43
|
|
40
|
-
|
41
|
-
|
44
|
+
def example_passed(example)
|
45
|
+
return if generative?(example)
|
42
46
|
|
43
|
-
|
44
|
-
|
47
|
+
super(example)
|
48
|
+
end
|
45
49
|
|
46
|
-
|
47
|
-
|
50
|
+
def example_pending(example)
|
51
|
+
return if generative?(example)
|
48
52
|
|
49
|
-
|
50
|
-
|
53
|
+
super(example)
|
54
|
+
end
|
51
55
|
|
52
|
-
|
53
|
-
|
56
|
+
def example_failed(example)
|
57
|
+
if generative?(example)
|
58
|
+
RSpec.wants_to_quit = true
|
59
|
+
end
|
54
60
|
|
55
|
-
|
56
|
-
if generative?(example)
|
57
|
-
RSpec.wants_to_quit = true
|
61
|
+
super(example)
|
58
62
|
end
|
59
63
|
|
60
|
-
|
61
|
-
end
|
64
|
+
private
|
62
65
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
example.metadata[:generative]
|
66
|
+
def generative?(example)
|
67
|
+
example.metadata[:generative]
|
68
|
+
end
|
67
69
|
end
|
68
70
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'generative'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
module Generative
|
5
|
+
class RakeTask < RSpec::Core::RakeTask
|
6
|
+
def initialize(*args, &task_block)
|
7
|
+
setup_ivars(args)
|
8
|
+
|
9
|
+
desc "Run Generative specs" unless Rake.application.last_comment
|
10
|
+
|
11
|
+
options = %w[
|
12
|
+
--require generative
|
13
|
+
--format Generative::Formatter
|
14
|
+
--tag generative
|
15
|
+
]
|
16
|
+
|
17
|
+
self.rspec_opts = options.join(' ')
|
18
|
+
|
19
|
+
task name, *args do |_, task_args|
|
20
|
+
RakeFileUtils.send(:verbose, verbose) do
|
21
|
+
ENV['GENERATIVE_COUNT'] ||= Generative::DEFAULT_COUNT
|
22
|
+
task_block.call(*[self, task_args].slice(0, task_block.arity)) if task_block
|
23
|
+
run_task verbose
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/spec/generative_spec.rb
CHANGED
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.
|
4
|
+
version: 0.2.0.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Campbell
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -43,7 +43,8 @@ description: Generative testing for RSpec
|
|
43
43
|
email:
|
44
44
|
- justin@justincampbell.me
|
45
45
|
- danmcclory@gmail.com
|
46
|
-
executables:
|
46
|
+
executables:
|
47
|
+
- generative
|
47
48
|
extensions: []
|
48
49
|
extra_rdoc_files: []
|
49
50
|
files:
|
@@ -55,11 +56,13 @@ files:
|
|
55
56
|
- LICENSE.txt
|
56
57
|
- README.md
|
57
58
|
- Rakefile
|
59
|
+
- bin/generative
|
58
60
|
- generative.gemspec
|
59
61
|
- lib/generative.rb
|
60
62
|
- lib/generative/dsl.rb
|
61
63
|
- lib/generative/formatters.rb
|
62
64
|
- lib/generative/ordering.rb
|
65
|
+
- lib/generative/rake_task.rb
|
63
66
|
- lib/generative/version.rb
|
64
67
|
- spec/generative_spec.rb
|
65
68
|
- spec/spec_helper.rb
|
@@ -78,9 +81,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
81
|
version: '0'
|
79
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
83
|
requirements:
|
81
|
-
- - "
|
84
|
+
- - ">"
|
82
85
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
86
|
+
version: 1.3.1
|
84
87
|
requirements: []
|
85
88
|
rubyforge_project:
|
86
89
|
rubygems_version: 2.2.0
|