bucky-core 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +66 -0
- data/.codeclimate.yml +48 -0
- data/.dockerignore +11 -0
- data/.gitignore +40 -0
- data/.rspec +3 -0
- data/.rubocop.yml +76 -0
- data/.rubocop_todo.yml +51 -0
- data/Dockerfile +38 -0
- data/Dockerfile.system-test +44 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +115 -0
- data/LICENSE +201 -0
- data/README.md +246 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/bucky-core.gemspec +47 -0
- data/docker-compose.dev-with-bm.yml +28 -0
- data/docker-compose.dev.yml +18 -0
- data/docker-compose.system-test.yml +21 -0
- data/docker/nginx/Dockerfile +7 -0
- data/docker/nginx/nginx.conf +22 -0
- data/docker/nginx/public/index.html +19 -0
- data/docker/nginx/public/test_page.html +12 -0
- data/exe/bucky +214 -0
- data/lib/bucky.rb +3 -0
- data/lib/bucky/core/database/db_connector.rb +29 -0
- data/lib/bucky/core/database/test_data_operator.rb +195 -0
- data/lib/bucky/core/exception/bucky_exception.rb +39 -0
- data/lib/bucky/core/report/screen_shot_generator.rb +24 -0
- data/lib/bucky/core/test_core/test_case_loader.rb +162 -0
- data/lib/bucky/core/test_core/test_class_generator.rb +129 -0
- data/lib/bucky/core/test_core/test_manager.rb +70 -0
- data/lib/bucky/core/test_core/test_result.rb +92 -0
- data/lib/bucky/test_equipment/evidence/evidence_generator.rb +36 -0
- data/lib/bucky/test_equipment/pageobject/base_pageobject.rb +55 -0
- data/lib/bucky/test_equipment/pageobject/pages.rb +61 -0
- data/lib/bucky/test_equipment/selenium_handler/webdriver_handler.rb +66 -0
- data/lib/bucky/test_equipment/test_case/abst_test_case.rb +49 -0
- data/lib/bucky/test_equipment/test_case/e2e_test_case.rb +70 -0
- data/lib/bucky/test_equipment/test_case/linkstatus_test_case.rb +28 -0
- data/lib/bucky/test_equipment/user_operation/user_operation_helper.rb +97 -0
- data/lib/bucky/test_equipment/user_operation/user_operation_logger.rb +15 -0
- data/lib/bucky/test_equipment/user_operation/user_operator.rb +61 -0
- data/lib/bucky/test_equipment/verifications/abst_verification.rb +13 -0
- data/lib/bucky/test_equipment/verifications/e2e_verification.rb +106 -0
- data/lib/bucky/test_equipment/verifications/js_error_checker.rb +23 -0
- data/lib/bucky/test_equipment/verifications/service_verifications.rb +62 -0
- data/lib/bucky/test_equipment/verifications/status_checker.rb +180 -0
- data/lib/bucky/tools/lint.rb +69 -0
- data/lib/bucky/utils/bucky_logger.rb +25 -0
- data/lib/bucky/utils/bucky_output.rb +23 -0
- data/lib/bucky/utils/config.rb +55 -0
- data/lib/bucky/utils/requests.rb +33 -0
- data/lib/bucky/utils/yaml_load.rb +24 -0
- data/lib/bucky/version.rb +7 -0
- data/system_testing/test_bucky_project/.bucky_home +2 -0
- data/system_testing/test_bucky_project/config/bucky_config.yml +6 -0
- data/system_testing/test_bucky_project/config/e2e_config.yml +15 -0
- data/system_testing/test_bucky_project/config/linkstatus_config.yml +3 -0
- data/system_testing/test_bucky_project/config/test_db_config.yml +8 -0
- data/system_testing/test_bucky_project/services/README.md +1 -0
- data/system_testing/test_bucky_project/services/service_a/pc/pageobject/index.rb +13 -0
- data/system_testing/test_bucky_project/services/service_a/pc/parts/index.yml +6 -0
- data/system_testing/test_bucky_project/services/service_a/pc/scenarios/e2e/pc_e2e.yml +68 -0
- data/system_testing/test_bucky_project/services/service_a/pc/scenarios/e2e/setup_each_pc_e2e.yml +20 -0
- data/system_testing/test_bucky_project/services/service_a/pc/scenarios/e2e/setup_teardown_each_pc_e2e.yml +35 -0
- data/system_testing/test_bucky_project/services/service_a/pc/scenarios/e2e/teardown_each_pc_e2e.yml +20 -0
- data/system_testing/test_bucky_project/services/service_a/pc/scenarios/linkstatus/pc_link.yml +10 -0
- data/system_testing/test_bucky_project/services/service_a/sp/pageobject/index.rb +14 -0
- data/system_testing/test_bucky_project/services/service_a/sp/parts/index.yml +6 -0
- data/system_testing/test_bucky_project/services/service_a/sp/scenarios/e2e/sp_e2e_test.yml +26 -0
- data/system_testing/test_bucky_project/services/service_a/sp/scenarios/linkstatus/sp_link.yml +10 -0
- data/system_testing/test_bucky_project/services/service_a/tablet/pageobject/index.rb +14 -0
- data/system_testing/test_bucky_project/services/service_a/tablet/parts/index.yml +6 -0
- data/system_testing/test_bucky_project/services/service_a/tablet/scenarios/e2e/tablet_e2e_test.yml +26 -0
- data/system_testing/test_bucky_project/system/evidences/README.md +1 -0
- data/system_testing/test_bucky_project/system/evidences/screen_shots/README.md +1 -0
- data/system_testing/test_bucky_project/system/logs/README.md +1 -0
- data/system_testing/test_specification.md +38 -0
- data/system_testing/testing_code/command.bats +42 -0
- data/system_testing/testing_code/e2e.bats +75 -0
- data/system_testing/testing_code/linkstatus.bats +24 -0
- data/template/make_page/pc/pageobject/sample_page.rb +23 -0
- data/template/make_page/pc/parts/sample_page.yml +9 -0
- data/template/make_page/sp/pageobject/sample_page.rb +24 -0
- data/template/make_page/sp/parts/sample_page.yml +9 -0
- data/template/make_page/tablet/pageobject/sample_page.rb +24 -0
- data/template/make_page/tablet/parts/sample_page.yml +9 -0
- data/template/new/.bucky_home +2 -0
- data/template/new/config/bucky_config.yml +6 -0
- data/template/new/config/e2e_config.yml +15 -0
- data/template/new/config/linkstatus_config.yml +3 -0
- data/template/new/config/test_db_config.yml +8 -0
- data/template/new/services/README.md +1 -0
- data/template/new/system/evidences/README.md +1 -0
- data/template/new/system/evidences/screen_shots/README.md +1 -0
- data/template/new/system/logs/README.md +1 -0
- metadata +415 -0
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'bucky/core'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start
|
data/bin/setup
ADDED
data/bucky-core.gemspec
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'bucky/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'bucky-core'
|
9
|
+
spec.version = Bucky::Version::VERSION
|
10
|
+
spec.authors = %w[NaotoKishino HikaruFukuzawa SeiyaSato NaokiNakano RikiyaHikimochi JyeRuey]
|
11
|
+
spec.email = ['KishinoNaoto@lifull.com']
|
12
|
+
|
13
|
+
spec.summary = 'A test framework that supports Life Cycle of System Testing.'
|
14
|
+
spec.description = <<-DESCRIPTION
|
15
|
+
Bucky support run in parellel, test results managed in database, and some test categories(E2E, http status check) and so on.
|
16
|
+
DESCRIPTION
|
17
|
+
spec.homepage = 'https://github.com/lifull-dev/bucky-core'
|
18
|
+
spec.license = 'MIT'
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f|
|
21
|
+
f.match(%r{^(test|spec|features)/})
|
22
|
+
}
|
23
|
+
spec.bindir = 'exe'
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ['lib']
|
26
|
+
|
27
|
+
spec.add_development_dependency 'awesome_print', '~> 1.8'
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
29
|
+
spec.add_development_dependency 'hirb', '~> 0.7'
|
30
|
+
spec.add_development_dependency 'pry', '~> 0.10'
|
31
|
+
spec.add_development_dependency 'pry-byebug', '~> 3.4'
|
32
|
+
spec.add_development_dependency 'pry-stack_explorer', '~> 0.4'
|
33
|
+
spec.add_development_dependency 'rake', '~> 12'
|
34
|
+
spec.add_development_dependency 'rspec', '~> 3.6'
|
35
|
+
spec.add_development_dependency 'rspec_junit_formatter', '~> 0.3'
|
36
|
+
spec.add_development_dependency 'rubocop', '~> 0.54'
|
37
|
+
spec.add_development_dependency 'simplecov-console', '~> 0.4.2'
|
38
|
+
|
39
|
+
spec.add_runtime_dependency 'color_echo', '~> 3.1'
|
40
|
+
spec.add_runtime_dependency 'json', '~> 2.1'
|
41
|
+
spec.add_runtime_dependency 'nokogiri', '~> 1.8'
|
42
|
+
spec.add_runtime_dependency 'parallel', '~> 1.11'
|
43
|
+
spec.add_runtime_dependency 'ruby-mysql', '~> 2.9'
|
44
|
+
spec.add_runtime_dependency 'selenium-webdriver', '~> 3.4'
|
45
|
+
spec.add_runtime_dependency 'sequel', '~> 4.48'
|
46
|
+
spec.add_runtime_dependency 'test-unit', '~> 3.2'
|
47
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
version: '3'
|
2
|
+
services:
|
3
|
+
bucky-core:
|
4
|
+
build:
|
5
|
+
context: .
|
6
|
+
dockerfile: Dockerfile
|
7
|
+
container_name: bucky-core
|
8
|
+
volumes:
|
9
|
+
- .:/bucky-core
|
10
|
+
- .sample:/app
|
11
|
+
tty: true
|
12
|
+
environment:
|
13
|
+
- BUCKY_DB_USERNAME=root
|
14
|
+
- BUCKY_DB_PASSWORD=password
|
15
|
+
- BUCKY_DB_HOSTNAME=bm-mysql
|
16
|
+
- BUCKY_DB_NAME=bucky_development
|
17
|
+
networks:
|
18
|
+
- bucky-management_default
|
19
|
+
chrome:
|
20
|
+
image: selenium/standalone-chrome-debug:3.11.0
|
21
|
+
container_name: chrome
|
22
|
+
ports:
|
23
|
+
- '4444:4444'
|
24
|
+
- '5901:5900'
|
25
|
+
shm_size: 1G
|
26
|
+
networks:
|
27
|
+
bucky-management_default:
|
28
|
+
external: true
|
@@ -0,0 +1,18 @@
|
|
1
|
+
version: '3'
|
2
|
+
services:
|
3
|
+
bucky-core:
|
4
|
+
build:
|
5
|
+
context: .
|
6
|
+
dockerfile: Dockerfile
|
7
|
+
container_name: bucky-core
|
8
|
+
volumes:
|
9
|
+
- .:/bucky-core
|
10
|
+
- .sample:/app
|
11
|
+
tty: true
|
12
|
+
chrome:
|
13
|
+
image: selenium/standalone-chrome-debug:3.11.0
|
14
|
+
container_name: chrome
|
15
|
+
ports:
|
16
|
+
- '4444:4444'
|
17
|
+
- '5901:5900'
|
18
|
+
shm_size: 1G
|
@@ -0,0 +1,21 @@
|
|
1
|
+
version: '3'
|
2
|
+
services:
|
3
|
+
bucky-core:
|
4
|
+
container_name: bucky-core
|
5
|
+
build:
|
6
|
+
context: .
|
7
|
+
dockerfile: Dockerfile.system-test
|
8
|
+
volumes:
|
9
|
+
- .:/bucky-core
|
10
|
+
tty: true
|
11
|
+
chrome:
|
12
|
+
container_name: bucky-chrome
|
13
|
+
image: selenium/standalone-chrome-debug:3.11.0
|
14
|
+
ports:
|
15
|
+
- '4444:4444'
|
16
|
+
# For local debug
|
17
|
+
- '5901:5900'
|
18
|
+
web:
|
19
|
+
container_name: bucky.net
|
20
|
+
build:
|
21
|
+
context: docker/nginx
|
@@ -0,0 +1,22 @@
|
|
1
|
+
user nginx;
|
2
|
+
|
3
|
+
events {
|
4
|
+
worker_connections 128;
|
5
|
+
}
|
6
|
+
|
7
|
+
http {
|
8
|
+
access_log /var/log/nginx/access.log;
|
9
|
+
error_log /var/log/nginx/error.log;
|
10
|
+
|
11
|
+
server_tokens off;
|
12
|
+
index index.html;
|
13
|
+
|
14
|
+
server {
|
15
|
+
listen 80;
|
16
|
+
server_name localhost;
|
17
|
+
|
18
|
+
location /{
|
19
|
+
root /app/public;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8">
|
5
|
+
<title>Test Index</title>
|
6
|
+
|
7
|
+
<script type="text/javascript">
|
8
|
+
window.onload = function () {
|
9
|
+
document.getElementById( "user_agent" ).innerHTML = navigator.userAgent;
|
10
|
+
}
|
11
|
+
</script>
|
12
|
+
</head>
|
13
|
+
|
14
|
+
<body>
|
15
|
+
<a id="test_link" href="/test_page.html">Go to test page</a>
|
16
|
+
<div id="user_agent"></div>
|
17
|
+
</body>
|
18
|
+
|
19
|
+
</html>
|
data/exe/bucky
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'optparse'
|
6
|
+
require 'color_echo'
|
7
|
+
require 'fileutils'
|
8
|
+
require_relative '../lib/bucky/version'
|
9
|
+
|
10
|
+
# Color Settings
|
11
|
+
CE.fg(:cyan)
|
12
|
+
|
13
|
+
NEW_COMMAND = %w[new].freeze
|
14
|
+
MAKE_SERVICE_COMMAND = %w[make service].freeze
|
15
|
+
MAKE_PAGE_COMMAND = %w[make page].freeze
|
16
|
+
RUN_COMMAND = %w[run].freeze
|
17
|
+
RERUN_COMMAND = %w[rerun].freeze
|
18
|
+
LINT_COMMAND = %w[lint].freeze
|
19
|
+
|
20
|
+
# ===================================
|
21
|
+
# Parse options =====================
|
22
|
+
# ===================================
|
23
|
+
opts = OptionParser.new
|
24
|
+
opts.banner = 'Bucky: A test framework that supports Life Cycle of System Testing.'
|
25
|
+
opts.define_head 'Usage: bucky [task]'
|
26
|
+
opts.separator ''
|
27
|
+
opts.separator 'Examples:'
|
28
|
+
opts.separator " bucky #{RUN_COMMAND.join(' ')} --test_category e2e --suite_name test_suite --case_name test_case_1"
|
29
|
+
opts.separator " bucky #{RUN_COMMAND.join(' ')} -t e2e -s 1 -c 1"
|
30
|
+
opts.separator " bucky #{RUN_COMMAND.join(' ')} --test_category linkstatus --re_test_count 3"
|
31
|
+
opts.separator " bucky #{RUN_COMMAND.join(' ')} --test_category e2e --suite_name test_suite --case_name test_case_1 --device sp --priority high --re_test_count 3"
|
32
|
+
opts.separator ''
|
33
|
+
opts.separator 'For more information see https://github.com/lifull-dev/bucky-core'
|
34
|
+
opts.separator ''
|
35
|
+
opts.separator 'Options:'
|
36
|
+
|
37
|
+
opts.on_tail('-h', '-?', '--help', 'Show this message') do
|
38
|
+
puts opts
|
39
|
+
exit
|
40
|
+
end
|
41
|
+
|
42
|
+
opts.on_tail('-v', '--version', 'Show version') do
|
43
|
+
puts "BuckyCore: #{Bucky::Version::VERSION}"
|
44
|
+
exit
|
45
|
+
end
|
46
|
+
|
47
|
+
test_cond = {}
|
48
|
+
# Save command and option
|
49
|
+
test_cond[:command_and_option] = 'bucky ' + ARGV.join(' ')
|
50
|
+
opts.on('-t', '--test_category TEST_CATEGORY', 'e.g. --test_category e2e, -t e2e') do |v|
|
51
|
+
test_cond[:test_category] = v
|
52
|
+
end
|
53
|
+
opts.on('-s', '--suite_name SUITE_NAME') do |v|
|
54
|
+
test_cond[:suite_name] = v
|
55
|
+
end
|
56
|
+
# opts.on('-c', '--case_id CASE_ID') do |v|
|
57
|
+
# test_cond[:case_id] = v
|
58
|
+
# end
|
59
|
+
opts.on('-S', '--service SERVICE') do |v|
|
60
|
+
test_cond[:service] = v
|
61
|
+
end
|
62
|
+
opts.on('-D', '--device DEVICE') do |v|
|
63
|
+
test_cond[:device] = v
|
64
|
+
end
|
65
|
+
opts.on('-p', '--priority PRIORITY') do |v|
|
66
|
+
test_cond[:priority] = v
|
67
|
+
end
|
68
|
+
opts.on('-d', 'Not Insert TestReport') do |_|
|
69
|
+
$debug = true
|
70
|
+
end
|
71
|
+
|
72
|
+
# TODO: Add error handling, if the argument of '-r' is not greater than 0
|
73
|
+
opts.on('-r', '--re_test_count RE_TEST_COUNT') do |v|
|
74
|
+
test_cond[:re_test_count] = v
|
75
|
+
end
|
76
|
+
opts.on('-c', '--case CASE_NAME') do |v|
|
77
|
+
test_cond[:case] = v
|
78
|
+
end
|
79
|
+
opts.on('-j', '--job_id JOB_ID') do |v|
|
80
|
+
test_cond[:job] = v
|
81
|
+
end
|
82
|
+
opts.on('-l', '--label LABEL_NAME') do |v|
|
83
|
+
test_cond[:label] = v
|
84
|
+
end
|
85
|
+
opts.on('-m', '--link_check_max_times') do |v|
|
86
|
+
test_cond[:link_check_max_times] = v.to_i
|
87
|
+
end
|
88
|
+
|
89
|
+
lint_cond = {}
|
90
|
+
opts.on('-C', '--category CATEGORY_NAME') do |v|
|
91
|
+
lint_cond[:lint_category] = v
|
92
|
+
end
|
93
|
+
|
94
|
+
opts.parse!
|
95
|
+
|
96
|
+
# ===================================
|
97
|
+
# Select by command =================
|
98
|
+
# ===================================
|
99
|
+
|
100
|
+
# Output error message and exit
|
101
|
+
# @param [String] msg error message
|
102
|
+
def error_and_exit(msg = nil)
|
103
|
+
CE.fg(:yellow)
|
104
|
+
puts 'Invalid command error.'
|
105
|
+
CE.fg(:red)
|
106
|
+
puts " [Error] #{msg}" if msg
|
107
|
+
CE.fg(:yellow)
|
108
|
+
puts " your command : bucky #{ARGV.join(' ')}"
|
109
|
+
puts ' Please input some commands.'
|
110
|
+
puts " e.g. bucky #{NEW_COMMAND.join(' ')}"
|
111
|
+
puts " bucky #{RUN_COMMAND.join(' ')}"
|
112
|
+
puts " bucky #{MAKE_SERVICE_COMMAND.join(' ')}"
|
113
|
+
puts " bucky #{MAKE_PAGE_COMMAND.join(' ')}"
|
114
|
+
puts " bucky #{RERUN_COMMAND.join(' ')}"
|
115
|
+
puts " bucky #{LINT_COMMAND.join(' ')}"
|
116
|
+
exit
|
117
|
+
end
|
118
|
+
|
119
|
+
def bucky_home?
|
120
|
+
File.exist?('.bucky_home')
|
121
|
+
end
|
122
|
+
|
123
|
+
current_dir = Dir.pwd
|
124
|
+
gem_script_dir = __dir__
|
125
|
+
|
126
|
+
if ARGV == RUN_COMMAND
|
127
|
+
error_and_exit('Not bucky project dirctory here.') unless bucky_home?
|
128
|
+
|
129
|
+
$bucky_home_dir = Dir.pwd
|
130
|
+
# Default conditions setting conditions setting
|
131
|
+
test_cond[:test_category] ||= 'e2e'
|
132
|
+
test_cond[:re_test_count] = test_cond[:re_test_count] ? test_cond[:re_test_count].to_i : 1
|
133
|
+
test_cond[:link_check_max_times] ||= 3
|
134
|
+
# Change to array e.g.--suite_id 1,2,3 -> :suite_id=>[1,2,3]
|
135
|
+
test_cond.each { |k, v| test_cond[k] = v.split(',') if v.instance_of?(String) }
|
136
|
+
require_relative '../lib/bucky/core/test_core/test_manager'
|
137
|
+
Bucky::Core::TestCore::TestManager.new(test_cond).run
|
138
|
+
|
139
|
+
elsif ARGV == RERUN_COMMAND
|
140
|
+
$bucky_home_dir = Dir.pwd
|
141
|
+
# Default conditions setting conditions setting
|
142
|
+
test_cond[:test_category] ||= 'e2e'
|
143
|
+
test_cond[:link_check_max_times] ||= 3
|
144
|
+
test_cond[:re_test_count] = test_cond[:re_test_count] ? test_cond[:re_test_count].to_i : 1
|
145
|
+
# Change to array e.g.--suite_id 1,2,3 -> :suite_id=>[1,2,3]
|
146
|
+
test_cond.each { |k, v| test_cond[k] = v.split(',') if v.instance_of?(String) }
|
147
|
+
require_relative '../lib/bucky/core/test_core/test_manager'
|
148
|
+
Bucky::Core::TestCore::TestManager.new(test_cond).rerun
|
149
|
+
|
150
|
+
elsif ARGV == LINT_COMMAND
|
151
|
+
$bucky_home_dir = Dir.pwd
|
152
|
+
# Default conditions setting
|
153
|
+
lint_cond[:lint_category] ||= 'config'
|
154
|
+
require_relative '../lib/bucky/tools/lint'
|
155
|
+
Bucky::Tools::Lint.check(lint_cond[:lint_category])
|
156
|
+
|
157
|
+
elsif ARGV[0..0] == NEW_COMMAND
|
158
|
+
error_and_exit('No test app name.') if ARGV.length < 2
|
159
|
+
|
160
|
+
# Copy template
|
161
|
+
FileUtils.cp_r("#{gem_script_dir}/../template/new/", current_dir, verbose: true)
|
162
|
+
# Rename dir
|
163
|
+
FileUtils.mv("#{current_dir}/new", "#{current_dir}/#{ARGV[1]}", verbose: true)
|
164
|
+
|
165
|
+
elsif ARGV[0..1] == MAKE_SERVICE_COMMAND
|
166
|
+
error_and_exit('Not bucky project dirctory here.') unless bucky_home?
|
167
|
+
error_and_exit('No service name.') if ARGV.length < 3
|
168
|
+
|
169
|
+
service_name = ARGV[2]
|
170
|
+
|
171
|
+
# Check if there is any directory in same service name.
|
172
|
+
error_and_exit("Already exist #{service_name} directory.") if File.exist?("#{current_dir}/services/#{service_name}")
|
173
|
+
FileUtils.mkdir("#{current_dir}/services/#{service_name}", verbose: true)
|
174
|
+
|
175
|
+
elsif ARGV[0..1] == MAKE_PAGE_COMMAND
|
176
|
+
support_device = %w[pc sp tablet]
|
177
|
+
error_and_exit('Not bucky project dirctory here.') unless bucky_home?
|
178
|
+
error_and_exit('No page name.') if ARGV.length < 3
|
179
|
+
error_and_exit('No service name.') unless test_cond[:service]
|
180
|
+
|
181
|
+
# Default conditions setting
|
182
|
+
test_cond[:device] ||= 'pc'
|
183
|
+
|
184
|
+
error_and_exit("#{test_cond[:device]} device is not supported. (only pc/sp/tablet.)") unless support_device.include?(test_cond[:device])
|
185
|
+
|
186
|
+
page_name = ARGV[2]
|
187
|
+
pageobject_dir = "#{current_dir}/services/#{test_cond[:service]}/#{test_cond[:device]}/pageobject"
|
188
|
+
pageobject_rb = "#{pageobject_dir}/#{page_name}.rb"
|
189
|
+
parts_dir = "#{current_dir}/services/#{test_cond[:service]}/#{test_cond[:device]}/parts"
|
190
|
+
parts_file = "#{parts_dir}/#{page_name}.yml"
|
191
|
+
|
192
|
+
error_and_exit("Already exist pageobject file: #{pageobject_rb}.") if File.exist?(pageobject_rb)
|
193
|
+
error_and_exit("Already exist parts file: #{parts_file}.") if File.exist?(parts_file)
|
194
|
+
FileUtils.mkdir_p("#{current_dir}/services/#{test_cond[:service]}/#{test_cond[:device]}")
|
195
|
+
FileUtils.cp_r(
|
196
|
+
"#{gem_script_dir}/../template/make_page/#{test_cond[:device]}",
|
197
|
+
"#{current_dir}/services/#{test_cond[:service]}",
|
198
|
+
verbose: true
|
199
|
+
)
|
200
|
+
|
201
|
+
FileUtils.mv("#{pageobject_dir}/sample_page.rb", pageobject_rb, verbose: true)
|
202
|
+
FileUtils.mv("#{parts_dir}/sample_page.yml", parts_file, verbose: true)
|
203
|
+
|
204
|
+
# Change service name and page name on pageobject
|
205
|
+
# | {SampleService} -> ServiceName
|
206
|
+
# | {SamplePage} -> PageName
|
207
|
+
script = File.open(pageobject_rb).read
|
208
|
+
split_and_capitalize = proc { |str| str.split(/_|-/).map(&:capitalize).join }
|
209
|
+
script.sub!('{SampleService}', split_and_capitalize.call(test_cond[:service]))
|
210
|
+
script.sub!('{SamplePage}', split_and_capitalize.call(page_name))
|
211
|
+
File.open(pageobject_rb, 'w+') { |f| f.write script }
|
212
|
+
else
|
213
|
+
error_and_exit
|
214
|
+
end
|
data/lib/bucky.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sequel'
|
4
|
+
require_relative '../exception/bucky_exception'
|
5
|
+
require_relative '../../utils/config'
|
6
|
+
|
7
|
+
module Bucky
|
8
|
+
module Core
|
9
|
+
module Database
|
10
|
+
class DbConnector
|
11
|
+
attr_reader :con
|
12
|
+
def initialize
|
13
|
+
@test_db_config = Bucky::Utils::Config.instance[:test_db]
|
14
|
+
end
|
15
|
+
|
16
|
+
# Connect to database
|
17
|
+
# @param [String] db_name database name
|
18
|
+
def connect(db_name = 'bucky_test')
|
19
|
+
@con = Sequel.connect(@test_db_config[db_name.to_sym], encoding: 'utf8')
|
20
|
+
end
|
21
|
+
|
22
|
+
# Disconnect to database
|
23
|
+
def disconnect
|
24
|
+
@con.disconnect
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|