New upstream version 3.14.0
Samuel Henrique
3 years ago
25 | 25 | gem "public_suffix", "< 3.0.0" |
26 | 26 | end |
27 | 27 | |
28 | # Latest versions of i18n don't support Ruby < 2.1 | |
29 | if Gem::Requirement.new("< 2.1").satisfied_by?(Gem::Version.new(RUBY_VERSION)) | |
28 | # Latest versions of i18n don't support Ruby < 2.4 | |
29 | if Gem::Requirement.new("< 2.4").satisfied_by?(Gem::Version.new(RUBY_VERSION)) | |
30 | 30 | gem "i18n", "< 1.3.0" |
31 | end | |
32 | ||
33 | # Latest versions of rake don't support Ruby < 2.2 | |
34 | if Gem::Requirement.new("< 2.2").satisfied_by?(Gem::Version.new(RUBY_VERSION)) | |
35 | gem "rake", "< 13.0.0" | |
31 | 36 | end |
32 | 37 | |
33 | 38 | # We only run danger once on a new-ish ruby; no need to install it otherwise |
106 | 106 | |
107 | 107 | ``` ruby |
108 | 108 | group :development do |
109 | gem "capistrano", "~> 3.13", require: false | |
109 | gem "capistrano", "~> 3.14", require: false | |
110 | 110 | end |
111 | 111 | ``` |
112 | 112 |
48 | 48 | end |
49 | 49 | |
50 | 50 | def question |
51 | if default.nil? | |
51 | if prompt && default.nil? | |
52 | I18n.t(:question_prompt, key: prompt, scope: :capistrano) | |
53 | elsif prompt | |
54 | I18n.t(:question_prompt_default, key: prompt, default_value: default, scope: :capistrano) | |
55 | elsif default.nil? | |
52 | 56 | I18n.t(:question, key: key, scope: :capistrano) |
53 | 57 | else |
54 | 58 | I18n.t(:question_default, key: key, default_value: default, scope: :capistrano) |
62 | 66 | def stdin |
63 | 67 | (options || {}).fetch(:stdin, $stdin) |
64 | 68 | end |
69 | ||
70 | def prompt | |
71 | (options || {}).fetch(:prompt, nil) | |
72 | end | |
65 | 73 | end |
66 | 74 | end |
67 | 75 | end |
11 | 11 | written_file: "create %{file}", |
12 | 12 | question: "Please enter %{key}: ", |
13 | 13 | question_default: "Please enter %{key} (%{default_value}): ", |
14 | question_prompt: "%{key}: ", | |
15 | question_prompt_default: "%{key} (%{default_value}): ", | |
14 | 16 | keeping_releases: "Keeping %{keep_releases} of %{releases} deployed releases on %{host}", |
15 | 17 | skip_cleanup: "Skipping cleanup of invalid releases on %{host}; unexpected foldername found (should be timestamp)", |
16 | 18 | wont_delete_current_release: "Current release was marked for being removed but it's going to be skipped on %{host}", |
5 | 5 | let(:question) { Question.new(key, default, stdin: stdin) } |
6 | 6 | let(:question_without_echo) { Question.new(key, default, echo: false, stdin: stdin) } |
7 | 7 | let(:question_without_default) { Question.new(key, nil, stdin: stdin) } |
8 | let(:question_prompt) { Question.new(key, default, stdin: stdin, prompt: "Your favorite branch") } | |
9 | let(:question_prompt_without_default) { Question.new(key, nil, stdin: stdin, prompt: "Your favorite branch") } | |
8 | 10 | let(:default) { :default } |
9 | 11 | let(:key) { :branch } |
10 | 12 | let(:stdin) { stub(tty?: true) } |
42 | 44 | |
43 | 45 | expect(question_without_default.call).to eq(branch) |
44 | 46 | end |
47 | ||
48 | it "uses prompt and returns the value" do | |
49 | $stdout.expects(:print).with("Your favorite branch (default): ") | |
50 | stdin.expects(:gets).returns(branch) | |
51 | stdin.expects(:noecho).never | |
52 | ||
53 | expect(question_prompt.call).to eq(branch) | |
54 | end | |
55 | ||
56 | it "uses prompt and returns the value but has no default between parenthesis" do | |
57 | $stdout.expects(:print).with("Your favorite branch: ") | |
58 | stdin.expects(:gets).returns(branch) | |
59 | stdin.expects(:noecho).never | |
60 | ||
61 | expect(question_prompt_without_default.call).to eq(branch) | |
62 | end | |
45 | 63 | end |
46 | 64 | |
47 | 65 | context "value is not entered" do |