closer 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +6 -1
- data/lib/closer.rb +2 -0
- data/lib/closer/cucumber_ext.rb +3 -0
- data/lib/closer/cucumber_ext/compiler.rb +31 -0
- data/lib/closer/helpers/snapshot.rb +27 -0
- data/lib/closer/helpers/snapshots/db_dump.rb +60 -0
- data/lib/closer/version.rb +1 -1
- data/lib/tasks/close.rake +8 -4
- metadata +6 -3
- data/lib/cucumber/ext/compiler.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dffdcef6d2d979a67c165c9726530db05dffc121a4485f77d4a81e3026ba160
|
4
|
+
data.tar.gz: 96e3c964e64f1b714fb7a32e885df52ddcf3c8ab8199f03e4615eac982623203
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09e646924633cac98783da5ad44650955ec943feaf4b7226da74a7abe6a9ec137ce8e28e2796515fac9a9aed98e3bd22c287d22c4b4c01ad001ea04f7f534420'
|
7
|
+
data.tar.gz: 8bb822369440ee6f6ac32208e7ace05132d5733332a21a41e168e40900730f6cfacfb7132dacfcfedea0e2999d917b417ba5d2f00e1f9d26b81bbcec1d8d2060
|
data/HISTORY.md
CHANGED
data/lib/closer.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'cucumber/core/compiler'
|
2
|
+
|
3
|
+
module Cucumber
|
4
|
+
module Core
|
5
|
+
class Compiler
|
6
|
+
class TestCaseBuilder
|
7
|
+
|
8
|
+
def on_test_case(source)
|
9
|
+
valid_test_case = false
|
10
|
+
resume_story_from = ENV['RESUME_STORY_FROM'].to_s
|
11
|
+
|
12
|
+
if resume_story_from.empty?
|
13
|
+
valid_test_case = true
|
14
|
+
else
|
15
|
+
@feature, scenario = *source
|
16
|
+
if @feature.location.file >= resume_story_from
|
17
|
+
valid_test_case = true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
if valid_test_case
|
22
|
+
Test::Case.new(test_steps, source).describe_to(receiver) #if test_steps.count > 0
|
23
|
+
end
|
24
|
+
@test_steps = nil
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
if ENV['USER_STORY']
|
2
|
+
unless ENV['CI']
|
3
|
+
require_relative 'snapshots/db_dump'
|
4
|
+
|
5
|
+
Before do |scenario|
|
6
|
+
db_dump = DbDump.instance
|
7
|
+
feature_file = scenario.feature.location.file
|
8
|
+
|
9
|
+
if ENV['RESUME_STORY_FROM'].to_s == feature_file
|
10
|
+
if db_dump.current_feature.nil?
|
11
|
+
db_dump.current_feature = feature_file
|
12
|
+
db_dump.load('tmp/user_stories')
|
13
|
+
end
|
14
|
+
else
|
15
|
+
# 直前のDBをダンプしておく
|
16
|
+
if db_dump.current_feature != feature_file
|
17
|
+
db_dump.current_feature = feature_file
|
18
|
+
db_dump.dump
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
After do |scenario|
|
25
|
+
Cucumber.wants_to_quit = true if scenario.failed?
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'singleton'
|
3
|
+
|
4
|
+
class DbDump
|
5
|
+
include Singleton
|
6
|
+
|
7
|
+
attr_accessor :current_feature
|
8
|
+
|
9
|
+
def load(dir)
|
10
|
+
db = Dir.glob(File.join(dump_dir, '*.dump.gz')).first
|
11
|
+
db ||= Dir.glob(File.join(dir, '*.dump.gz')).first
|
12
|
+
|
13
|
+
if db
|
14
|
+
raise 'DBロードに失敗しました。' unless load_mysql(db)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def dump(dir = nil)
|
19
|
+
raise 'DBダンプの削除に失敗しました。' unless system("rm -f #{dump_dir(dir)}/*.gz")
|
20
|
+
raise 'DBダンプに失敗しました。' unless dump_mysql(dump_dir(dir))
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def dump_dir(dir = nil)
|
26
|
+
if dir.to_s.empty?
|
27
|
+
dir = File.join('tmp', File.dirname(current_feature), File.basename(current_feature, '.feature'))
|
28
|
+
end
|
29
|
+
|
30
|
+
dir
|
31
|
+
end
|
32
|
+
|
33
|
+
def dump_mysql(dump_dir)
|
34
|
+
config = YAML.load_file(File.join('config', 'database.yml'))[Rails.env]
|
35
|
+
host = config['host'] || 'localhost'
|
36
|
+
database = config['database']
|
37
|
+
user = config['username']
|
38
|
+
password = config['password']
|
39
|
+
|
40
|
+
filepath = File.join(dump_dir, "#{database}-#{Time.now.strftime('%Y-%m-%d_%H%M')}.dump.gz")
|
41
|
+
|
42
|
+
FileUtils.mkdir_p(File.dirname(filepath))
|
43
|
+
system("mysqldump -u #{user} -p#{password} -h #{host} #{database} | gzip > #{filepath}")
|
44
|
+
end
|
45
|
+
|
46
|
+
def load_mysql(dump_file)
|
47
|
+
config = YAML.load_file(File.join('config', 'database.yml'))[Rails.env]
|
48
|
+
host = config['host'] || 'localhost'
|
49
|
+
database = config['database']
|
50
|
+
user = config['username']
|
51
|
+
password = config['password']
|
52
|
+
|
53
|
+
if dump_file.end_with?('.gz')
|
54
|
+
system("zcat #{dump_file} | mysql -u #{user} -p#{password} -h #{host} #{database}")
|
55
|
+
else
|
56
|
+
system("mysql -u #{user} -p#{password} -h #{host} #{database} < #{dump_file}")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
data/lib/closer/version.rb
CHANGED
data/lib/tasks/close.rake
CHANGED
@@ -53,10 +53,6 @@ task :close => dependencies do |t, args|
|
|
53
53
|
args << '--no-strict'
|
54
54
|
end
|
55
55
|
|
56
|
-
if feature_dir != 'user_stories'
|
57
|
-
args << '--order random' unless ENV['SORT']
|
58
|
-
end
|
59
|
-
|
60
56
|
options = [
|
61
57
|
'DRIVER=' + (ENV['DRIVER'] || 'headless_chrome'),
|
62
58
|
'PAUSE=' + (ENV['PAUSE'] || '0'),
|
@@ -66,6 +62,14 @@ task :close => dependencies do |t, args|
|
|
66
62
|
'COMMAND_NAME=' + (ENV['COMMAND_NAME'] || feature_dir.split('_').map{|a| a.capitalize }.join)
|
67
63
|
]
|
68
64
|
|
65
|
+
if feature_dir == 'user_stories'
|
66
|
+
options << 'USER_STORY=' + 'true'
|
67
|
+
options << 'RESUME_STORY_FROM=' + features.first
|
68
|
+
features = ['user_stories']
|
69
|
+
else
|
70
|
+
args << '--order random' unless ENV['SORT']
|
71
|
+
end
|
72
|
+
|
69
73
|
report_dir = File.join(feature_dir, 'reports')
|
70
74
|
fail unless system("mkdir -p #{report_dir}")
|
71
75
|
fail unless system("rm -Rf #{report_dir}/*")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: closer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ichy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -118,6 +118,8 @@ files:
|
|
118
118
|
- lib/closer.rb
|
119
119
|
- lib/closer/config.rb
|
120
120
|
- lib/closer/coverage/rcov_formatter.rb
|
121
|
+
- lib/closer/cucumber_ext.rb
|
122
|
+
- lib/closer/cucumber_ext/compiler.rb
|
121
123
|
- lib/closer/formatter/closer.css
|
122
124
|
- lib/closer/formatter/closer.js
|
123
125
|
- lib/closer/formatter/closer_html.rb
|
@@ -132,9 +134,10 @@ files:
|
|
132
134
|
- lib/closer/helpers/driver.rb
|
133
135
|
- lib/closer/helpers/drivers/file_detector.rb
|
134
136
|
- lib/closer/helpers/multi_test.rb
|
137
|
+
- lib/closer/helpers/snapshot.rb
|
138
|
+
- lib/closer/helpers/snapshots/db_dump.rb
|
135
139
|
- lib/closer/tasks.rb
|
136
140
|
- lib/closer/version.rb
|
137
|
-
- lib/cucumber/ext/compiler.rb
|
138
141
|
- lib/tasks/close.rake
|
139
142
|
homepage: https://github.com/ichylinux/closer
|
140
143
|
licenses:
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'cucumber/core/compiler'
|
2
|
-
|
3
|
-
module Cucumber
|
4
|
-
module Core
|
5
|
-
class Compiler
|
6
|
-
class TestCaseBuilder
|
7
|
-
|
8
|
-
def on_test_case(source)
|
9
|
-
Test::Case.new(test_steps, source).describe_to(receiver) #if test_steps.count > 0
|
10
|
-
@test_steps = nil
|
11
|
-
self
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|