moto 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90fe2561282622f310e6d74d3061dd718e9b3477
4
- data.tar.gz: 75c338461cbd7f97af43f09fe6e3bf455bd0b246
3
+ metadata.gz: 2e56d7e5033affe7722147e62069dce0abb867a0
4
+ data.tar.gz: 1b24b5d96561c51bc981df29d20956d942440e9d
5
5
  SHA512:
6
- metadata.gz: a798e654af8a5243ff1f9b465f7cfc5ad82357323d72a3973fa4d1d36e306facb90289f20150a446c39a268af6fc45d7ef849baf1454ae4e14047357966003cf
7
- data.tar.gz: b955b5b207d99921e73764adda6499c28559372c63f84a46dac095d7a36b39cafa71d967078d2afc5da474d13b450672169f28005cca5e07773d5e0c9632293f
6
+ metadata.gz: 94fd8eed59186ccd6699b9d76319a01695745a97dc3c6c0cc9127abea6fc0126c5ef2b44c75a6e6dde71e9a11ebef0180c6580b5fdd1be2dc86219e0db84adef
7
+ data.tar.gz: fdcc3abc7f4ffecfc93f9c50a4d0974bd84e967f7664fc1235d160741da4cf0b74534a351df02f4b60c175e35723aff61749bebb0f77cbfb7f55535167139c3e
data/lib/cli.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # TODO: fix this dumb verification of current working directory
2
2
  unless File.exists? "#{Dir.pwd}/config/moto.rb"
3
- puts "Config file (config/moto.rb) not present."
4
- puts "Does current working directory contain Moto application?"
3
+ puts 'Config file (config/moto.rb) not present.'
4
+ puts 'Does current working directory contain Moto application?'
5
5
  exit 1
6
6
  end
7
7
 
@@ -46,23 +46,56 @@ require_relative './exceptions/test_forced_passed'
46
46
  module Moto
47
47
 
48
48
  class Cli
49
-
50
49
  def self.run(argv)
51
- tests = []
52
- argv[ :tests ].each do |test_name|
53
- test_class_name = test_name
54
-
55
- tg = TestGenerator.new(MotoApp::DIR)
56
- t = tg.generate(test_class_name)
57
- tests << t
50
+ test_paths_absolute = []
51
+ test_classes = []
52
+
53
+ unless argv[ :tests ].nil?
54
+ argv[ :tests ].each do |dir_name|
55
+ test_paths = Dir.glob("#{MotoApp::DIR}/tests/#{dir_name}/**/*.rb")
56
+ test_paths -= test_paths_absolute
57
+ test_paths_absolute += test_paths
58
+ end
58
59
  end
59
-
60
+
61
+ # TODO Optimization for files without #MOTO_TAGS
62
+ unless argv[ :tags ].nil?
63
+ tests_total = Dir.glob("#{MotoApp::DIR}/tests/**/*.rb")
64
+ argv[ :tags ].each do |tag_name|
65
+ tests_total.each do |test_dir|
66
+ test_body = File.read (test_dir)
67
+ test_body.each_line do |line|
68
+ line = line.delete(' ')
69
+ if line.include?( '#MOTO_TAGS')
70
+ if line.include? (tag_name + ',')
71
+ test_paths_absolute.include?(test_dir) || test_paths_absolute << test_dir
72
+ break
73
+ else
74
+ break
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+ #TODO Display criteria used
83
+ if test_paths_absolute.empty?
84
+ puts 'No tests found for given arguments'
85
+ exit 1
86
+ end
87
+
88
+ tg = TestGenerator.new(MotoApp::DIR)
89
+ test_paths_absolute.each do |test_path|
90
+ test_classes << tg.generate(test_path)
91
+ end
92
+
60
93
  listeners = []
61
94
  argv[ :reporters ].each do |r|
62
95
  listeners << r.constantize
63
96
  end
64
97
 
65
- runner = Moto::Runner.new(tests, listeners, argv[ :environments ], argv[ :config ])
98
+ runner = Moto::Runner.new(test_classes, listeners, argv[ :environments ], argv[ :config ])
66
99
  runner.run
67
100
  end
68
101
 
@@ -1,47 +1,47 @@
1
- require 'capybara'
2
-
3
- module Moto
4
- module Clients
5
-
6
- class Website < Moto::Clients::Base
7
-
8
- attr_reader :session
9
-
10
- ignore_logging(:page)
11
- ignore_logging(:context)
12
- ignore_logging(:session)
13
-
14
- def start_run
15
- # TODO: make session driver configurable
16
- @session = Capybara::Session.new(context.runner.my_config[:capybara][:default_driver])
17
- @pages = {}
18
- end
19
-
20
- def end_run
21
- @session.driver.browser.close # TODO: check that it really works
22
- end
23
-
24
- def start_test(test)
25
- # @context.current_test.logger.info("Hi mom, I'm opening some pages!")
26
- @session.reset_session!
27
- end
28
-
29
- def end_test(test)
30
- @session.reset_session!
31
- end
32
-
33
- def page(p)
34
- page_class_name = "#{self.class.name}Pages::#{p}"
35
- page_class_name.gsub!('Moto::', 'MotoApp::')
36
- if @pages[page_class_name].nil?
37
- a = page_class_name.underscore.split('/')
38
- page_path = a[1..20].join('/')
39
- require "#{MotoApp::DIR}/lib/#{page_path}"
40
- @pages[page_class_name] = page_class_name.constantize.new(self)
41
- end
42
- @pages[page_class_name]
43
- end
44
-
45
- end
46
- end
47
- end
1
+ require 'capybara'
2
+
3
+ module Moto
4
+ module Clients
5
+
6
+ class Website < Moto::Clients::Base
7
+
8
+ attr_reader :session
9
+
10
+ ignore_logging(:page)
11
+ ignore_logging(:context)
12
+ ignore_logging(:session)
13
+
14
+ def start_run
15
+ # TODO: make session driver configurable
16
+ @session = Capybara::Session.new(context.runner.my_config[:capybara][:default_driver])
17
+ @pages = {}
18
+ end
19
+
20
+ def end_run
21
+ @session.driver.browser.close # TODO: check that it really works
22
+ end
23
+
24
+ def start_test(test)
25
+ # @context.current_test.logger.info("Hi mom, I'm opening some pages!")
26
+ @session.reset_session!
27
+ end
28
+
29
+ def end_test(test)
30
+ @session.reset_session!
31
+ end
32
+
33
+ def page(p)
34
+ page_class_name = "#{self.class.name}Pages::#{p}"
35
+ page_class_name.gsub!('Moto::', 'MotoApp::')
36
+ if @pages[page_class_name].nil?
37
+ a = page_class_name.underscore.split('/')
38
+ page_path = a[1..20].join('/')
39
+ require "#{MotoApp::DIR}/lib/#{page_path}"
40
+ @pages[page_class_name] = page_class_name.constantize.new(self)
41
+ end
42
+ @pages[page_class_name]
43
+ end
44
+
45
+ end
46
+ end
47
+ end
data/lib/parser.rb CHANGED
@@ -12,17 +12,18 @@ module Moto
12
12
 
13
13
  # TODO Generate app / Change the way parsing options goes so it doesnt generate them if they`re not needed
14
14
  case argv[0]
15
- when 'run' then Moto::Cli.run run_parse(argv)
16
- when 'help' then show_help
17
- when 'generate' then Moto::AppGenerator.run generate_parse(argv)
15
+ when 'run' then Moto::Cli.run run_parse(argv)
16
+ when 'help' then show_help
17
+ when 'generate' then Moto::AppGenerator.run generate_parse(argv)
18
+ else puts "Command '#{argv[0]}' not recognized. Type help for list of supported commands."
18
19
  end
19
20
  end
20
21
 
21
- def self.run_parse(argv)
22
- # puts Moto::DIR
23
- # Default options
22
+ def self.run_parse(argv)
23
+ # Default options
24
24
  options = {}
25
- options[:reporters] = []
25
+ options[:reporters] = []
26
+ # TODO Mandatory env var in app config
26
27
  options[:config] = eval(File.read("#{MotoApp::DIR}/config/moto.rb"))
27
28
  options[:environments] = []
28
29
 
@@ -31,12 +32,19 @@ module Moto
31
32
  # TODO const
32
33
  # TODO reporters should be consts - not strings
33
34
  OptionParser.new do |opts|
34
- opts.on('-t', "--tests Tests", Array) { |v| options[:tests ] = v }
35
+ opts.on('-t', '--tests Tests', Array) { |v| options[:tests ] = v }
36
+ opts.on('-g', '--tags Tags', Array) { |v| options[:tags ] = v }
35
37
  opts.on('-r', '--reporters Reporters', Array) { |v| options[:reporters] = v }
36
38
  opts.on('-e', '--environments Environment', Array) { |v| options[:environments] = v }
37
39
  opts.on('-c', '--const Const') { |v| options[:const] = v }
38
40
  opts.on('-cfg', '--config Config') { |v| options[:config] = options[:config].merge( eval( v ) ) }
39
41
  end.parse!
42
+
43
+ if options[ :config ][ :moto ][ :runner ][ :mandatory_environment ] && options[ :environments ].empty?
44
+ puts 'Environment is mandatory for this project.'
45
+ exit 1
46
+ end
47
+
40
48
  return options
41
49
  end
42
50
 
@@ -35,13 +35,8 @@ module Moto
35
35
  end
36
36
 
37
37
  # assuming that target file includes only content of method 'run' and some magic comments
38
- def generate(class_name)
39
- full_class_name = 'MotoApp::Tests::'+class_name
40
- a = full_class_name.underscore.split('/')
41
- test_path = (a[1..20]+[a[-1]]).join('/')
42
- test_path = "#{MotoApp::DIR}/#{test_path}.rb"
43
-
44
- method_body = File.read(test_path) + "\n"
38
+ def generate(test_path_absolute)
39
+ method_body = File.read(test_path_absolute) + "\n"
45
40
 
46
41
  base = Moto::Test
47
42
  base_class_string = method_body.match( /^#\s*BASE_CLASS:\s(\S+)/ )
@@ -49,24 +44,24 @@ module Moto
49
44
  base_class_string = base_class_string[1].strip
50
45
 
51
46
  a = base_class_string.underscore.split('/')
52
- base_test_path = a[1..20].join('/')
47
+ base_test_path = a[1..-1].join('/')
53
48
 
54
49
  require "#{MotoApp::DIR}/lib/#{base_test_path}"
55
50
  base = base_class_string.constantize
56
51
  end
57
52
 
58
53
  # MotoApp::Tests::Login::Short
59
- consts = full_class_name.split('::')
54
+ consts = test_path_absolute.camelize.split('Tests::')[1].split('::')
55
+ consts.pop
60
56
  class_name = consts.pop
61
57
 
62
- consts.shift 2 # remove Moto::Test as already defined
63
58
  m = create_module_tree(MotoApp::Tests, consts)
64
59
  cls = Class.new(base)
65
60
  m.const_set(class_name.to_sym, cls)
66
61
 
67
62
  test_object = cls.new
68
63
  test_object.instance_eval( "def run\n #{method_body} \n end" )
69
- test_object.static_path = test_path
64
+ test_object.static_path = test_path_absolute
70
65
  test_object
71
66
  end
72
67
 
@@ -14,8 +14,10 @@ module Moto
14
14
  @tests.each do |t|
15
15
  t.context = self
16
16
  end
17
- # TODO: add all *.yml files from that dir
18
- @config = YAML.load_file("#{MotoApp::DIR}/config/const.yml")
17
+ @config = {}
18
+ Dir.glob("config/*.yml").each do |f|
19
+ @config.merge! YAML.load_file(f)
20
+ end
19
21
  end
20
22
 
21
23
  def client(name)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartek Wilczek
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-15 00:00:00.000000000 Z
12
+ date: 2015-10-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  version: '0'
97
97
  requirements: []
98
98
  rubyforge_project:
99
- rubygems_version: 2.0.15
99
+ rubygems_version: 2.0.14.1
100
100
  signing_key:
101
101
  specification_version: 4
102
102
  summary: Moto - yet another web testing framework