hanami-devtools 2023.02.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rubocop.yml +158 -0
- data/Gemfile +4 -0
- data/README.md +35 -0
- data/Rakefile +4 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/hanami-devtools.gemspec +42 -0
- data/lib/hanami/devtools/integration/bundler.rb +174 -0
- data/lib/hanami/devtools/integration/capybara.rb +20 -0
- data/lib/hanami/devtools/integration/cli.rb +57 -0
- data/lib/hanami/devtools/integration/coverage.rb +55 -0
- data/lib/hanami/devtools/integration/dns.rb +26 -0
- data/lib/hanami/devtools/integration/env.rb +97 -0
- data/lib/hanami/devtools/integration/files.rb +108 -0
- data/lib/hanami/devtools/integration/gemfile.rb +38 -0
- data/lib/hanami/devtools/integration/hanami_commands.rb +169 -0
- data/lib/hanami/devtools/integration/platform/engine.rb +32 -0
- data/lib/hanami/devtools/integration/platform/matcher.rb +79 -0
- data/lib/hanami/devtools/integration/platform/os.rb +21 -0
- data/lib/hanami/devtools/integration/platform.rb +22 -0
- data/lib/hanami/devtools/integration/project_without_hanami_model.rb +26 -0
- data/lib/hanami/devtools/integration/rack_test.rb +87 -0
- data/lib/hanami/devtools/integration/random_port.rb +46 -0
- data/lib/hanami/devtools/integration/retry.rb +36 -0
- data/lib/hanami/devtools/integration/silently.rb +35 -0
- data/lib/hanami/devtools/integration/with_clean_env_project.rb +29 -0
- data/lib/hanami/devtools/integration/with_directory.rb +30 -0
- data/lib/hanami/devtools/integration/with_project.rb +77 -0
- data/lib/hanami/devtools/integration/with_system_tmp_directory.rb +24 -0
- data/lib/hanami/devtools/integration/with_tmp_directory.rb +48 -0
- data/lib/hanami/devtools/integration/within_project_directory.rb +37 -0
- data/lib/hanami/devtools/integration.rb +4 -0
- data/lib/hanami/devtools/rake_helper.rb +31 -0
- data/lib/hanami/devtools/rake_tasks.rb +4 -0
- data/lib/hanami/devtools/unit/support/coverage.rb +10 -0
- data/lib/hanami/devtools/unit/support/silence_deprecations.rb +12 -0
- data/lib/hanami/devtools/unit.rb +4 -0
- data/lib/hanami/devtools/version.rb +7 -0
- data/lib/hanami/devtools.rb +8 -0
- data/script/setup +36 -0
- metadata +266 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 6b819306f2455421d0ee135fe9e402f4ad942c85107b1675fbd4b45cb8495a30
|
|
4
|
+
data.tar.gz: e1fd50d1cfc3f3be0097b5283a71a56d762a7f1118a0637ceb3ce079ef9a3557
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: d01d8885c60495d028b09afc939e610db3bf1a1a00a377f925a542f1a4ed68807d8beded05bd08f9811541a39dc7df34cec5fb35b7a073ce88a53791bb565a9d
|
|
7
|
+
data.tar.gz: 192d367e36588f4be482b56c4c3aaa3839b3a9eec665f655e620877479a3ea4152d58b647e14c4d8d100452bbd9eb275df0c14165e991065abbdd2a56026f59b
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Please keep AllCops, Bundler, Layout, Style, Metrics groups and then order cops
|
|
2
|
+
# alphabetically
|
|
3
|
+
#
|
|
4
|
+
# References:
|
|
5
|
+
# * https://github.com/bbatsov/ruby-style-guide
|
|
6
|
+
# * https://rubocop.readthedocs.io/
|
|
7
|
+
#
|
|
8
|
+
# This configuration is for Hanami 2.x and Rubocop ~> 1.0
|
|
9
|
+
AllCops:
|
|
10
|
+
TargetRubyVersion: 3.0
|
|
11
|
+
DisplayCopNames: true
|
|
12
|
+
DisplayStyleGuide: true
|
|
13
|
+
ExtraDetails: false
|
|
14
|
+
SuggestExtensions: false
|
|
15
|
+
NewCops: enable
|
|
16
|
+
Exclude:
|
|
17
|
+
- "vendor/**/*"
|
|
18
|
+
- "vendor/**/.*" # See https://github.com/bbatsov/rubocop/issues/4832
|
|
19
|
+
Bundler/OrderedGems:
|
|
20
|
+
Enabled: false
|
|
21
|
+
Gemspec/DevelopmentDependencies:
|
|
22
|
+
Enabled: false
|
|
23
|
+
Gemspec/OrderedDependencies:
|
|
24
|
+
Enabled: false
|
|
25
|
+
Layout/FirstArrayElementIndentation:
|
|
26
|
+
EnforcedStyle: consistent
|
|
27
|
+
Layout/LineLength:
|
|
28
|
+
Max: 120
|
|
29
|
+
Exclude:
|
|
30
|
+
- "spec/**/*_spec.rb"
|
|
31
|
+
Layout/SpaceInLambdaLiteral:
|
|
32
|
+
Enabled: false
|
|
33
|
+
Layout/MultilineMethodCallIndentation:
|
|
34
|
+
Enabled: true
|
|
35
|
+
EnforcedStyle: indented
|
|
36
|
+
Layout/SpaceInsideHashLiteralBraces:
|
|
37
|
+
Enabled: true
|
|
38
|
+
EnforcedStyle: no_space
|
|
39
|
+
EnforcedStyleForEmptyBraces: no_space
|
|
40
|
+
Lint/AssignmentInCondition:
|
|
41
|
+
Enabled: false
|
|
42
|
+
Lint/ConstantDefinitionInBlock:
|
|
43
|
+
Enabled: false
|
|
44
|
+
Lint/EmptyClass:
|
|
45
|
+
Enabled: false
|
|
46
|
+
Lint/RaiseException:
|
|
47
|
+
Enabled: false
|
|
48
|
+
Lint/StructNewOverride:
|
|
49
|
+
Enabled: true
|
|
50
|
+
Metrics/AbcSize:
|
|
51
|
+
Max: 25
|
|
52
|
+
Metrics/CyclomaticComplexity:
|
|
53
|
+
Enabled: true
|
|
54
|
+
Max: 12
|
|
55
|
+
Metrics/MethodLength:
|
|
56
|
+
Enabled: false
|
|
57
|
+
Metrics/BlockLength:
|
|
58
|
+
Enabled: false
|
|
59
|
+
Metrics/ClassLength:
|
|
60
|
+
Enabled: false
|
|
61
|
+
Naming/FileName:
|
|
62
|
+
Enabled: false
|
|
63
|
+
Naming/HeredocDelimiterNaming:
|
|
64
|
+
Enabled: false
|
|
65
|
+
Naming/MemoizedInstanceVariableName:
|
|
66
|
+
Enabled: false
|
|
67
|
+
Naming/MethodName:
|
|
68
|
+
Enabled: false
|
|
69
|
+
Naming/MethodParameterName:
|
|
70
|
+
Enabled: false
|
|
71
|
+
Naming/PredicateName:
|
|
72
|
+
Enabled: false
|
|
73
|
+
Naming/RescuedExceptionsVariableName:
|
|
74
|
+
PreferredName: exception
|
|
75
|
+
Style/Alias:
|
|
76
|
+
Enabled: true
|
|
77
|
+
EnforcedStyle: prefer_alias_method
|
|
78
|
+
Style/AndOr:
|
|
79
|
+
Enabled: false
|
|
80
|
+
Style/AsciiComments:
|
|
81
|
+
Enabled: false
|
|
82
|
+
Style/BisectedAttrAccessor:
|
|
83
|
+
Enabled: false
|
|
84
|
+
Style/BlockDelimiters:
|
|
85
|
+
Enabled: false
|
|
86
|
+
Style/ClassAndModuleChildren:
|
|
87
|
+
Exclude:
|
|
88
|
+
- "spec/**/*_spec.rb"
|
|
89
|
+
Style/ConditionalAssignment:
|
|
90
|
+
Enabled: false
|
|
91
|
+
Style/DateTime:
|
|
92
|
+
Enabled: false
|
|
93
|
+
Style/Documentation:
|
|
94
|
+
Enabled: false
|
|
95
|
+
Style/DoubleNegation:
|
|
96
|
+
Enabled: false
|
|
97
|
+
Style/EachWithObject:
|
|
98
|
+
Enabled: false
|
|
99
|
+
Style/EmptyMethod:
|
|
100
|
+
Enabled: false
|
|
101
|
+
Style/ExpandPathArguments:
|
|
102
|
+
Enabled: false
|
|
103
|
+
Style/FormatString:
|
|
104
|
+
Enabled: false
|
|
105
|
+
Style/FrozenStringLiteralComment:
|
|
106
|
+
Enabled: true
|
|
107
|
+
Style/GuardClause:
|
|
108
|
+
Enabled: false
|
|
109
|
+
Style/HashConversion:
|
|
110
|
+
Enabled: false
|
|
111
|
+
Style/HashEachMethods:
|
|
112
|
+
Enabled: false
|
|
113
|
+
Style/HashTransformKeys:
|
|
114
|
+
Enabled: true
|
|
115
|
+
Style/HashTransformValues:
|
|
116
|
+
Enabled: true
|
|
117
|
+
Style/IfUnlessModifier:
|
|
118
|
+
Enabled: false
|
|
119
|
+
Style/Lambda:
|
|
120
|
+
Enabled: false
|
|
121
|
+
Style/LambdaCall:
|
|
122
|
+
Enabled: false
|
|
123
|
+
Style/MultilineBlockChain:
|
|
124
|
+
Enabled: false
|
|
125
|
+
Style/OptionalBooleanParameter:
|
|
126
|
+
Enabled: false
|
|
127
|
+
Style/ParallelAssignment:
|
|
128
|
+
Enabled: false
|
|
129
|
+
Style/RaiseArgs:
|
|
130
|
+
Enabled: false
|
|
131
|
+
Style/RedundantAssignment:
|
|
132
|
+
Enabled: true
|
|
133
|
+
Style/RedundantConstantBase:
|
|
134
|
+
Enabled: false
|
|
135
|
+
Style/RedundantFetchBlock:
|
|
136
|
+
Enabled: true
|
|
137
|
+
Style/RedundantRegexpCharacterClass:
|
|
138
|
+
Enabled: true
|
|
139
|
+
Style/RedundantRegexpEscape:
|
|
140
|
+
Enabled: true
|
|
141
|
+
Style/RegexpLiteral:
|
|
142
|
+
Enabled: false
|
|
143
|
+
Style/SlicingWithRange:
|
|
144
|
+
Enabled: true
|
|
145
|
+
Style/SpecialGlobalVars:
|
|
146
|
+
Enabled: false
|
|
147
|
+
Style/StringLiterals:
|
|
148
|
+
Enabled: true
|
|
149
|
+
EnforcedStyle: double_quotes
|
|
150
|
+
ConsistentQuotesInMultiline: false
|
|
151
|
+
Style/StringLiteralsInInterpolation:
|
|
152
|
+
Enabled: true
|
|
153
|
+
EnforcedStyle: single_quotes
|
|
154
|
+
Style/SymbolArray:
|
|
155
|
+
Exclude:
|
|
156
|
+
- "spec/**/*_spec.rb"
|
|
157
|
+
Style/TrailingUnderscoreVariable:
|
|
158
|
+
Enabled: false
|
data/Gemfile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Hanami::Devtools
|
|
2
|
+
|
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/hanami/devtools`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
|
+
|
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'hanami-devtools'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install hanami-devtools
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
TODO: Write usage instructions here
|
|
26
|
+
|
|
27
|
+
## Development
|
|
28
|
+
|
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
30
|
+
|
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
32
|
+
|
|
33
|
+
## Contributing
|
|
34
|
+
|
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/hanami/devtools.
|
data/Rakefile
ADDED
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 "hanami/devtools"
|
|
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(__FILE__)
|
data/bin/setup
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
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 "hanami/devtools/version"
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
8
|
+
spec.name = "hanami-devtools"
|
|
9
|
+
spec.version = Hanami::Devtools::VERSION
|
|
10
|
+
spec.authors = ["Luca Guidi"]
|
|
11
|
+
spec.email = ["me@lucaguidi.com"]
|
|
12
|
+
|
|
13
|
+
spec.summary = "Development tools for Hanami"
|
|
14
|
+
spec.description = "Development tools for Hanami. This gem is designed for the Hanami core team."
|
|
15
|
+
spec.homepage = "http://hanamirb.org"
|
|
16
|
+
spec.license = "MIT"
|
|
17
|
+
|
|
18
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
19
|
+
spec.required_ruby_version = ">= 3.0"
|
|
20
|
+
|
|
21
|
+
spec.bindir = "exe"
|
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
23
|
+
spec.require_paths = ["lib"]
|
|
24
|
+
|
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
spec.add_dependency "aruba", "~> 0.14"
|
|
30
|
+
spec.add_dependency "bundler", ">= 1.6", "< 3"
|
|
31
|
+
spec.add_dependency "dotenv", "~> 2.0"
|
|
32
|
+
spec.add_dependency "capybara", "~> 3.34"
|
|
33
|
+
spec.add_dependency "codecov", "~> 0.1"
|
|
34
|
+
spec.add_dependency "excon", "~> 0.60"
|
|
35
|
+
spec.add_dependency "poltergeist", "~> 1.17"
|
|
36
|
+
spec.add_dependency "rack", "~> 2.0"
|
|
37
|
+
spec.add_dependency "rspec", "~> 3.7"
|
|
38
|
+
spec.add_dependency "dry-core", ">= 0.9", "< 2"
|
|
39
|
+
spec.add_dependency "hanami-utils"
|
|
40
|
+
|
|
41
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
|
42
|
+
end
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "open3"
|
|
4
|
+
require "pathname"
|
|
5
|
+
require "hanami/devtools/integration/env"
|
|
6
|
+
require "hanami/devtools/integration/gemfile"
|
|
7
|
+
require "hanami/devtools/integration/silently"
|
|
8
|
+
require "hanami/devtools/integration/files"
|
|
9
|
+
|
|
10
|
+
module RSpec
|
|
11
|
+
module Support
|
|
12
|
+
# Support for Bundler
|
|
13
|
+
#
|
|
14
|
+
# @since 0.2.0
|
|
15
|
+
module Bundler
|
|
16
|
+
HANAMI_GEMS_PREFIX = "hanami-"
|
|
17
|
+
HANAMI_GEMS = %w[utils validations router controller view helpers mailer assets model webconsole].freeze
|
|
18
|
+
|
|
19
|
+
def self.root
|
|
20
|
+
@_root
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.root=(value)
|
|
24
|
+
@_root = Pathname.new(value).realpath
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
self.root = Dir.pwd
|
|
28
|
+
|
|
29
|
+
def self.cache
|
|
30
|
+
root.join("vendor", "cache")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.setup
|
|
34
|
+
return unless setup?
|
|
35
|
+
|
|
36
|
+
with_clean_env do
|
|
37
|
+
RSpec::Support.silently(setup_script)
|
|
38
|
+
Gemfile.write_checksum
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.setup?
|
|
43
|
+
return true if Platform.ci?
|
|
44
|
+
|
|
45
|
+
Gemfile.changed?
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.setup_script
|
|
49
|
+
result = root.join("script", "setup")
|
|
50
|
+
return result.to_s if result.exist?
|
|
51
|
+
|
|
52
|
+
Pathname.new(__dir__).join("..", "..", "..", "..", "script", "setup").realpath.to_s
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def self.with_clean_env(&blk)
|
|
56
|
+
::Bundler.with_clean_env(&blk)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
private
|
|
60
|
+
|
|
61
|
+
attr_reader :out, :err, :exitstatus
|
|
62
|
+
|
|
63
|
+
# rubocop:disable Metrics/MethodLength
|
|
64
|
+
# rubocop:disable Metrics/AbcSize
|
|
65
|
+
def setup_gemfile(gems: [], exclude_gems: [], path: "Gemfile")
|
|
66
|
+
@current_gemfile_path = RSpec::Support::Env["BUNDLE_GEMFILE"]
|
|
67
|
+
RSpec::Support::Env["BUNDLE_GEMFILE"] = ::File.join(Dir.pwd, path)
|
|
68
|
+
|
|
69
|
+
content = ::File.readlines(path)
|
|
70
|
+
content = inject_gemfile_sources(content, cache)
|
|
71
|
+
|
|
72
|
+
unless gems.empty?
|
|
73
|
+
gems = gems.map do |g|
|
|
74
|
+
case g
|
|
75
|
+
when String
|
|
76
|
+
"gem '#{g}'\n"
|
|
77
|
+
when Array
|
|
78
|
+
"gem '#{g.first}', #{g.last}\n"
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
content.concat(gems)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
exclude_gems.each do |g|
|
|
86
|
+
content.reject! { |line| line.include?(g) }
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
rewrite(path, content)
|
|
90
|
+
end
|
|
91
|
+
# rubocop:enable Metrics/AbcSize
|
|
92
|
+
# rubocop:enable Metrics/MethodLength
|
|
93
|
+
|
|
94
|
+
def restore_gemfile
|
|
95
|
+
RSpec::Support::Env["BUNDLE_GEMFILE"] = @current_gemfile_path if defined?(@current_gemfile_path)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def bundle_install
|
|
99
|
+
bundle "install --local --no-cache --retry 0 --no-color"
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def bundle_exec(cmd, env: nil, &blk)
|
|
103
|
+
bundle("exec #{cmd}", env: env, &blk)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def bundle(cmd, env: nil, &blk)
|
|
107
|
+
# ruby_bin = which("ruby")
|
|
108
|
+
bundle_bin = which("bundle")
|
|
109
|
+
hanami_env = "HANAMI_ENV=#{env} " unless env.nil?
|
|
110
|
+
|
|
111
|
+
# system_exec("#{hanami_env}#{ruby_bin} -I#{load_paths} #{bundle_bin} #{cmd}", &blk)
|
|
112
|
+
system_exec("#{hanami_env}#{bundle_bin} #{cmd}", &blk)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def inject_gemfile_sources(contents, vendor_cache_path)
|
|
116
|
+
sources = ["source 'file://#{vendor_cache_path}'\n"]
|
|
117
|
+
sources + contents[1..-1]
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Adapted from Bundler source code
|
|
121
|
+
#
|
|
122
|
+
# Bundler is released under MIT license
|
|
123
|
+
# https://github.com/bundler/bundler/blob/master/LICENSE.md
|
|
124
|
+
#
|
|
125
|
+
# A special "thank you" goes to Bundler maintainers and contributors.
|
|
126
|
+
#
|
|
127
|
+
# rubocop:disable Metrics/AbcSize
|
|
128
|
+
# rubocop:disable Metrics/MethodLength
|
|
129
|
+
def system_exec(cmd)
|
|
130
|
+
Open3.popen3(RSpec::Support::Env.env, cmd) do |stdin, stdout, stderr, wait_thr|
|
|
131
|
+
yield stdin, stdout, wait_thr if block_given?
|
|
132
|
+
stdin.close
|
|
133
|
+
|
|
134
|
+
@exitstatus = wait_thr&.value&.exitstatus
|
|
135
|
+
@out = Thread.new { stdout.read }.value.strip
|
|
136
|
+
@err = Thread.new { stderr.read }.value.strip
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
@all_output ||= ""
|
|
140
|
+
@all_output += [
|
|
141
|
+
"$ #{cmd.to_s.strip}",
|
|
142
|
+
out,
|
|
143
|
+
err,
|
|
144
|
+
@exitstatus ? "# $? => #{@exitstatus}" : "",
|
|
145
|
+
"\n"
|
|
146
|
+
].reject(&:empty?).join("\n")
|
|
147
|
+
|
|
148
|
+
@out
|
|
149
|
+
end
|
|
150
|
+
# rubocop:enable Metrics/MethodLength
|
|
151
|
+
# rubocop:enable Metrics/AbcSize
|
|
152
|
+
|
|
153
|
+
def load_paths
|
|
154
|
+
[root.join("lib"), root.join("spec")].join(":")
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def root
|
|
158
|
+
RSpec::Support::Bundler.root
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def cache
|
|
162
|
+
RSpec::Support::Bundler.cache
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
RSpec.configure do |config|
|
|
169
|
+
config.include RSpec::Support::Bundler, type: :integration
|
|
170
|
+
|
|
171
|
+
config.before(:all, type: :integration) do
|
|
172
|
+
RSpec::Support::Bundler.setup
|
|
173
|
+
end
|
|
174
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "capybara"
|
|
4
|
+
require "capybara/rspec"
|
|
5
|
+
require "capybara/dsl"
|
|
6
|
+
require "hanami/devtools/integration/platform"
|
|
7
|
+
require "capybara/poltergeist"
|
|
8
|
+
|
|
9
|
+
RSpec.configure do |config|
|
|
10
|
+
config.include Capybara::DSL, type: :integration
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
Capybara.register_driver :poltergeist do |app|
|
|
14
|
+
Capybara::Poltergeist::Driver.new(app, {js_errors: false})
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Capybara.configure do |config|
|
|
18
|
+
config.run_server = false
|
|
19
|
+
config.default_driver = :poltergeist
|
|
20
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "aruba"
|
|
4
|
+
require "aruba/api"
|
|
5
|
+
require "pathname"
|
|
6
|
+
|
|
7
|
+
module RSpec
|
|
8
|
+
module Support
|
|
9
|
+
# Run Command Line Interface (CLI) programs
|
|
10
|
+
#
|
|
11
|
+
# @since 0.2.0
|
|
12
|
+
module CLI
|
|
13
|
+
def self.included(spec)
|
|
14
|
+
spec.before do
|
|
15
|
+
aruba = Pathname.new(Dir.pwd).join("tmp", "aruba")
|
|
16
|
+
aruba.rmtree if aruba.exist?
|
|
17
|
+
|
|
18
|
+
setup_aruba
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def run_cmd(cmd, output = nil, exit_status: 0)
|
|
25
|
+
run_command_and_stop "bundle exec #{cmd}", fail_on_error: false
|
|
26
|
+
|
|
27
|
+
match_output(output)
|
|
28
|
+
expect(last_command_started).to have_exit_status(exit_status)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def run_cmd_with_clean_env(cmd, successful: true)
|
|
32
|
+
result = ::Bundler.clean_system(cmd, out: File::NULL)
|
|
33
|
+
expect(result).to be(successful)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def match_output(output)
|
|
37
|
+
case output
|
|
38
|
+
when String
|
|
39
|
+
expect(all_output).to include(output)
|
|
40
|
+
when Regexp
|
|
41
|
+
expect(all_output).to match(output)
|
|
42
|
+
when Array
|
|
43
|
+
output.each { |o| match_output(o) }
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def all_output
|
|
48
|
+
all_commands.map(&:output).join("\n")
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
RSpec.configure do |config|
|
|
55
|
+
config.include Aruba::Api, type: :integration
|
|
56
|
+
config.include RSpec::Support::CLI, type: :integration
|
|
57
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RSpec
|
|
4
|
+
module Support
|
|
5
|
+
# Code coverage support
|
|
6
|
+
#
|
|
7
|
+
# @since 0.2.0
|
|
8
|
+
module Coverage
|
|
9
|
+
def self.configure!
|
|
10
|
+
return unless enabled?
|
|
11
|
+
|
|
12
|
+
require "simplecov"
|
|
13
|
+
require "coveralls"
|
|
14
|
+
|
|
15
|
+
configure_simplecov!
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.cover_as!(suite_name)
|
|
19
|
+
return unless enabled?
|
|
20
|
+
|
|
21
|
+
SimpleCov.command_name(suite_name)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private_class_method
|
|
25
|
+
|
|
26
|
+
def self.ci?
|
|
27
|
+
!ENV["TRAVIS"].nil?
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.enabled?
|
|
31
|
+
# !ENV['COVERAGE'].nil?
|
|
32
|
+
false
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.configure_simplecov!
|
|
36
|
+
SimpleCov.formatter = Coveralls::SimpleCov::Formatter if ci?
|
|
37
|
+
|
|
38
|
+
SimpleCov.start do
|
|
39
|
+
add_filter "spec/"
|
|
40
|
+
add_filter "script/"
|
|
41
|
+
add_filter "tmp/"
|
|
42
|
+
add_filter "vendor/"
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
RSpec::Support::Coverage.configure!
|
|
50
|
+
|
|
51
|
+
RSpec.configure do |config|
|
|
52
|
+
config.before do |example|
|
|
53
|
+
RSpec::Support::Coverage.cover_as!(example.file_path)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "resolv-replace"
|
|
4
|
+
|
|
5
|
+
module RSpec
|
|
6
|
+
module Support
|
|
7
|
+
# DNS stub utilities
|
|
8
|
+
module Dns
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
def stub_dns_hosts(hosts)
|
|
12
|
+
file = Pathname.new(Dir.pwd).join("tmp", "hosts-#{SecureRandom.uuid}")
|
|
13
|
+
write(file, hosts)
|
|
14
|
+
|
|
15
|
+
hosts_resolver = Resolv::Hosts.new(file.to_s)
|
|
16
|
+
dns_resolver = Resolv::DNS.new
|
|
17
|
+
|
|
18
|
+
Resolv::DefaultResolver.replace_resolvers([hosts_resolver, dns_resolver])
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
RSpec.configure do |config|
|
|
25
|
+
config.include RSpec::Support::Dns, type: :integration
|
|
26
|
+
end
|