From 373c6933d227d295b2d69950f6849600c98bf77f Mon Sep 17 00:00:00 2001 From: Alessandro Desantis Date: Sun, 25 Aug 2019 19:13:14 +0200 Subject: [PATCH] Adopt new trailblazer-operation API --- Gemfile | 3 ++- lib/pragma.rb | 2 ++ pragma.gemspec | 3 ++- spec/pragma/macro/classes_spec.rb | 1 + spec/pragma/operation/create_spec.rb | 2 +- spec/pragma/operation/destroy_spec.rb | 2 +- spec/pragma/operation/index_spec.rb | 2 +- spec/pragma/operation/show_spec.rb | 4 +++- spec/pragma/operation/update_spec.rb | 2 +- 9 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index 4d2437a..612862a 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,8 @@ source 'https://rubygems.org' # Specify your gem's dependencies in pragma.gemspec gemspec -gem 'pragma-operation', github: 'pragmarb/pragma-operation' +# gem 'pragma-operation', github: 'pragmarb/pragma-operation' +gem 'pragma-operation', path: '../pragma-operation' gem 'pragma-policy', github: 'pragmarb/pragma-policy' gem 'pragma-decorator', github: 'pragmarb/pragma-decorator' gem 'pragma-contract', github: 'pragmarb/pragma-contract' diff --git a/lib/pragma.rb b/lib/pragma.rb index 026a028..7fd6e7c 100644 --- a/lib/pragma.rb +++ b/lib/pragma.rb @@ -5,6 +5,8 @@ require 'pragma/policy' require 'pragma/contract' require 'pragma/decorator' +require 'trailblazer-macro' +require 'trailblazer-macro-contract' require 'zeitwerk' Zeitwerk::Loader.for_gem.setup diff --git a/pragma.gemspec b/pragma.gemspec index 6d59ce4..3ab1488 100644 --- a/pragma.gemspec +++ b/pragma.gemspec @@ -26,7 +26,8 @@ Gem::Specification.new do |spec| spec.add_dependency 'pragma-decorator', '~> 2.0' spec.add_dependency 'pragma-operation', '~> 2.0' spec.add_dependency 'pragma-policy', '~> 2.0' - spec.add_dependency 'trailblazer', '~> 2.0' + spec.add_dependency 'trailblazer-macro', '~> 2.1.0.rc13' + spec.add_dependency 'trailblazer-macro-contract', '~> 2.1.0.rc13' spec.add_dependency 'zeitwerk', '~> 2.1' spec.add_development_dependency 'bundler' diff --git a/spec/pragma/macro/classes_spec.rb b/spec/pragma/macro/classes_spec.rb index fc9aaf9..b103ce0 100644 --- a/spec/pragma/macro/classes_spec.rb +++ b/spec/pragma/macro/classes_spec.rb @@ -37,6 +37,7 @@ class << self def validate_classes(operation, expectations) expectations.each do |key, expected| it "computes #{key} correctly" do + binding.irb expect(Object.const_get(operation).call[key].to_s).to eq(expected) end end diff --git a/spec/pragma/operation/create_spec.rb b/spec/pragma/operation/create_spec.rb index 02cb60f..db4019a 100644 --- a/spec/pragma/operation/create_spec.rb +++ b/spec/pragma/operation/create_spec.rb @@ -3,7 +3,7 @@ RSpec.describe Pragma::Operation::Create do subject(:result) do described_class.call( - params, + 'params' => params, 'current_user' => current_user, 'model.class' => model_klass, 'decorator.instance.class' => decorator_klass, diff --git a/spec/pragma/operation/destroy_spec.rb b/spec/pragma/operation/destroy_spec.rb index 20d2643..9a6dfdb 100644 --- a/spec/pragma/operation/destroy_spec.rb +++ b/spec/pragma/operation/destroy_spec.rb @@ -3,7 +3,7 @@ RSpec.describe Pragma::Operation::Destroy do subject(:result) do described_class.call( - params, + 'params' => params, 'current_user' => current_user, 'model.class' => model_klass, 'policy.default.class' => policy_klass diff --git a/spec/pragma/operation/index_spec.rb b/spec/pragma/operation/index_spec.rb index 185bb0c..4f0fadb 100644 --- a/spec/pragma/operation/index_spec.rb +++ b/spec/pragma/operation/index_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Pragma::Operation::Index do subject(:result) do described_class.call( - params, + 'params' => params, 'current_user' => current_user, 'model.class' => model_klass, 'decorator.collection.class' => collection_decorator_klass, diff --git a/spec/pragma/operation/show_spec.rb b/spec/pragma/operation/show_spec.rb index ce65e31..ef529a7 100644 --- a/spec/pragma/operation/show_spec.rb +++ b/spec/pragma/operation/show_spec.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true RSpec.describe Pragma::Operation::Show do - subject(:result) { described_class.call(params, base_options.merge(options)) } + subject(:result) do + described_class.call(base_options.merge(options).merge('params' => params)) + end let(:params) do { diff --git a/spec/pragma/operation/update_spec.rb b/spec/pragma/operation/update_spec.rb index 513b54c..cc1488f 100644 --- a/spec/pragma/operation/update_spec.rb +++ b/spec/pragma/operation/update_spec.rb @@ -3,7 +3,7 @@ RSpec.describe Pragma::Operation::Update do subject(:result) do described_class.call( - params, + 'params' => params, 'current_user' => current_user, 'model.class' => model_klass, 'decorator.instance.class' => decorator_klass,