blob: 915cbe580c558bab416e06da14d218cc486b2554 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# frozen_string_literal: true
RSpec.describe Pry::BlockCommand do
subject { Class.new(described_class).new }
describe "#call" do
context "when #process accepts no arguments" do
let(:block) do
def process; end
method(:process)
end
before { subject.class.block = block }
it "calls the block despite passed arguments" do
expect { subject.call(1, 2) }.not_to raise_error
end
end
context "when #process accepts some arguments" do
let(:block) do
def process(arg, other); end
method(:process)
end
before { subject.class.block = block }
it "calls the block even if there's not enough arguments" do
expect { subject.call(1) }.not_to raise_error
end
it "calls the block even if there are more arguments than needed" do
expect { subject.call(1, 2, 3) }.not_to raise_error
end
end
context "when passed a variable-length array" do
let(:block) do
def process(*args); end
method(:process)
end
before { subject.class.block = block }
it "calls the block without arguments" do
expect { subject.call }.not_to raise_error
end
it "calls the block with some arguments" do
expect { subject.call(1, 2, 3) }.not_to raise_error
end
end
end
describe "#help" do
before do
subject.class.description = 'desc'
subject.class.command_options(listing: 'listing')
end
it "returns help output" do
expect(subject.help).to eq('listing desc')
end
end
end
|