-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update DeferProp signature to simplify group usage with blocks
- Loading branch information
Showing
8 changed files
with
110 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
RSpec.describe InertiaRails::AlwaysProp do | ||
describe '#call' do | ||
subject(:call) { prop.call } | ||
let(:prop) { described_class.new('value') } | ||
|
||
it { is_expected.to eq('value') } | ||
|
||
context 'with a callable value' do | ||
let(:prop) { described_class.new(-> { 'callable' }) } | ||
|
||
it { is_expected.to eq('callable') } | ||
end | ||
|
||
context 'with a block' do | ||
let(:prop) { described_class.new { 'block' } } | ||
|
||
it { is_expected.to eq('block') } | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
RSpec.describe InertiaRails::DeferProp do | ||
describe '#call' do | ||
subject(:call) { prop.call } | ||
let(:prop) { described_class.new('value') } | ||
|
||
it { is_expected.to eq('value') } | ||
|
||
it 'returns the default group' do | ||
expect(prop.group).to eq('default') | ||
end | ||
|
||
context "with group" do | ||
let(:prop) { described_class.new('value', group: 'custom') } | ||
|
||
it 'returns the group' do | ||
expect(prop.group).to eq('custom') | ||
end | ||
end | ||
|
||
context 'with a callable value' do | ||
let(:prop) { described_class.new(-> { 'callable' }) } | ||
|
||
it { is_expected.to eq('callable') } | ||
|
||
context "with group" do | ||
let(:prop) { described_class.new(-> { 'callable' }, group: 'custom') } | ||
|
||
it 'returns the group' do | ||
expect(prop.group).to eq('custom') | ||
end | ||
end | ||
end | ||
|
||
context 'with a block' do | ||
let(:prop) { described_class.new { 'block' } } | ||
|
||
it { is_expected.to eq('block') } | ||
|
||
context "with group" do | ||
let(:prop) { described_class.new(group: 'custom') { 'block' } } | ||
|
||
it 'returns the group' do | ||
expect(prop.group).to eq('custom') | ||
end | ||
end | ||
end | ||
|
||
it 'returns the merge flag' do | ||
expect(prop.merge?).to be_falsey | ||
prop.merge | ||
|
||
expect(prop.merge?).to be(true) | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
RSpec.describe InertiaRails::MergeProp do | ||
describe '#call' do | ||
subject(:call) { prop.call } | ||
let(:prop) { described_class.new('value') } | ||
|
||
it { is_expected.to eq('value') } | ||
|
||
context 'with a callable value' do | ||
let(:prop) { described_class.new(-> { 'callable' }) } | ||
|
||
it { is_expected.to eq('callable') } | ||
end | ||
|
||
context 'with a block' do | ||
let(:prop) { described_class.new { 'block' } } | ||
|
||
it { is_expected.to eq('block') } | ||
end | ||
|
||
it 'returns the merge flag' do | ||
expect(prop.merge?).to eq(true) | ||
end | ||
end | ||
end |
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