-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from nebulab/fix
Some little fixes
- Loading branch information
Showing
6 changed files
with
21 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,31 @@ | ||
require 'spec_helper' | ||
|
||
class BasicValidator | ||
include Interactor | ||
include Pulsar::Validator | ||
end | ||
|
||
class NotNilInteractor | ||
include Interactor | ||
include Pulsar::Validator | ||
|
||
validate_context_for! :not_nil_property | ||
end | ||
|
||
class GreaterThanTenInteractor | ||
include Interactor | ||
include Pulsar::Validator | ||
|
||
validate_context_for! :greater_than_ten do |prop| | ||
prop > 10 | ||
end | ||
end | ||
|
||
RSpec.describe Pulsar::Validator do | ||
let(:described_instance) { BasicValidator.new } | ||
let(:described_instance) { NotNilInteractor.new } | ||
|
||
it { expect(described_instance).to respond_to :validate_context! } | ||
|
||
describe '#validate_context!' do | ||
context 'without block' do | ||
subject { NotNilInteractor.call initial_context } | ||
|
||
context 'with valid property name' do | ||
let(:initial_context) { { not_nil_property: true } } | ||
subject { NotNilInteractor.call initial_context } | ||
|
||
it { is_expected.to be_a_success } | ||
it { is_expected.to eql Interactor::Context.new(not_nil_property: true) } | ||
end | ||
context 'with valid property name' do | ||
let(:initial_context) { { not_nil_property: true } } | ||
|
||
context 'with invalid property name' do | ||
let(:initial_context) { { not_nil_property: nil } } | ||
|
||
it { is_expected.to be_a_failure } | ||
end | ||
it { is_expected.to be_a_success } | ||
it { is_expected.to eql Interactor::Context.new(not_nil_property: true) } | ||
end | ||
|
||
context 'with block' do | ||
subject { GreaterThanTenInteractor.call initial_context } | ||
context 'with valid property' do | ||
let(:initial_context) { { greater_than_ten: 32 } } | ||
|
||
it { is_expected.to be_a_success } | ||
it { is_expected.to eql Interactor::Context.new(greater_than_ten: 32) } | ||
end | ||
|
||
context 'with invalid property' do | ||
let(:initial_context) { { greater_than_ten: 4 } } | ||
context 'with invalid property name' do | ||
let(:initial_context) { { not_nil_property: nil } } | ||
|
||
it { is_expected.to be_a_failure } | ||
end | ||
it { is_expected.to be_a_failure } | ||
end | ||
end | ||
end |