Skip to content

Commit ca0d850

Browse files
authored
Merge pull request #8 from imdrasil/feature/add-crystal-1-support
Add crystal 1 support
2 parents 210b6e1 + 3ceafde commit ca0d850

11 files changed

Lines changed: 72 additions & 34 deletions

File tree

.github/workflows/ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
schedule:
6+
- cron: "0 7 * * 1"
7+
8+
jobs:
9+
test:
10+
strategy:
11+
fail-fast: false
12+
13+
runs-on: ubuntu-latest
14+
15+
env:
16+
DB_USER: dbuser
17+
DB_PASSWORD: dbpassword
18+
19+
steps:
20+
- name: Install Crystal
21+
uses: oprypin/install-crystal@v1
22+
23+
- name: Donwload sources
24+
uses: actions/checkout@v2
25+
26+
- name: Check formatting
27+
run: crystal tool format --check
28+
29+
- name: Install dependencies
30+
# TODO: remove --ignore-crystal-version once all packages will be updated
31+
run: shards install --ignore-crystal-version
32+
33+
- name: Run linter
34+
run: ./bin/ameba
35+
36+
- name: Install PostgreSQL
37+
uses: harmon758/postgresql-action@v1
38+
with:
39+
postgresql version: '9.5'
40+
postgresql user: ${{ env.DB_USER }}
41+
postgresql password: ${{ env.DB_PASSWORD }}
42+
43+
- name: Run migrations
44+
run: crystal sam.cr db:create @ db:migrate
45+
46+
- name: Run specs
47+
run: make seq

.travis.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

sam.cr

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require "sam"
2+
require "./spec/support/config"
3+
require "./spec/support/models"
4+
require "./spec/support/migrations/*"
5+
6+
load_dependencies "jennifer"
7+
8+
Sam.help

shard.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
name: factory
2-
version: 0.1.4
2+
version: 0.1.5
33

44
authors:
55
- Roman Kalnytskyi <moranibaca@gmail.com>
66

7-
crystal: 0.26.1
7+
crystal: ">= 0.34.0"
88

99
license: MIT
1010

1111
development_dependencies:
1212
minitest:
1313
github: ysbaddaden/minitest.cr
14-
version: "~> 0.4.0"
14+
version: "~> 1.0.0"
15+
sam:
16+
github: imdrasil/sam.cr
17+
version: "~> 0.4.1"
1518
jennifer:
1619
github: imdrasil/jennifer.cr
1720
branch: "master"
1821
pg:
1922
github: will/crystal-pg
23+
ameba:
24+
github: crystal-ameba/ameba
25+
version: "= 0.14.3"

spec/factory/jennifer/base_spec.cr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ describe Factory::Jennifer::Base do
44
let(:described_class) { Factory::Jennifer::Base }
55

66
before do
7-
::Jennifer::Adapter.adapter.begin_transaction
7+
::Jennifer::Adapter.default_adapter.begin_transaction
88
end
99

1010
after do
11-
::Jennifer::Adapter.adapter.rollback_transaction
11+
::Jennifer::Adapter.default_adapter.rollback_transaction
1212
end
1313

1414
describe "%association" do

spec/support/config.cr

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ require "jennifer"
22
require "jennifer/adapter/postgres"
33

44
::Jennifer::Config.configure do |conf|
5-
conf.logger.level = Logger::ERROR
6-
conf.host = "localhost"
5+
conf.logger.level = :error
76
conf.adapter = "postgres"
87
conf.migration_files_path = "./spec/support/migrations"
98
conf.db = "factory_test"

spec/support/factories.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class HumanPetFactory < PetFactory
9191
skip_empty_constructor
9292
assign :f1, "centaur"
9393

94-
initialize_with do |hash, traits|
94+
initialize_with do |hash, traits| # ameba:disable Lint/UnusedArgument
9595
obj = described_class.new({"f1" => "some value"})
9696
make_assigns(obj, traits)
9797
obj

spec/support/sam.cr

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/factory/jennifer/association.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module Factory
77
{% if factory %}
88
{% klass = factory %}
99
{% else %}
10-
{% klass = (name.id.stringify.camelcase + "Factory" ).id %}
10+
{% klass = (name.id.stringify.camelcase + "Factory").id %}
1111
{% end %}
1212

1313
def self.__process_association_{{name.id}}(obj)

src/factory/jennifer/base.cr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ module Factory
6060
{% if ATTRIBUTES.empty? %}
6161
{% if !IGNORED_METHODS.includes?("empty_constructor") %}
6262
def self._initialize_with(hash, traits)
63-
obj = described_class.build
63+
obj = described_class.new
6464
make_assigns(obj, traits)
6565
obj
6666
end
6767
{% end %}
6868
{% else %}
6969
{% if !IGNORED_METHODS.includes?("hash_constructor") %}
7070
def self._initialize_with(hash, traits)
71-
obj = described_class.build(hash)
71+
obj = described_class.new(hash)
7272
make_assigns(obj, traits)
7373
obj
7474
end

0 commit comments

Comments
 (0)