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 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, write more test
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 types file1 file2 / directoris"
8
+ opts.banner = "Usage: tm -t tag1,tag2 spec_file"
9
9
 
10
- opts.on( '-t', '--type types', 'types' ) do |types|
11
- TM::Configuration.types = types.split(',').map(&:to_s)
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
@@ -1,4 +1,4 @@
1
- types:
1
+ tags:
2
2
  all:
3
3
  capybara:
4
4
  asset_root: 'tmp'
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.should_run_type?(types)
15
- return true if TM::Configuration.types.nil?
16
- return false if types.nil?
17
- types = types.to_a.map(&:to_s)
18
- (types - TM::Configuration.types) != types
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.should_run_type?(opts[:type])
28
- TM::Configuration.load_setting_for_types(opts[:type])
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
- data_table = TM::Table[test_file, desc]
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.should_run_type?(opts[:type])
64
+ return unless TM.should_run?(opts[:tag])
51
65
 
52
66
  before type do
53
67
  self.instance_exec(&block)
@@ -3,7 +3,7 @@ require 'yaml'
3
3
  module TM
4
4
  class Configuration
5
5
  class << self
6
- attr_accessor :types, :root
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 load_setting_for_types(types=[])
26
- types = types.to_a.unshift(:all)
27
- types.map do |type|
28
- config = self.config['types'] && self.config['types'][type.to_s]
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: 9
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 9
10
- version: 0.1.9
9
+ - 10
10
+ version: 0.1.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jinzhu