|
111 | 111 | expect(subject.entries.map(&:path)).to contain_exactly('file_1', 'file_2') |
112 | 112 | end |
113 | 113 | end |
| 114 | + |
| 115 | + context 'building the right status command' do |
| 116 | + let(:given_options) { {} } |
| 117 | + |
| 118 | + let(:result) { instance_double(RubyGit::CommandLine::Result, stdout: '') } |
| 119 | + |
| 120 | + context 'when no options are given' do |
| 121 | + let(:expected_command) do |
| 122 | + %w[status --porcelain=v2 |
| 123 | + --branch --show-stash --ahead-behind --renames -z |
| 124 | + --untracked-files=all --ignored=no --ignore-submodules=all] |
| 125 | + end |
| 126 | + |
| 127 | + it 'should build the correct command' do |
| 128 | + expect(worktree).to( |
| 129 | + receive(:run).with(*expected_command, Hash) |
| 130 | + ).and_return(result) |
| 131 | + |
| 132 | + worktree.status(**given_options) |
| 133 | + end |
| 134 | + end |
| 135 | + |
| 136 | + context 'when a non-default untracked_files is given' do |
| 137 | + let(:given_options) { { untracked_files: :normal } } |
| 138 | + |
| 139 | + it 'should build the correct command' do |
| 140 | + expect(worktree).to( |
| 141 | + receive(:run) do |*args, **_options| |
| 142 | + expect(args).to include('--untracked-files=normal') |
| 143 | + end.and_return(result) |
| 144 | + ) |
| 145 | + worktree.status(**given_options) |
| 146 | + end |
| 147 | + end |
| 148 | + |
| 149 | + context 'when ignored is given' do |
| 150 | + let(:given_options) { { ignored: :matching } } |
| 151 | + |
| 152 | + it 'should build the correct command' do |
| 153 | + expect(worktree).to( |
| 154 | + receive(:run) do |*args, **_options| |
| 155 | + expect(args).to include('--ignored=matching') |
| 156 | + end.and_return(result) |
| 157 | + ) |
| 158 | + worktree.status(**given_options) |
| 159 | + end |
| 160 | + end |
| 161 | + |
| 162 | + context 'when ignore_submodules is given' do |
| 163 | + let(:given_options) { { ignore_submodules: :dirty } } |
| 164 | + |
| 165 | + it 'should build the correct command' do |
| 166 | + expect(worktree).to( |
| 167 | + receive(:run) do |*args, **_options| |
| 168 | + expect(args).to include('--ignore-submodules=dirty') |
| 169 | + end.and_return(result) |
| 170 | + ) |
| 171 | + worktree.status(**given_options) |
| 172 | + end |
| 173 | + end |
| 174 | + end |
114 | 175 | end |
115 | 176 | end |
0 commit comments