Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions .ameba.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,2 @@
# This configuration file was generated by `ameba --gen-config`
# on 2025-02-22 11:49:05 UTC using Ameba version 1.5.0.
# The point is for the user to remove these configuration records
# one by one as the reported problems are removed from the code base.

# Problems found: 1
# Run `ameba --only Lint/NotNil` for details
Lint/NotNil:
Description: Identifies usage of `not_nil!` calls
Excluded:
- src/reqs-up.cr
Enabled: true
Severity: Warning
Documentation/DocumentationAdmonition:
Style/HeredocIndent:
Enabled: false
2 changes: 1 addition & 1 deletion shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ version: 2.0
shards:
ameba:
git: https://github.com/crystal-ameba/ameba.git
version: 1.6.4+git.commit.a21dea0b44642f4fc87429283f8b0dd9f1e47a9f
version: 1.7.0-dev+git.commit.4057e0c5ed98587282587afb9cc44395c41de3f0
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ executables:
development_dependencies:
ameba:
github: crystal-ameba/ameba
tag: v1.6.4
commit: 4057e0c5
28 changes: 16 additions & 12 deletions spec/main_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ describe "main.cr CLI" do
describe "опция --dry-run" do
it "выводит результат в stdout вместо записи в файл" do
test_file = "spec/fixtures/requirements_dryrun.yml"
File.write(test_file, "---
- name: test
src: https://github.com/evgkrsk/reqs-up.git
version: 1.0.0
scm: git
")
yaml = <<-YAML
---
- name: test
src: https://github.com/evgkrsk/reqs-up.git
version: 1.0.0
scm: git
YAML
File.write(test_file, yaml)
output = `crystal run src/main.cr -- --dry-run --file #{test_file} 2>&1`
$?.success?.should be_true
output.should contain("---")
Expand All @@ -41,12 +43,14 @@ describe "main.cr CLI" do
describe "опция --file" do
it "использует указанный файл вместо requirements.yml" do
test_file = "spec/fixtures/requirements_custom.yml"
File.write(test_file, "---
- name: custom
src: https://github.com/evgkrsk/reqs-up.git
version: 1.0.0
scm: git
")
yaml = <<-YAML
---
- name: custom
src: https://github.com/evgkrsk/reqs-up.git
version: 1.0.0
scm: git
YAML
File.write(test_file, yaml)
output = `crystal run src/main.cr -- --dry-run --file #{test_file} 2>&1`
$?.success?.should be_true
output.should contain("custom")
Expand Down
160 changes: 80 additions & 80 deletions spec/reqs-up_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,11 @@ describe ReqsUp do
describe "парсинг полей из YAML" do
it "извлекает src, name, version, scm" do
yaml_str = <<-YAML
- name: test-role
src: https://github.com/evgkrsk/reqs-up.git
version: 1.2.3
scm: git
YAML
- name: test-role
src: https://github.com/evgkrsk/reqs-up.git
version: 1.2.3
scm: git
YAML
yaml = YAML.parse(yaml_str)
git_req = ReqsUp::GitReq.new(yaml[0])
git_req.name.should eq("test-role")
Expand All @@ -324,9 +324,9 @@ describe ReqsUp do

it "корректно обрабатывает отсутствие name" do
yaml_str = <<-YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.0.0
YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.0.0
YAML
yaml = YAML.parse(yaml_str)
git_req = ReqsUp::GitReq.new(yaml[0])
git_req.name.should be_nil
Expand All @@ -336,9 +336,9 @@ describe ReqsUp do
describe "#versions" do
it "возвращает пустой массив при отсутствии git" do
yaml_str = <<-YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.0.0
YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.0.0
YAML
yaml = YAML.parse(yaml_str)
git_req = ReqsUp::GitReq.new(yaml[0])
# Тест предполагает что git есть в системе, но для мокирования
Expand All @@ -350,9 +350,9 @@ describe ReqsUp do
describe "#update" do
it "возвращает nil для не-semver версии" do
yaml_str = <<-YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: not-a-version
YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: not-a-version
YAML
yaml = YAML.parse(yaml_str)
git_req = ReqsUp::GitReq.new(yaml[0])
result = git_req.update
Expand All @@ -361,8 +361,8 @@ describe ReqsUp do

it "возвращает nil при отсутствии версии" do
yaml_str = <<-YAML
- src: https://github.com/evgkrsk/reqs-up.git
YAML
- src: https://github.com/evgkrsk/reqs-up.git
YAML
yaml = YAML.parse(yaml_str)
git_req = ReqsUp::GitReq.new(yaml[0])
result = git_req.update
Expand All @@ -371,9 +371,9 @@ describe ReqsUp do

it "возвращает текущую версию если нет новых версий" do
yaml_str = <<-YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.0.0
YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.0.0
YAML
yaml = YAML.parse(yaml_str)
git_req = ReqsUp::GitReq.new(yaml[0])
# Метод versions будет вызван, но так как мы не мокаем git,
Expand All @@ -388,11 +388,11 @@ describe ReqsUp do
describe "#to_s" do
it "возвращает строковое представление объекта" do
yaml_str = <<-YAML
- name: test-role
src: https://github.com/evgkrsk/reqs-up.git
version: 1.2.3
scm: git
YAML
- name: test-role
src: https://github.com/evgkrsk/reqs-up.git
version: 1.2.3
scm: git
YAML
yaml = YAML.parse(yaml_str)
req = ReqsUp::GitReq.new(yaml[0])
req.to_s.should contain("GitReq")
Expand All @@ -408,20 +408,20 @@ describe ReqsUp do
it "обновляет версию когда есть более новая" do
git_script = "spec/fixtures/git"
script_str = <<-SCRIPT
#!/bin/bash
echo "abc123 refs/tags/v0.9.0"
echo "def456 refs/tags/v1.0.0"
echo "ghi789 refs/tags/v1.1.0"
echo "jkl012 refs/tags/v1.2.0"
echo "mno345 refs/tags/v2.0.0"
SCRIPT
#!/bin/bash
echo "abc123 refs/tags/v0.9.0"
echo "def456 refs/tags/v1.0.0"
echo "ghi789 refs/tags/v1.1.0"
echo "jkl012 refs/tags/v1.2.0"
echo "mno345 refs/tags/v2.0.0"
SCRIPT
File.write(git_script, script_str)
File.chmod(git_script, 0o755)

yaml_str = <<-YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.0.0
YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.0.0
YAML
yaml = YAML.parse(yaml_str)
git_req = ReqsUp::GitReq.new(yaml[0])

Expand All @@ -441,9 +441,9 @@ describe ReqsUp do
describe "обработка ошибок git" do
it "возвращает пустой массив когда git не найден" do
yaml_str = <<-YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.0.0
YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.0.0
YAML
yaml = YAML.parse(yaml_str)
git_req = ReqsUp::GitReq.new(yaml[0])

Expand All @@ -464,20 +464,20 @@ describe ReqsUp do
it "обновляет до максимальной minor версии" do
git_script = "spec/fixtures/git"
script_str = <<-SCRIPT
#!/bin/bash
echo "abc123 refs/tags/v1.0.0"
echo "def456 refs/tags/v1.5.0"
echo "ghi789 refs/tags/v1.9.0"
echo "jkl012 refs/tags/v2.0.0"
echo "mno345 refs/tags/v2.1.0"
SCRIPT
#!/bin/bash
echo "abc123 refs/tags/v1.0.0"
echo "def456 refs/tags/v1.5.0"
echo "ghi789 refs/tags/v1.9.0"
echo "jkl012 refs/tags/v2.0.0"
echo "mno345 refs/tags/v2.1.0"
SCRIPT
File.write(git_script, script_str)
File.chmod(git_script, 0o755)

yaml_str = <<-YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.2.3
YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.2.3
YAML
yaml = YAML.parse(yaml_str)
git_req = ReqsUp::GitReq.new(yaml[0])

Expand All @@ -496,17 +496,17 @@ describe ReqsUp do
it "не обновляет если нет подходящих minor версий" do
git_script = "spec/fixtures/git"
script_str = <<-SCRIPT
#!/bin/bash
echo "abc123 refs/tags/v2.0.0"
echo "def456 refs/tags/v2.1.0"
SCRIPT
#!/bin/bash
echo "abc123 refs/tags/v2.0.0"
echo "def456 refs/tags/v2.1.0"
SCRIPT
File.write(git_script, script_str)
File.chmod(git_script, 0o755)

yaml_str = <<-YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.2.3
YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.2.3
YAML
yaml = YAML.parse(yaml_str)
git_req = ReqsUp::GitReq.new(yaml[0])

Expand All @@ -527,20 +527,20 @@ describe ReqsUp do
it "обновляет до максимальной patch версии" do
git_script = "spec/fixtures/git"
script_str = <<-SCRIPT
#!/bin/bash
echo "abc123 refs/tags/v1.2.0"
echo "def456 refs/tags/v1.2.5"
echo "ghi789 refs/tags/v1.2.8"
echo "jkl012 refs/tags/v1.2.9"
echo "mno345 refs/tags/v1.3.0"
SCRIPT
#!/bin/bash
echo "abc123 refs/tags/v1.2.0"
echo "def456 refs/tags/v1.2.5"
echo "ghi789 refs/tags/v1.2.8"
echo "jkl012 refs/tags/v1.2.9"
echo "mno345 refs/tags/v1.3.0"
SCRIPT
File.write(git_script, script_str)
File.chmod(git_script, 0o755)

yaml_str = <<-YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.2.3
YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.2.3
YAML
yaml = YAML.parse(yaml_str)
git_req = ReqsUp::GitReq.new(yaml[0])

Expand All @@ -559,17 +559,17 @@ describe ReqsUp do
it "не обновляет если нет подходящих patch версий" do
git_script = "spec/fixtures/git"
script_str = <<-SCRIPT
#!/bin/bash
echo "abc123 refs/tags/v1.3.0"
echo "def456 refs/tags/v1.4.0"
SCRIPT
#!/bin/bash
echo "abc123 refs/tags/v1.3.0"
echo "def456 refs/tags/v1.4.0"
SCRIPT
File.write(git_script, script_str)
File.chmod(git_script, 0o755)

yaml_str = <<-YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.2.3
YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.2.3
YAML
yaml = YAML.parse(yaml_str)
git_req = ReqsUp::GitReq.new(yaml[0])

Expand All @@ -590,19 +590,19 @@ describe ReqsUp do
it "игнорирует pre-release версии" do
git_script = "spec/fixtures/git"
script_str = <<-SCRIPT
#!/bin/bash
echo "abc123 refs/tags/v1.0.0"
echo "def456 refs/tags/v1.0.0-alpha"
echo "ghi789 refs/tags/v1.0.0-beta.1"
echo "jkl012 refs/tags/v1.0.1"
SCRIPT
#!/bin/bash
echo "abc123 refs/tags/v1.0.0"
echo "def456 refs/tags/v1.0.0-alpha"
echo "ghi789 refs/tags/v1.0.0-beta.1"
echo "jkl012 refs/tags/v1.0.1"
SCRIPT
File.write(git_script, script_str)
File.chmod(git_script, 0o755)

yaml_str = <<-YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.0.0
YAML
- src: https://github.com/evgkrsk/reqs-up.git
version: 1.0.0
YAML
yaml = YAML.parse(yaml_str)
git_req = ReqsUp::GitReq.new(yaml[0])

Expand Down
Loading