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.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -1
  3. data/.rspec +1 -1
  4. data/.travis.yml +6 -2
  5. data/Appraisals +11 -0
  6. data/Gemfile +4 -4
  7. data/Guardfile +10 -4
  8. data/History.markdown +6 -0
  9. data/README.markdown +32 -17
  10. data/Rakefile +33 -13
  11. data/cape.gemspec +6 -2
  12. data/features/dsl/each_rake_task/unqualified.feature +0 -6
  13. data/features/dsl/each_rake_task/with_defined_namespace.feature +1 -1
  14. data/features/dsl/each_rake_task/with_defined_task.feature +4 -4
  15. data/features/dsl/each_rake_task/with_undefined_task_or_namespace.feature +2 -2
  16. data/features/dsl/mirror_rake_tasks/inside_capistrano_namespace.feature +3 -4
  17. data/features/dsl/mirror_rake_tasks/unqualified.feature +89 -32
  18. data/features/dsl/mirror_rake_tasks/with_cd.feature +18 -12
  19. data/features/dsl/mirror_rake_tasks/with_cd_and_environment_variables.feature +6 -4
  20. data/features/dsl/mirror_rake_tasks/with_defined_namespace.feature +7 -3
  21. data/features/dsl/mirror_rake_tasks/with_defined_task.feature +10 -8
  22. data/features/dsl/mirror_rake_tasks/with_defined_task_and_cd.feature +10 -8
  23. data/features/dsl/mirror_rake_tasks/with_defined_task_and_cd_and_environment_variables.feature +10 -8
  24. data/features/dsl/mirror_rake_tasks/with_defined_task_and_environment_variables.feature +21 -17
  25. data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename.feature +4 -2
  26. data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_cd.feature +4 -2
  27. data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_cd_and_environment_variables.feature +4 -2
  28. data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_environment_variables.feature +4 -2
  29. data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_valid_options.feature +4 -2
  30. data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_valid_options_and_cd.feature +4 -2
  31. data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_valid_options_and_cd_and_environment_variables.feature +4 -2
  32. data/features/dsl/mirror_rake_tasks/with_defined_task_and_rename_and_valid_options_and_environment_variables.feature +4 -2
  33. data/features/dsl/mirror_rake_tasks/with_defined_task_and_valid_options.feature +22 -18
  34. data/features/dsl/mirror_rake_tasks/with_defined_task_and_valid_options_and_cd.feature +10 -8
  35. data/features/dsl/mirror_rake_tasks/with_defined_task_and_valid_options_and_cd_and_environment_variables.feature +10 -8
  36. data/features/dsl/mirror_rake_tasks/with_defined_task_and_valid_options_and_environment_variables.feature +22 -18
  37. data/features/dsl/mirror_rake_tasks/with_environment_variables.feature +14 -10
  38. data/features/dsl/mirror_rake_tasks/with_rename.feature +3 -1
  39. data/features/dsl/mirror_rake_tasks/with_rename_and_cd.feature +3 -1
  40. data/features/dsl/mirror_rake_tasks/with_rename_and_cd_and_environment_variables.feature +3 -1
  41. data/features/dsl/mirror_rake_tasks/with_rename_and_environment_variables.feature +3 -1
  42. data/features/dsl/mirror_rake_tasks/with_rename_and_valid_options.feature +3 -1
  43. data/features/dsl/mirror_rake_tasks/with_rename_and_valid_options_and_cd.feature +3 -1
  44. data/features/dsl/mirror_rake_tasks/with_rename_and_valid_options_and_cd_and_environment_variables.feature +3 -1
  45. data/features/dsl/mirror_rake_tasks/with_rename_and_valid_options_and_environment_variables.feature +3 -1
  46. data/features/dsl/mirror_rake_tasks/with_undefined_task_or_namespace.feature +2 -2
  47. data/features/dsl/mirror_rake_tasks/with_valid_options.feature +12 -8
  48. data/features/dsl/mirror_rake_tasks/with_valid_options_and_cd.feature +6 -4
  49. data/features/dsl/mirror_rake_tasks/with_valid_options_and_cd_and_environment_variables.feature +6 -4
  50. data/features/dsl/mirror_rake_tasks/with_valid_options_and_environment_variables.feature +14 -10
  51. data/features/dsl/rake_executable.feature +1 -6
  52. data/features/step_definitions.rb +0 -12
  53. data/gemfiles/capistrano_v2.x.gemfile +7 -0
  54. data/gemfiles/capistrano_v2.x.gemfile.lock +66 -0
  55. data/gemfiles/rake_v0.9.3.gemfile +7 -0
  56. data/gemfiles/rake_v0.9.3.gemfile.lock +66 -0
  57. data/gemfiles/rake_v10.x.gemfile +7 -0
  58. data/gemfiles/rake_v10.x.gemfile.lock +66 -0
  59. data/lib/cape/capistrano.rb +39 -29
  60. data/lib/cape/version.rb +1 -1
  61. data/lib/cape/xterm.rb +1 -1
  62. data/spec/cape/capistrano_spec.rb +13 -3
  63. data/spec/cape/core_ext/hash_spec.rb +5 -5
  64. data/spec/cape/core_ext/symbol_spec.rb +10 -8
  65. data/spec/cape/deprecation/base_sharedspec.rb +6 -2
  66. data/spec/cape/deprecation/capistrano_deprecated_define_rake_wrapper_spec.rb +123 -101
  67. data/spec/cape/deprecation/dsl_deprecated_mirror_rake_tasks_spec.rb +119 -97
  68. data/spec/cape/dsl_deprecated_spec.rb +128 -134
  69. data/spec/cape/dsl_spec.rb +56 -63
  70. data/spec/cape/hash_list_spec.rb +40 -20
  71. data/spec/cape/rake_spec.rb +59 -51
  72. data/spec/cape/recipe_definition_spec.rb +44 -32
  73. data/spec/cape/util_spec.rb +18 -18
  74. data/spec/cape/version_spec.rb +1 -1
  75. data/spec/cape/xterm_spec.rb +33 -33
  76. data/spec/cape_spec.rb +9 -7
  77. data/spec/spec_helper.rb +5 -1
  78. metadata +100 -86
@@ -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
- it { should be_empty }
10
+ specify { expect(hash_list).to be_empty }
7
11
 
8
- its(:inspect) { should == '{}' }
12
+ describe '#inspect' do
13
+ specify { expect(hash_list.inspect).to eq('{}') }
14
+ end
9
15
 
10
- its(:to_a) { should == [] }
16
+ describe '#to_a' do
17
+ specify { expect(hash_list.to_a).to eq([]) }
18
+ end
11
19
 
12
- its(:to_hash) { should == {} }
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
- subject['foo'] = 'xxx'
17
- subject['foo'] = 'bar'
18
- subject['baz'] = 'qux'
26
+ hash_list['foo'] = 'xxx'
27
+ hash_list['foo'] = 'bar'
28
+ hash_list['baz'] = 'qux'
19
29
  end
20
30
 
21
- it { should == {'foo' => 'bar', 'baz' => 'qux'} }
31
+ specify { expect(hash_list).to eq({'foo' => 'bar', 'baz' => 'qux'}) }
22
32
 
23
- its(:inspect) { should == '{"foo"=>"bar", "baz"=>"qux"}' }
33
+ describe '#inspect' do
34
+ specify {
35
+ expect(hash_list.inspect).to eq('{"foo"=>"bar", "baz"=>"qux"}')
36
+ }
37
+ end
24
38
 
25
- its(:to_a) { should == [%w(foo bar), %w(baz qux)] }
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
- its(:to_hash) { should == {'foo' => 'bar', 'baz' => 'qux'} }
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 { described_class.new 'foo' => 'bar', 'baz' => 'qux' }
52
+ subject(:hash_list) { hash_list_class.new 'foo' => 'bar', 'baz' => 'qux' }
33
53
 
34
- it { should == {'foo' => 'bar', 'baz' => 'qux'} }
54
+ specify { expect(hash_list).to eq({'foo' => 'bar', 'baz' => 'qux'}) }
35
55
 
36
- it 'should index the values as expected' do
37
- subject['foo'].should == 'bar'
38
- subject['baz'].should == 'qux'
39
- subject['not-found'].should be_nil
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 'when sent #clear' do
62
+ describe '#clear' do
43
63
  before :each do
44
- subject.clear
64
+ hash_list.clear
45
65
  end
46
66
 
47
- it { should be_empty }
67
+ specify { expect(hash_list).to be_empty }
48
68
  end
49
69
  end
50
70
  end
@@ -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 { described_class::DEFAULT_EXECUTABLE }
10
+ subject(:constant) { rake_class::DEFAULT_EXECUTABLE }
7
11
 
8
- it { should be_frozen }
12
+ specify { expect(constant).to be_frozen }
9
13
  end
10
14
 
11
- describe '-- when sent #== --' do
12
- it('should recognize equivalent instances to be equal') {
13
- described_class.new.should == described_class.new
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('should compare using #local_executable') {
17
- described_class.new.should_not == described_class.new(:local_executable => 'foo')
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('should compare using #remote_executable') {
21
- described_class.new.should_not == described_class.new(:remote_executable => 'foo')
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
- its(:local_executable) { should == described_class::DEFAULT_EXECUTABLE }
30
+ describe '#local_executable' do
31
+ specify { expect(rake.local_executable).to eq(rake_class::DEFAULT_EXECUTABLE) }
32
+ end
27
33
 
28
- its(:remote_executable) { should == described_class::DEFAULT_EXECUTABLE }
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
- described_class.new :local_executable => ('the specified value of ' +
34
- '#local_executable'),
35
- :remote_executable => ('the specified value of ' +
36
- '#remote_executable')
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
- its(:local_executable) {
40
- should == 'the specified value of #local_executable'
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
- its(:remote_executable) {
44
- should == 'the specified value of #remote_executable'
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
- subject.stub!(:fetch_output).and_return output
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 'when sent #each_task,' do
62
- it 'should build and use a cache' do
63
- subject.should_receive(:fetch_output).once.and_return output
64
- subject.each_task do |t|
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
- subject.each_task do |t|
74
+ rake.each_task do |t|
67
75
  end
68
76
  end
69
77
 
70
- it 'should not expire the cache' do
71
- subject.should_not_receive :expire_cache!
72
- subject.each_task do |t|
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 'should expire the cache in the event of an error' do
77
- subject.should_receive(:expire_cache!).once
84
+ it 'expires the cache in the event of an error' do
85
+ expect(rake).to receive(:expire_cache!).once
78
86
  begin
79
- subject.each_task do |t|
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 'should not swallow errors' do
87
- lambda {
88
- subject.each_task do |t|
94
+ it 'does not swallow errors' do
95
+ expect {
96
+ rake.each_task do |t|
89
97
  raise ZeroDivisionError, 'pow!'
90
98
  end
91
- }.should raise_error(ZeroDivisionError, 'pow!')
99
+ }.to raise_error(ZeroDivisionError, 'pow!')
92
100
  end
93
101
  end
94
102
 
95
- describe 'when sent #expire_cache!,' do
96
- it 'should expire the cache' do
97
- subject.should_receive(:fetch_output).twice.and_return output
98
- subject.each_task do |t|
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
- subject.expire_cache!
101
- subject.each_task do |t|
108
+ rake.expire_cache!
109
+ rake.each_task do |t|
102
110
  end
103
111
  end
104
112
  end
105
113
 
106
- describe 'when sent #local_executable=' do
114
+ describe '#local_executable=' do
107
115
  describe 'with the same value,' do
108
- it 'should not expire the cache' do
109
- subject.should_not_receive :expire_cache!
110
- subject.local_executable = subject.local_executable
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 'should expire the cache' do
116
- subject.should_receive(:expire_cache!).once
117
- subject.local_executable = subject.local_executable + ' foo'
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
- its(:cd) { should be_nil }
4
+ subject(:recipe_definition) { recipe_definition_class.new }
5
5
 
6
- it 'should have a mutable #cd' do
7
- subject.cd '/foo/bar'
8
- subject.cd.should == '/foo/bar'
6
+ let(:recipe_definition_class) { described_class }
9
7
 
10
- subject.cd lambda { '/foo/bar' }
11
- subject.cd.call.should == '/foo/bar'
8
+ describe '#cd' do
9
+ specify { expect(recipe_definition.cd).to be_nil }
12
10
 
13
- subject.cd { '/foo/bar' }
14
- subject.cd.call.should == '/foo/bar'
15
- end
11
+ it 'is mutable' do
12
+ recipe_definition.cd '/foo/bar'
13
+ expect(recipe_definition.cd).to eq('/foo/bar')
16
14
 
17
- it 'should complain about a #cd with the wrong arity' do
18
- expect {
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
- its(:env) { should == {} }
18
+ recipe_definition.cd { '/foo/bar' }
19
+ expect(recipe_definition.cd.call).to eq('/foo/bar')
20
+ end
25
21
 
26
- it 'should have a mutable #env' do
27
- subject.env['FOO'] = 'bar'
28
- subject.env.should == {'FOO' => 'bar'}
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
- its(:options) { should == {} }
30
+ describe '#env' do
31
+ specify { expect(recipe_definition.env).to eq({}) }
32
32
 
33
- it 'should have mutable #options' do
34
- subject.options[:some_option] = 'foo'
35
- subject.options.should == {:some_option => 'foo'}
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
- its(:rename) { should be_nil }
39
+ describe '#options' do
40
+ specify { expect(recipe_definition.options).to eq({}) }
39
41
 
40
- it 'should have a mutable #rename' do
41
- subject.rename do |task_name|
42
- "#{task_name}_recipe"
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
- it 'should complain about a #rename with the wrong arity' do
48
- expect {
49
- subject.rename do |foo, bar|
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
- }.to raise_error(ArgumentError, 'Must have 1 parameter but has 2')
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
@@ -3,43 +3,43 @@ require 'cape/util'
3
3
 
4
4
  describe Cape::Util do
5
5
  describe '.pluralize' do
6
- it "should pluralize 'foo' as expected" do
7
- Cape::Util.pluralize('foo').should == 'foos'
6
+ it "transforms 'foo' as expected" do
7
+ expect(Cape::Util.pluralize('foo')).to eq('foos')
8
8
  end
9
9
 
10
- it "should pluralize 'foo' as expected for a count of 2" do
11
- Cape::Util.pluralize('foo', 2).should == 'foos'
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 "should not pluralize 'foo' for a count of 1" do
15
- Cape::Util.pluralize('foo', 1).should == 'foo'
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 "should pluralize 'foo' as expected for a count of 0" do
19
- Cape::Util.pluralize('foo', 0).should == 'foos'
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 "should pluralize 'foo' as expected for a count of -1" do
23
- Cape::Util.pluralize('foo', -1).should == 'foos'
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 'should make the expected list phrase of an empty array' do
29
- Cape::Util.to_list_phrase([]).should == ''
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 'should make the expected list phrase of a 1-element array' do
33
- Cape::Util.to_list_phrase(%w(foo)).should == '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 'should make the expected list phrase of a 2-element array' do
37
- Cape::Util.to_list_phrase(%w(foo bar)).should == 'foo and 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 'should make the expected list phrase of a 3-element array' do
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).should == 'foo, bar, and baz'
42
+ expect(Cape::Util.to_list_phrase(array)).to eq('foo, bar, and baz')
43
43
  end
44
44
  end
45
45
  end
@@ -2,5 +2,5 @@ require 'spec_helper'
2
2
  require 'cape/version'
3
3
 
4
4
  describe 'Cape::VERSION' do
5
- specify { Cape::VERSION.should =~ /^\d+\.\d+\.\d+/ }
5
+ specify { expect(Cape::VERSION).to match(/^\d+\.\d+\.\d+/) }
6
6
  end
@@ -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 'should not try to format a nil argument' do
7
- described_class.format(nil).should be_nil
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 'should not try to format a nil argument with a recognized format' do
11
- described_class.format(nil, :bold).should be_nil
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
- it 'should complain about an unrecognized format' do
16
+ specify do
15
17
  expect {
16
- described_class.format nil, :this_does_not_exist
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
- described_class.format 'foo', :this_does_not_exist
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 "should format a String argument with the #{format.inspect} format" do
25
- described_class.format('foo', format).should == "\e[#{code}mfoo\e[0m"
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 "should format a String argument with the :bold and :foreground_red formats" do
30
- described_class.format('foo',
31
- :bold,
32
- :foreground_red).should == "\e[1;31mfoo\e[0m"
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
- it 'should not respond to :this_does_not_exist' do
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
- it '.this_does_not_exist should complain' do
44
+ specify do
41
45
  expect {
42
- described_class.this_does_not_exist
46
+ xterm_module.this_does_not_exist
43
47
  }.to raise_error(NoMethodError,
44
- "undefined method `this_does_not_exist' for #{described_class.name}:Module")
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
- it "should respond to .#{format.inspect}" do
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 "should format a String argument with the #{format.inspect} format" do
54
- described_class.send(format,
55
- 'foo').should == described_class.format('foo',
56
- format)
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
- it 'should respond to .bold_and_foreground_red' do
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 "should format a String argument with the :bold and :foreground_red formats" do
67
- described_class.bold_and_foreground_red('foo').should == described_class.format('foo',
68
- :bold,
69
- :foreground_red)
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