Skip to content

Commit

Permalink
Merge pull request #8 from imdrasil/feature/add-crystal-1-support
Browse files Browse the repository at this point in the history
Add crystal 1 support
  • Loading branch information
imdrasil committed Jun 28, 2021
2 parents 210b6e1 + 3ceafde commit ca0d850
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 34 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI

on:
push:
schedule:
- cron: "0 7 * * 1"

jobs:
test:
strategy:
fail-fast: false

runs-on: ubuntu-latest

env:
DB_USER: dbuser
DB_PASSWORD: dbpassword

steps:
- name: Install Crystal
uses: oprypin/install-crystal@v1

- name: Donwload sources
uses: actions/checkout@v2

- name: Check formatting
run: crystal tool format --check

- name: Install dependencies
# TODO: remove --ignore-crystal-version once all packages will be updated
run: shards install --ignore-crystal-version

- name: Run linter
run: ./bin/ameba

- name: Install PostgreSQL
uses: harmon758/postgresql-action@v1
with:
postgresql version: '9.5'
postgresql user: ${{ env.DB_USER }}
postgresql password: ${{ env.DB_PASSWORD }}

- name: Run migrations
run: crystal sam.cr db:create @ db:migrate

- name: Run specs
run: make seq
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

8 changes: 8 additions & 0 deletions sam.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require "sam"
require "./spec/support/config"
require "./spec/support/models"
require "./spec/support/migrations/*"

load_dependencies "jennifer"

Sam.help
12 changes: 9 additions & 3 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
name: factory
version: 0.1.4
version: 0.1.5

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

crystal: 0.26.1
crystal: ">= 0.34.0"

license: MIT

development_dependencies:
minitest:
github: ysbaddaden/minitest.cr
version: "~> 0.4.0"
version: "~> 1.0.0"
sam:
github: imdrasil/sam.cr
version: "~> 0.4.1"
jennifer:
github: imdrasil/jennifer.cr
branch: "master"
pg:
github: will/crystal-pg
ameba:
github: crystal-ameba/ameba
version: "= 0.14.3"
4 changes: 2 additions & 2 deletions spec/factory/jennifer/base_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ describe Factory::Jennifer::Base do
let(:described_class) { Factory::Jennifer::Base }

before do
::Jennifer::Adapter.adapter.begin_transaction
::Jennifer::Adapter.default_adapter.begin_transaction
end

after do
::Jennifer::Adapter.adapter.rollback_transaction
::Jennifer::Adapter.default_adapter.rollback_transaction
end

describe "%association" do
Expand Down
3 changes: 1 addition & 2 deletions spec/support/config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ require "jennifer"
require "jennifer/adapter/postgres"

::Jennifer::Config.configure do |conf|
conf.logger.level = Logger::ERROR
conf.host = "localhost"
conf.logger.level = :error
conf.adapter = "postgres"
conf.migration_files_path = "./spec/support/migrations"
conf.db = "factory_test"
Expand Down
2 changes: 1 addition & 1 deletion spec/support/factories.cr
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class HumanPetFactory < PetFactory
skip_empty_constructor
assign :f1, "centaur"

initialize_with do |hash, traits|
initialize_with do |hash, traits| # ameba:disable Lint/UnusedArgument
obj = described_class.new({"f1" => "some value"})
make_assigns(obj, traits)
obj
Expand Down
8 changes: 0 additions & 8 deletions spec/support/sam.cr

This file was deleted.

2 changes: 1 addition & 1 deletion src/factory/jennifer/association.cr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Factory
{% if factory %}
{% klass = factory %}
{% else %}
{% klass = (name.id.stringify.camelcase + "Factory" ).id %}
{% klass = (name.id.stringify.camelcase + "Factory").id %}
{% end %}

def self.__process_association_{{name.id}}(obj)
Expand Down
4 changes: 2 additions & 2 deletions src/factory/jennifer/base.cr
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ module Factory
{% if ATTRIBUTES.empty? %}
{% if !IGNORED_METHODS.includes?("empty_constructor") %}
def self._initialize_with(hash, traits)
obj = described_class.build
obj = described_class.new
make_assigns(obj, traits)
obj
end
{% end %}
{% else %}
{% if !IGNORED_METHODS.includes?("hash_constructor") %}
def self._initialize_with(hash, traits)
obj = described_class.build(hash)
obj = described_class.new(hash)
make_assigns(obj, traits)
obj
end
Expand Down
2 changes: 1 addition & 1 deletion src/factory/version.cr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Factory
VERSION = "0.1.4"
VERSION = "0.1.5"
end

0 comments on commit ca0d850

Please sign in to comment.