testingmachine 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- data/TODO +6 -3
- data/bin/tm +11 -3
- data/lib/generators/testing_machine/templates/config.yml +1 -1
- data/lib/tm.rb +23 -9
- data/lib/tm/configuration.rb +5 -5
- metadata +3 -3
data/TODO
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
1, more table parser adapters: excel sql(web interface)
|
2
|
-
2, support multi tables
|
1
|
+
1, more table parser adapters: excel sql(web interface)
|
2
|
+
2, support multi tables???
|
3
3
|
3, rake task
|
4
|
-
4,
|
4
|
+
4, generator without rails
|
5
|
+
5, only run one test case?
|
6
|
+
6, email error message
|
7
|
+
7, parallel, distributed test
|
data/bin/tm
CHANGED
@@ -5,10 +5,18 @@ require File.expand_path('../lib/tm',File.dirname(__FILE__))
|
|
5
5
|
options = {}
|
6
6
|
|
7
7
|
OptionParser.new do |opts|
|
8
|
-
opts.banner = "Usage: tm -t
|
8
|
+
opts.banner = "Usage: tm -t tag1,tag2 spec_file"
|
9
9
|
|
10
|
-
opts.on( '-t', '--
|
11
|
-
TM::Configuration.
|
10
|
+
opts.on( '-t', '--tags tags', 'tags' ) do |tag|
|
11
|
+
TM::Configuration.tags = (TM::Configuration.tags || []).concat tag.split(',')
|
12
|
+
end
|
13
|
+
|
14
|
+
opts.on( '-d', '--data data', 'data' ) do |data|
|
15
|
+
TM::Configuration.data = data
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on( '-n', '--name name', 'only execute the feature elements which match part of the given name.' ) do |name|
|
19
|
+
TM::Configuration.names = (TM::Configuration.names || []).concat name.to_a
|
12
20
|
end
|
13
21
|
|
14
22
|
opts.on( '-h', '--help', 'Display this screen' ) do
|
data/lib/tm.rb
CHANGED
@@ -11,11 +11,21 @@ Capybara.default_driver = :selenium
|
|
11
11
|
MiniTest::Unit.autorun
|
12
12
|
|
13
13
|
module TM
|
14
|
-
def self.
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
def self.should_run?(tags=nil, name=nil)
|
15
|
+
should_run_tags?(tags) && should_run_name?(name)
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
def self.should_run_tags?(tags)
|
20
|
+
return true if TM::Configuration.tags.nil?
|
21
|
+
return false if tags.nil?
|
22
|
+
tags = tags.to_a.map(&:to_s)
|
23
|
+
(tags - TM::Configuration.tags) != tags
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.should_run_name?(name)
|
27
|
+
return true if TM::Configuration.names.nil?
|
28
|
+
TM::Configuration.names.to_a.include?(name)
|
19
29
|
end
|
20
30
|
end
|
21
31
|
|
@@ -24,12 +34,16 @@ class MiniTest::Spec
|
|
24
34
|
|
25
35
|
class << self
|
26
36
|
def scenario desc, opts = {}, &block
|
27
|
-
return unless TM.
|
28
|
-
TM::Configuration.
|
37
|
+
return unless TM.should_run?(opts[:tag], desc)
|
38
|
+
TM::Configuration.load_setting_for_tags(opts[:tag])
|
29
39
|
test_file = File.expand_path(caller[0].sub(/:.*$/,''))
|
30
40
|
|
31
41
|
it desc do
|
32
|
-
|
42
|
+
if TM::Configuration.data
|
43
|
+
data_table = eval("TM::Table[test_file, desc][#{TM::Configuration.data}].to_a")
|
44
|
+
else
|
45
|
+
data_table = TM::Table[test_file, desc]
|
46
|
+
end
|
33
47
|
|
34
48
|
if !data_table.empty?
|
35
49
|
data_table.map do |example|
|
@@ -47,7 +61,7 @@ class MiniTest::Spec
|
|
47
61
|
alias :Scenario :scenario
|
48
62
|
|
49
63
|
def background type = :each, opts = {}, &block
|
50
|
-
return unless TM.
|
64
|
+
return unless TM.should_run?(opts[:tag])
|
51
65
|
|
52
66
|
before type do
|
53
67
|
self.instance_exec(&block)
|
data/lib/tm/configuration.rb
CHANGED
@@ -3,7 +3,7 @@ require 'yaml'
|
|
3
3
|
module TM
|
4
4
|
class Configuration
|
5
5
|
class << self
|
6
|
-
attr_accessor :
|
6
|
+
attr_accessor :tags, :names, :root, :data
|
7
7
|
|
8
8
|
def root
|
9
9
|
test_path = File.expand_path('testingmachine')
|
@@ -22,10 +22,10 @@ module TM
|
|
22
22
|
return {}
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
config = self.config['
|
25
|
+
def load_setting_for_tags(tags=[])
|
26
|
+
tags = tags.to_a.unshift(:all)
|
27
|
+
tags.map do |tag|
|
28
|
+
config = self.config['tags'] && self.config['tags'][tag.to_s]
|
29
29
|
load_config(config)
|
30
30
|
end
|
31
31
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testingmachine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 10
|
10
|
+
version: 0.1.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jinzhu
|