cape 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +2 -1
- data/.rspec +1 -1
- data/.travis.yml +6 -2
- data/Appraisals +11 -0
- data/Gemfile +4 -4
- data/Guardfile +10 -4
- data/History.markdown +6 -0
- data/README.markdown +32 -17
- data/Rakefile +33 -13
- data/cape.gemspec +6 -2
- data/features/dsl/each_rake_task/unqualified.feature +0 -6
- data/features/dsl/each_rake_task/with_defined_namespace.feature +1 -1
- data/features/dsl/each_rake_task/with_defined_task.feature +4 -4
- data/features/dsl/each_rake_task/with_undefined_task_or_namespace.feature +2 -2
- data/features/dsl/mirror_rake_tasks/inside_capistrano_namespace.feature +3 -4
- data/features/dsl/mirror_rake_tasks/unqualified.feature +89 -32
- data/features/dsl/mirror_rake_tasks/with_cd.feature +18 -12
- data/features/dsl/mirror_rake_tasks/with_cd_and_environment_variables.feature +6 -4
- data/features/dsl/mirror_rake_tasks/with_defined_namespace.feature +7 -3
- data/features/dsl/mirror_rake_tasks/with_defined_task.feature +10 -8
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_cd.feature +10 -8
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_cd_and_environment_variables.feature +10 -8
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_environment_variables.feature +21 -17
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename.feature +4 -2
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_cd.feature +4 -2
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_cd_and_environment_variables.feature +4 -2
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_environment_variables.feature +4 -2
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_valid_options.feature +4 -2
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_valid_options_and_cd.feature +4 -2
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_valid_options_and_cd_and_environment_variables.feature +4 -2
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_valid_options_and_environment_variables.feature +4 -2
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_valid_options.feature +22 -18
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_valid_options_and_cd.feature +10 -8
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_valid_options_and_cd_and_environment_variables.feature +10 -8
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_valid_options_and_environment_variables.feature +22 -18
- data/features/dsl/mirror_rake_tasks/with_environment_variables.feature +14 -10
- data/features/dsl/mirror_rake_tasks/with_rename.feature +3 -1
- data/features/dsl/mirror_rake_tasks/with_rename_and_cd.feature +3 -1
- data/features/dsl/mirror_rake_tasks/with_rename_and_cd_and_environment_variables.feature +3 -1
- data/features/dsl/mirror_rake_tasks/with_rename_and_environment_variables.feature +3 -1
- data/features/dsl/mirror_rake_tasks/with_rename_and_valid_options.feature +3 -1
- data/features/dsl/mirror_rake_tasks/with_rename_and_valid_options_and_cd.feature +3 -1
- data/features/dsl/mirror_rake_tasks/with_rename_and_valid_options_and_cd_and_environment_variables.feature +3 -1
- data/features/dsl/mirror_rake_tasks/with_rename_and_valid_options_and_environment_variables.feature +3 -1
- data/features/dsl/mirror_rake_tasks/with_undefined_task_or_namespace.feature +2 -2
- data/features/dsl/mirror_rake_tasks/with_valid_options.feature +12 -8
- data/features/dsl/mirror_rake_tasks/with_valid_options_and_cd.feature +6 -4
- data/features/dsl/mirror_rake_tasks/with_valid_options_and_cd_and_environment_variables.feature +6 -4
- data/features/dsl/mirror_rake_tasks/with_valid_options_and_environment_variables.feature +14 -10
- data/features/dsl/rake_executable.feature +1 -6
- data/features/step_definitions.rb +0 -12
- data/gemfiles/capistrano_v2.x.gemfile +7 -0
- data/gemfiles/capistrano_v2.x.gemfile.lock +66 -0
- data/gemfiles/rake_v0.9.3.gemfile +7 -0
- data/gemfiles/rake_v0.9.3.gemfile.lock +66 -0
- data/gemfiles/rake_v10.x.gemfile +7 -0
- data/gemfiles/rake_v10.x.gemfile.lock +66 -0
- data/lib/cape/capistrano.rb +39 -29
- data/lib/cape/version.rb +1 -1
- data/lib/cape/xterm.rb +1 -1
- data/spec/cape/capistrano_spec.rb +13 -3
- data/spec/cape/core_ext/hash_spec.rb +5 -5
- data/spec/cape/core_ext/symbol_spec.rb +10 -8
- data/spec/cape/deprecation/base_sharedspec.rb +6 -2
- data/spec/cape/deprecation/capistrano_deprecated_define_rake_wrapper_spec.rb +123 -101
- data/spec/cape/deprecation/dsl_deprecated_mirror_rake_tasks_spec.rb +119 -97
- data/spec/cape/dsl_deprecated_spec.rb +128 -134
- data/spec/cape/dsl_spec.rb +56 -63
- data/spec/cape/hash_list_spec.rb +40 -20
- data/spec/cape/rake_spec.rb +59 -51
- data/spec/cape/recipe_definition_spec.rb +44 -32
- data/spec/cape/util_spec.rb +18 -18
- data/spec/cape/version_spec.rb +1 -1
- data/spec/cape/xterm_spec.rb +33 -33
- data/spec/cape_spec.rb +9 -7
- data/spec/spec_helper.rb +5 -1
- metadata +100 -86
data/spec/cape/hash_list_spec.rb
CHANGED
@@ -2,49 +2,69 @@ require 'spec_helper'
|
|
2
2
|
require 'cape/hash_list'
|
3
3
|
|
4
4
|
describe Cape::HashList do
|
5
|
+
subject(:hash_list) { hash_list_class.new }
|
6
|
+
|
7
|
+
let(:hash_list_class) { described_class }
|
8
|
+
|
5
9
|
describe 'that is empty' do
|
6
|
-
|
10
|
+
specify { expect(hash_list).to be_empty }
|
7
11
|
|
8
|
-
|
12
|
+
describe '#inspect' do
|
13
|
+
specify { expect(hash_list.inspect).to eq('{}') }
|
14
|
+
end
|
9
15
|
|
10
|
-
|
16
|
+
describe '#to_a' do
|
17
|
+
specify { expect(hash_list.to_a).to eq([]) }
|
18
|
+
end
|
11
19
|
|
12
|
-
|
20
|
+
describe '#to_hash' do
|
21
|
+
specify { expect(hash_list.to_hash).to eq({}) }
|
22
|
+
end
|
13
23
|
|
14
24
|
describe 'when values are added out of order' do
|
15
25
|
before :each do
|
16
|
-
|
17
|
-
|
18
|
-
|
26
|
+
hash_list['foo'] = 'xxx'
|
27
|
+
hash_list['foo'] = 'bar'
|
28
|
+
hash_list['baz'] = 'qux'
|
19
29
|
end
|
20
30
|
|
21
|
-
|
31
|
+
specify { expect(hash_list).to eq({'foo' => 'bar', 'baz' => 'qux'}) }
|
22
32
|
|
23
|
-
|
33
|
+
describe '#inspect' do
|
34
|
+
specify {
|
35
|
+
expect(hash_list.inspect).to eq('{"foo"=>"bar", "baz"=>"qux"}')
|
36
|
+
}
|
37
|
+
end
|
24
38
|
|
25
|
-
|
39
|
+
describe '#to_a' do
|
40
|
+
specify { expect(hash_list.to_a).to eq([%w(foo bar), %w(baz qux)]) }
|
41
|
+
end
|
26
42
|
|
27
|
-
|
43
|
+
describe '#to_hash' do
|
44
|
+
specify {
|
45
|
+
expect(hash_list.to_hash).to eq({'foo' => 'bar', 'baz' => 'qux'})
|
46
|
+
}
|
47
|
+
end
|
28
48
|
end
|
29
49
|
end
|
30
50
|
|
31
51
|
describe 'that has values out of order' do
|
32
|
-
subject {
|
52
|
+
subject(:hash_list) { hash_list_class.new 'foo' => 'bar', 'baz' => 'qux' }
|
33
53
|
|
34
|
-
|
54
|
+
specify { expect(hash_list).to eq({'foo' => 'bar', 'baz' => 'qux'}) }
|
35
55
|
|
36
|
-
it '
|
37
|
-
|
38
|
-
|
39
|
-
|
56
|
+
it 'indexes the values as expected' do
|
57
|
+
expect(hash_list['foo']).to eq('bar')
|
58
|
+
expect(hash_list['baz']).to eq('qux')
|
59
|
+
expect(hash_list['not-found']).to be_nil
|
40
60
|
end
|
41
61
|
|
42
|
-
describe '
|
62
|
+
describe '#clear' do
|
43
63
|
before :each do
|
44
|
-
|
64
|
+
hash_list.clear
|
45
65
|
end
|
46
66
|
|
47
|
-
|
67
|
+
specify { expect(hash_list).to be_empty }
|
48
68
|
end
|
49
69
|
end
|
50
70
|
end
|
data/spec/cape/rake_spec.rb
CHANGED
@@ -2,52 +2,60 @@ require 'spec_helper'
|
|
2
2
|
require 'cape/rake'
|
3
3
|
|
4
4
|
describe Cape::Rake do
|
5
|
+
subject(:rake) { rake_class.new }
|
6
|
+
|
7
|
+
let(:rake_class) { described_class }
|
8
|
+
|
5
9
|
describe '::DEFAULT_EXECUTABLE' do
|
6
|
-
subject {
|
10
|
+
subject(:constant) { rake_class::DEFAULT_EXECUTABLE }
|
7
11
|
|
8
|
-
|
12
|
+
specify { expect(constant).to be_frozen }
|
9
13
|
end
|
10
14
|
|
11
|
-
describe '
|
12
|
-
it('
|
13
|
-
|
15
|
+
describe '#==' do
|
16
|
+
it('recognizes equivalent instances to be equal') {
|
17
|
+
expect(rake_class.new).to eq(rake_class.new)
|
14
18
|
}
|
15
19
|
|
16
|
-
it('
|
17
|
-
|
20
|
+
it('compares using #local_executable') {
|
21
|
+
expect(rake_class.new).not_to eq(rake_class.new(:local_executable => 'foo'))
|
18
22
|
}
|
19
23
|
|
20
|
-
it('
|
21
|
-
|
24
|
+
it('compares using #remote_executable') {
|
25
|
+
expect(rake_class.new).not_to eq(rake_class.new(:remote_executable => 'foo'))
|
22
26
|
}
|
23
27
|
end
|
24
28
|
|
25
29
|
describe '-- without specified attributes --' do
|
26
|
-
|
30
|
+
describe '#local_executable' do
|
31
|
+
specify { expect(rake.local_executable).to eq(rake_class::DEFAULT_EXECUTABLE) }
|
32
|
+
end
|
27
33
|
|
28
|
-
|
34
|
+
describe '#remote_executable' do
|
35
|
+
specify { expect(rake.remote_executable).to eq(rake_class::DEFAULT_EXECUTABLE) }
|
36
|
+
end
|
29
37
|
end
|
30
38
|
|
31
39
|
describe '-- with specified attributes --' do
|
32
|
-
subject {
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
40
|
+
subject(:rake) {
|
41
|
+
rake_class.new :local_executable => ('the specified value of ' +
|
42
|
+
'#local_executable'),
|
43
|
+
:remote_executable => ('the specified value of ' +
|
44
|
+
'#remote_executable')
|
37
45
|
}
|
38
46
|
|
39
|
-
|
40
|
-
|
41
|
-
|
47
|
+
describe '#local_executable' do
|
48
|
+
specify { expect(rake.local_executable).to eq('the specified value of #local_executable') }
|
49
|
+
end
|
42
50
|
|
43
|
-
|
44
|
-
|
45
|
-
|
51
|
+
describe '#remote_executable' do
|
52
|
+
specify { expect(rake.remote_executable).to eq('the specified value of #remote_executable') }
|
53
|
+
end
|
46
54
|
end
|
47
55
|
|
48
56
|
describe '-- with respect to caching --' do
|
49
57
|
before :each do
|
50
|
-
|
58
|
+
allow(rake).to receive(:fetch_output).and_return(output)
|
51
59
|
end
|
52
60
|
|
53
61
|
let(:output) {
|
@@ -58,63 +66,63 @@ rake baz # baz
|
|
58
66
|
end_output
|
59
67
|
}
|
60
68
|
|
61
|
-
describe '
|
62
|
-
it '
|
63
|
-
|
64
|
-
|
69
|
+
describe '#each_task' do
|
70
|
+
it 'builds and uses a cache' do
|
71
|
+
expect(rake).to receive(:fetch_output).once.and_return(output)
|
72
|
+
rake.each_task do |t|
|
65
73
|
end
|
66
|
-
|
74
|
+
rake.each_task do |t|
|
67
75
|
end
|
68
76
|
end
|
69
77
|
|
70
|
-
it '
|
71
|
-
|
72
|
-
|
78
|
+
it 'does not expire the cache' do
|
79
|
+
expect(rake).not_to receive(:expire_cache!)
|
80
|
+
rake.each_task do |t|
|
73
81
|
end
|
74
82
|
end
|
75
83
|
|
76
|
-
it '
|
77
|
-
|
84
|
+
it 'expires the cache in the event of an error' do
|
85
|
+
expect(rake).to receive(:expire_cache!).once
|
78
86
|
begin
|
79
|
-
|
87
|
+
rake.each_task do |t|
|
80
88
|
raise 'pow!'
|
81
89
|
end
|
82
90
|
rescue
|
83
91
|
end
|
84
92
|
end
|
85
93
|
|
86
|
-
it '
|
87
|
-
|
88
|
-
|
94
|
+
it 'does not swallow errors' do
|
95
|
+
expect {
|
96
|
+
rake.each_task do |t|
|
89
97
|
raise ZeroDivisionError, 'pow!'
|
90
98
|
end
|
91
|
-
}.
|
99
|
+
}.to raise_error(ZeroDivisionError, 'pow!')
|
92
100
|
end
|
93
101
|
end
|
94
102
|
|
95
|
-
describe '
|
96
|
-
it '
|
97
|
-
|
98
|
-
|
103
|
+
describe '#expire_cache!' do
|
104
|
+
it 'expires the cache' do
|
105
|
+
expect(rake).to receive(:fetch_output).twice.and_return(output)
|
106
|
+
rake.each_task do |t|
|
99
107
|
end
|
100
|
-
|
101
|
-
|
108
|
+
rake.expire_cache!
|
109
|
+
rake.each_task do |t|
|
102
110
|
end
|
103
111
|
end
|
104
112
|
end
|
105
113
|
|
106
|
-
describe '
|
114
|
+
describe '#local_executable=' do
|
107
115
|
describe 'with the same value,' do
|
108
|
-
it '
|
109
|
-
|
110
|
-
|
116
|
+
it 'does not expire the cache' do
|
117
|
+
expect(rake).not_to receive(:expire_cache!)
|
118
|
+
rake.local_executable = rake.local_executable
|
111
119
|
end
|
112
120
|
end
|
113
121
|
|
114
122
|
describe 'with a different value,' do
|
115
|
-
it '
|
116
|
-
|
117
|
-
|
123
|
+
it 'expires the cache' do
|
124
|
+
expect(rake).to receive(:expire_cache!).once
|
125
|
+
rake.local_executable = rake.local_executable + ' foo'
|
118
126
|
end
|
119
127
|
end
|
120
128
|
end
|
@@ -1,53 +1,65 @@
|
|
1
1
|
require 'cape/recipe_definition'
|
2
2
|
|
3
3
|
describe Cape::RecipeDefinition do
|
4
|
-
|
4
|
+
subject(:recipe_definition) { recipe_definition_class.new }
|
5
5
|
|
6
|
-
|
7
|
-
subject.cd '/foo/bar'
|
8
|
-
subject.cd.should == '/foo/bar'
|
6
|
+
let(:recipe_definition_class) { described_class }
|
9
7
|
|
10
|
-
|
11
|
-
|
8
|
+
describe '#cd' do
|
9
|
+
specify { expect(recipe_definition.cd).to be_nil }
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
it 'is mutable' do
|
12
|
+
recipe_definition.cd '/foo/bar'
|
13
|
+
expect(recipe_definition.cd).to eq('/foo/bar')
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
subject.cd do |foo, bar|
|
20
|
-
end
|
21
|
-
}.to raise_error(ArgumentError, 'Must have 0 parameters but has 2')
|
22
|
-
end
|
15
|
+
recipe_definition.cd lambda { '/foo/bar' }
|
16
|
+
expect(recipe_definition.cd.call).to eq('/foo/bar')
|
23
17
|
|
24
|
-
|
18
|
+
recipe_definition.cd { '/foo/bar' }
|
19
|
+
expect(recipe_definition.cd.call).to eq('/foo/bar')
|
20
|
+
end
|
25
21
|
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
it 'complains about wrong arity' do
|
23
|
+
expect {
|
24
|
+
recipe_definition.cd do |foo, bar|
|
25
|
+
end
|
26
|
+
}.to raise_error(ArgumentError, 'Must have 0 parameters but has 2')
|
27
|
+
end
|
29
28
|
end
|
30
29
|
|
31
|
-
|
30
|
+
describe '#env' do
|
31
|
+
specify { expect(recipe_definition.env).to eq({}) }
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
it 'is mutable' do
|
34
|
+
recipe_definition.env['FOO'] = 'bar'
|
35
|
+
expect(recipe_definition.env).to eq('FOO' => 'bar')
|
36
|
+
end
|
36
37
|
end
|
37
38
|
|
38
|
-
|
39
|
+
describe '#options' do
|
40
|
+
specify { expect(recipe_definition.options).to eq({}) }
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
it 'is mutable' do
|
43
|
+
recipe_definition.options[:some_option] = 'foo'
|
44
|
+
expect(recipe_definition.options).to eq(:some_option => 'foo')
|
43
45
|
end
|
44
|
-
subject.rename.call(:foo).should == 'foo_recipe'
|
45
46
|
end
|
46
47
|
|
47
|
-
|
48
|
-
expect
|
49
|
-
|
48
|
+
describe '#rename' do
|
49
|
+
specify { expect(recipe_definition.rename).to be_nil }
|
50
|
+
|
51
|
+
it 'is mutable' do
|
52
|
+
recipe_definition.rename do |task_name|
|
53
|
+
"#{task_name}_recipe"
|
50
54
|
end
|
51
|
-
|
55
|
+
expect(recipe_definition.rename.call(:foo)).to eq('foo_recipe')
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'complains about wrong arity' do
|
59
|
+
expect {
|
60
|
+
recipe_definition.rename do |foo, bar|
|
61
|
+
end
|
62
|
+
}.to raise_error(ArgumentError, 'Must have 1 parameter but has 2')
|
63
|
+
end
|
52
64
|
end
|
53
65
|
end
|
data/spec/cape/util_spec.rb
CHANGED
@@ -3,43 +3,43 @@ require 'cape/util'
|
|
3
3
|
|
4
4
|
describe Cape::Util do
|
5
5
|
describe '.pluralize' do
|
6
|
-
it "
|
7
|
-
Cape::Util.pluralize('foo').
|
6
|
+
it "transforms 'foo' as expected" do
|
7
|
+
expect(Cape::Util.pluralize('foo')).to eq('foos')
|
8
8
|
end
|
9
9
|
|
10
|
-
it "
|
11
|
-
Cape::Util.pluralize('foo', 2).
|
10
|
+
it "transforms 'foo' as expected for a count of 2" do
|
11
|
+
expect(Cape::Util.pluralize('foo', 2)).to eq('foos')
|
12
12
|
end
|
13
13
|
|
14
|
-
it "
|
15
|
-
Cape::Util.pluralize('foo', 1).
|
14
|
+
it "does not transform 'foo' for a count of 1" do
|
15
|
+
expect(Cape::Util.pluralize('foo', 1)).to eq('foo')
|
16
16
|
end
|
17
17
|
|
18
|
-
it "
|
19
|
-
Cape::Util.pluralize('foo', 0).
|
18
|
+
it "transforms 'foo' as expected for a count of 0" do
|
19
|
+
expect(Cape::Util.pluralize('foo', 0)).to eq('foos')
|
20
20
|
end
|
21
21
|
|
22
|
-
it "
|
23
|
-
Cape::Util.pluralize('foo', -1).
|
22
|
+
it "transforms 'foo' as expected for a count of -1" do
|
23
|
+
expect(Cape::Util.pluralize('foo', -1)).to eq('foos')
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe '.to_list_phrase' do
|
28
|
-
it '
|
29
|
-
Cape::Util.to_list_phrase([]).
|
28
|
+
it 'makes the expected phrase of an empty array' do
|
29
|
+
expect(Cape::Util.to_list_phrase([])).to eq('')
|
30
30
|
end
|
31
31
|
|
32
|
-
it '
|
33
|
-
Cape::Util.to_list_phrase(%w(foo)).
|
32
|
+
it 'makes the expected phrase of a 1-element array' do
|
33
|
+
expect(Cape::Util.to_list_phrase(%w(foo))).to eq('foo')
|
34
34
|
end
|
35
35
|
|
36
|
-
it '
|
37
|
-
Cape::Util.to_list_phrase(%w(foo bar)).
|
36
|
+
it 'makes the expected phrase of a 2-element array' do
|
37
|
+
expect(Cape::Util.to_list_phrase(%w(foo bar))).to eq('foo and bar')
|
38
38
|
end
|
39
39
|
|
40
|
-
it '
|
40
|
+
it 'makes the expected phrase of a 3-element array' do
|
41
41
|
array = %w(foo bar baz)
|
42
|
-
Cape::Util.to_list_phrase(array).
|
42
|
+
expect(Cape::Util.to_list_phrase(array)).to eq('foo, bar, and baz')
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
data/spec/cape/version_spec.rb
CHANGED
data/spec/cape/xterm_spec.rb
CHANGED
@@ -2,71 +2,71 @@ require 'spec_helper'
|
|
2
2
|
require 'cape/xterm'
|
3
3
|
|
4
4
|
describe Cape::XTerm do
|
5
|
+
let(:xterm_module) { described_class }
|
6
|
+
|
5
7
|
describe '.format' do
|
6
|
-
it '
|
7
|
-
|
8
|
+
it 'does not try to format a nil argument' do
|
9
|
+
expect(xterm_module.format(nil)).to be_nil
|
8
10
|
end
|
9
11
|
|
10
|
-
it '
|
11
|
-
|
12
|
+
it 'does not try to format a nil argument with a recognized format' do
|
13
|
+
expect(xterm_module.format(nil, :bold)).to be_nil
|
12
14
|
end
|
13
15
|
|
14
|
-
|
16
|
+
specify do
|
15
17
|
expect {
|
16
|
-
|
18
|
+
xterm_module.format nil, :this_does_not_exist
|
17
19
|
}.to raise_error(ArgumentError, 'Unrecognized format :this_does_not_exist')
|
20
|
+
end
|
21
|
+
|
22
|
+
specify do
|
18
23
|
expect {
|
19
|
-
|
24
|
+
xterm_module.format 'foo', :this_does_not_exist
|
20
25
|
}.to raise_error(ArgumentError, 'Unrecognized format :this_does_not_exist')
|
21
26
|
end
|
22
27
|
|
23
28
|
described_class::FORMATS.each do |format, code|
|
24
|
-
it "
|
25
|
-
|
29
|
+
it "formats a String argument with the #{format.inspect} format" do
|
30
|
+
expect(xterm_module.format('foo',
|
31
|
+
format)).to eq("\e[#{code}mfoo\e[0m")
|
26
32
|
end
|
27
33
|
end
|
28
34
|
|
29
|
-
it "
|
30
|
-
|
31
|
-
|
32
|
-
|
35
|
+
it "formats a String argument with the :bold and :foreground_red formats" do
|
36
|
+
expect(xterm_module.format('foo',
|
37
|
+
:bold,
|
38
|
+
:foreground_red)).to eq("\e[1;31mfoo\e[0m")
|
33
39
|
end
|
34
40
|
end
|
35
41
|
|
36
|
-
|
37
|
-
described_class.should_not respond_to(:this_does_not_exist)
|
38
|
-
end
|
42
|
+
specify { expect(xterm_module).not_to respond_to(:this_does_not_exist) }
|
39
43
|
|
40
|
-
|
44
|
+
specify do
|
41
45
|
expect {
|
42
|
-
|
46
|
+
xterm_module.this_does_not_exist
|
43
47
|
}.to raise_error(NoMethodError,
|
44
|
-
"undefined method `this_does_not_exist' for #{
|
48
|
+
"undefined method `this_does_not_exist' for #{xterm_module.name}:Module")
|
45
49
|
end
|
46
50
|
|
47
51
|
described_class::FORMATS.each do |format, code|
|
48
|
-
|
49
|
-
described_class.should respond_to(format)
|
50
|
-
end
|
52
|
+
specify { expect(xterm_module).to respond_to(format) }
|
51
53
|
|
52
54
|
describe ".#{format}" do
|
53
|
-
it "
|
54
|
-
|
55
|
-
|
56
|
-
|
55
|
+
it "formats a String argument with the #{format.inspect} format" do
|
56
|
+
expect(xterm_module.send(format,
|
57
|
+
'foo')).to eq(xterm_module.format('foo',
|
58
|
+
format))
|
57
59
|
end
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
61
|
-
|
62
|
-
described_class.should respond_to(:bold_and_foreground_red)
|
63
|
-
end
|
63
|
+
specify { expect(xterm_module).to respond_to(:bold_and_foreground_red) }
|
64
64
|
|
65
65
|
describe '.bold_and_foreground_red' do
|
66
|
-
it "
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
it "formats a String argument with the :bold and :foreground_red formats" do
|
67
|
+
expect(xterm_module.bold_and_foreground_red('foo')).to eq(xterm_module.format('foo',
|
68
|
+
:bold,
|
69
|
+
:foreground_red))
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|