diff --git a/.travis.yml b/.travis.yml index 3f144ab..0e98ab0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ cache: bundler language: ruby rvm: - - 2.0 - 2.1 - 2.2 - 2.3.0 diff --git a/README.md b/README.md index 12cccdd..fd2eac4 100644 --- a/README.md +++ b/README.md @@ -41,13 +41,13 @@ class AuthenticateUser include Interactor::Contracts expects do - attr(:email) { |email| email.filled? } - attr(:password) { |password| password.filled? } + required(:email).filled + required(:password).filled end assures do - attr(:user) { |user| user.filled? } - attr(:token) { |token| token.filled? } + required(:user).filled + required(:token).filled end def call diff --git a/interactor-contracts.gemspec b/interactor-contracts.gemspec index 2807716..a97e4df 100644 --- a/interactor-contracts.gemspec +++ b/interactor-contracts.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| spec.files += Dir["lib/**/*.rb"] spec.require_paths = ["lib"] - spec.add_dependency "dry-validation", "~> 0.7", "< 0.8" + spec.add_dependency "dry-validation" spec.add_dependency "interactor", "~> 3" spec.add_development_dependency "bundler", "~> 1.11" diff --git a/lib/interactor/contracts.rb b/lib/interactor/contracts.rb index cd9ec86..6d70b08 100644 --- a/lib/interactor/contracts.rb +++ b/lib/interactor/contracts.rb @@ -37,7 +37,7 @@ def assurances # include Interactor::Contracts # # assures do - # attr(:person, &:filled?) + # required(:person).filled # end # # def call @@ -68,7 +68,7 @@ def default_violation_handler # include Interactor::Contracts # # expects do - # attr(:name, &:filled?) + # required(:name).filled # end # # def call @@ -102,7 +102,7 @@ def expectations # include Interactor::Contracts # # expects do - # attr(:name, &:filled?) + # required(:name).filled # end # # on_violation do |violations| @@ -164,7 +164,7 @@ def define_assurances_hook after do assurances = self.class.assurances.new - result = assurances.call(context) + result = assurances.call(context.to_h) unless result.success? violations = result.messages.map do |property, messages| @@ -189,7 +189,7 @@ def define_expectations_hook before do expectations = self.class.expectations.new - result = expectations.call(context) + result = expectations.call(context.to_h) unless result.success? violations = result.messages.map do |property, messages| diff --git a/spec/interactor/contracts_spec.rb b/spec/interactor/contracts_spec.rb index 8ef6c4e..4e09634 100644 --- a/spec/interactor/contracts_spec.rb +++ b/spec/interactor/contracts_spec.rb @@ -16,7 +16,7 @@ include Interactor::Contracts assures do - attr(:name).required + required(:name).filled end def call @@ -36,11 +36,11 @@ def call include Interactor::Contracts assures do - attr(:first_name).required + required(:first_name).filled end assures do - attr(:last_name).required + required(:last_name).filled end def call @@ -61,11 +61,11 @@ def call include Interactor::Contracts assures do - attr(:first_name).required + required(:first_name).filled end assures do - attr(:last_name).required + required(:last_name).filled end def call @@ -87,7 +87,7 @@ def call include Interactor::Contracts expects do - attr(:name).required + required(:name).filled end end @@ -101,11 +101,11 @@ def call include Interactor::Contracts expects do - attr(:first_name).required + required(:first_name).filled end expects do - attr(:last_name).required + required(:last_name).filled end end @@ -124,11 +124,11 @@ def call include Interactor::Contracts expects do - attr(:first_name).required + required(:first_name).filled end expects do - attr(:last_name).required + required(:last_name).filled end end @@ -142,7 +142,7 @@ def call include Interactor include Interactor::Contracts - expects { attr(:name).required } + expects { required(:name).filled } on_violation { |_| context[:message] = "Bilbo Baggins!" } end @@ -158,7 +158,7 @@ def call include Interactor include Interactor::Contracts - assures { attr(:name).required } + assures { required(:name).filled } on_violation { |_| context[:message] = "Bilbo Baggins!" } end @@ -174,7 +174,7 @@ def call include Interactor include Interactor::Contracts - expects { attr(:name).required } + expects { required(:name).filled } on_violation { |_| context[:silly] = "You did something silly." } on_violation { |_| context.fail!(:message => "Bilbo Baggins!") } @@ -192,7 +192,7 @@ def call include Interactor include Interactor::Contracts - expects { attr(:name).required } + expects { required(:name).filled } on_violation { |_| context.fail!(:message => "Bilbo Baggins!") } on_violation { |_| context[:wont_be_set] = "Nope" } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cb6fd3c..8f572b3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,5 @@ -require "codeclimate-test-reporter" -CodeClimate::TestReporter.start +require 'simplecov' +SimpleCov.start if ENV["COVERAGE"] || ENV["CI"] require "simplecov"