rubycut-babushka 0.10.8 → 0.15.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. data/Gemfile +1 -0
  2. data/Gemfile.lock +17 -15
  3. data/README.markdown +163 -41
  4. data/Rakefile +1 -1
  5. data/bin/babushka +1 -1
  6. data/deps/apt.rb +44 -0
  7. data/deps/babushka.rb +54 -42
  8. data/deps/deprecated.rb +16 -0
  9. data/deps/dev.rb +28 -3
  10. data/deps/git.rb +27 -12
  11. data/deps/homebrew.rb +2 -2
  12. data/deps/packages.rb +14 -15
  13. data/deps/pkg_managers.rb +21 -75
  14. data/deps/ruby.rb +5 -19
  15. data/deps/rubygems.rb +3 -3
  16. data/deps/system.rb +2 -2
  17. data/deps/templates/app.rb +60 -41
  18. data/deps/templates/bin.rb +16 -0
  19. data/deps/templates/installer.rb +9 -9
  20. data/deps/templates/lib.rb +17 -0
  21. data/deps/templates/managed.rb +1 -38
  22. data/deps/templates/src.rb +16 -8
  23. data/deps/templates/task.rb +11 -0
  24. data/deps/templates/tmbundle.rb +16 -2
  25. data/lib/babushka.rb +2 -3
  26. data/lib/babushka/accepts_block_for.rb +5 -3
  27. data/lib/babushka/asset.rb +172 -0
  28. data/lib/babushka/base.rb +37 -8
  29. data/lib/babushka/bug_reporter.rb +6 -6
  30. data/lib/babushka/cmdline.rb +11 -10
  31. data/lib/babushka/cmdline/handler.rb +7 -3
  32. data/lib/babushka/cmdline/helpers.rb +15 -23
  33. data/lib/babushka/cmdline/parser.rb +1 -1
  34. data/lib/babushka/core_patches/object.rb +1 -1
  35. data/lib/babushka/core_patches/string.rb +8 -3
  36. data/lib/babushka/current_ruby.rb +44 -0
  37. data/lib/babushka/dep.rb +111 -185
  38. data/lib/babushka/dep_context.rb +8 -3
  39. data/lib/babushka/dep_definer.rb +45 -15
  40. data/lib/babushka/dep_pool.rb +5 -8
  41. data/lib/babushka/{meta_dep.rb → dep_template.rb} +21 -2
  42. data/lib/babushka/dsl.rb +3 -0
  43. data/lib/babushka/git_repo.rb +143 -49
  44. data/lib/babushka/helpers/git_helpers.rb +7 -6
  45. data/lib/babushka/helpers/log_helpers.rb +51 -13
  46. data/lib/babushka/helpers/path_helpers.rb +5 -7
  47. data/lib/babushka/helpers/run_helpers.rb +15 -55
  48. data/lib/babushka/helpers/shell_helpers.rb +18 -26
  49. data/lib/babushka/helpers/uri_helpers.rb +9 -18
  50. data/lib/babushka/lambda_chooser.rb +20 -13
  51. data/lib/babushka/parameter.rb +20 -4
  52. data/lib/babushka/path_checker.rb +72 -0
  53. data/lib/babushka/pkg_helper.rb +38 -13
  54. data/lib/babushka/pkg_helpers/apt_helper.rb +15 -8
  55. data/lib/babushka/pkg_helpers/binpkgsrc_helper.rb +15 -14
  56. data/lib/babushka/pkg_helpers/binports_helper.rb +7 -7
  57. data/lib/babushka/pkg_helpers/brew_helper.rb +17 -25
  58. data/lib/babushka/pkg_helpers/gem_helper.rb +36 -27
  59. data/lib/babushka/pkg_helpers/npm_helper.rb +9 -9
  60. data/lib/babushka/pkg_helpers/pacman_helper.rb +5 -4
  61. data/lib/babushka/pkg_helpers/pip_helper.rb +14 -10
  62. data/lib/babushka/pkg_helpers/unknown_pkg_helper.rb +19 -0
  63. data/lib/babushka/pkg_helpers/yum_helper.rb +1 -1
  64. data/lib/babushka/popen.rb +13 -10
  65. data/lib/babushka/prompt.rb +14 -1
  66. data/lib/babushka/renderable.rb +11 -9
  67. data/lib/babushka/resource.rb +5 -166
  68. data/lib/babushka/run_reporter.rb +12 -3
  69. data/lib/babushka/shell.rb +54 -44
  70. data/lib/babushka/source.rb +41 -20
  71. data/lib/babushka/source_pool.rb +20 -13
  72. data/lib/babushka/system_definitions.rb +11 -3
  73. data/lib/babushka/system_detector.rb +31 -0
  74. data/lib/babushka/system_matcher.rb +53 -0
  75. data/lib/babushka/system_profile.rb +67 -89
  76. data/lib/babushka/task.rb +36 -8
  77. data/lib/babushka/{meta_dep_context.rb → templated_dep_context.rb} +1 -1
  78. data/lib/babushka/vars.rb +46 -4
  79. data/lib/babushka/version_of.rb +35 -17
  80. data/lib/babushka/version_str.rb +12 -8
  81. data/lib/components.rb +9 -8
  82. data/lib/fancypath/fancypath.rb +109 -83
  83. data/lib/inkan/inkan.rb +14 -14
  84. data/lib/{babushka → levenshtein}/levenshtein.rb +0 -0
  85. data/spec/acceptance/acceptance.rb +4 -4
  86. data/spec/acceptance_helper.rb +10 -6
  87. data/spec/babushka/accepts_for_spec.rb +137 -142
  88. data/spec/babushka/accepts_for_support.rb +13 -6
  89. data/spec/babushka/asset_spec.rb +165 -0
  90. data/spec/babushka/cmdline/help_spec.rb +11 -9
  91. data/spec/babushka/cmdline/meet_spec.rb +15 -0
  92. data/spec/babushka/cmdline/version_spec.rb +1 -1
  93. data/spec/babushka/core_patches_spec.rb +9 -0
  94. data/spec/babushka/current_ruby_spec.rb +73 -0
  95. data/spec/babushka/dep_context_spec.rb +27 -13
  96. data/spec/babushka/dep_definer_spec.rb +108 -16
  97. data/spec/babushka/dep_spec.rb +87 -104
  98. data/spec/babushka/dep_template_spec.rb +176 -0
  99. data/spec/babushka/deps_spec.rb +48 -19
  100. data/spec/babushka/gem_helper_spec.rb +46 -59
  101. data/spec/babushka/git_repo_spec.rb +242 -51
  102. data/spec/babushka/ip_spec.rb +11 -11
  103. data/spec/babushka/lambda_chooser_spec.rb +47 -9
  104. data/spec/babushka/parameter_spec.rb +21 -0
  105. data/spec/babushka/path_checker_spec.rb +35 -0
  106. data/spec/babushka/path_helpers_spec.rb +51 -50
  107. data/spec/babushka/prompt_spec.rb +4 -4
  108. data/spec/babushka/renderable_spec.rb +61 -28
  109. data/spec/babushka/shell_helpers_spec.rb +110 -85
  110. data/spec/babushka/shell_spec.rb +15 -0
  111. data/spec/babushka/source_pool_spec.rb +204 -210
  112. data/spec/babushka/source_spec.rb +125 -42
  113. data/spec/babushka/source_support.rb +1 -1
  114. data/spec/babushka/system_profile_spec.rb +86 -49
  115. data/spec/babushka/task_spec.rb +80 -13
  116. data/spec/babushka/vars_spec.rb +2 -1
  117. data/spec/babushka/version_of_spec.rb +29 -2
  118. data/spec/babushka/version_str_spec.rb +91 -65
  119. data/spec/babushka/xml_string_spec.rb +1 -1
  120. data/spec/deps/bad/broken.rb +2 -2
  121. data/spec/deps/bad/working.rb +0 -1
  122. data/spec/deps/good/{meta.rb → template.rb} +0 -0
  123. data/spec/deps/good/test.rb +0 -3
  124. data/spec/deps/outer/deps.rb +0 -2
  125. data/spec/fancypath/fancypath_spec.rb +30 -0
  126. data/spec/inkan/inkan_spec.rb +34 -32
  127. data/spec/spec_helper.rb +7 -50
  128. data/spec/system_detector_spec.rb +70 -0
  129. metadata +163 -177
  130. data/deps/os_x.rb +0 -33
  131. data/deps/templates/ppa.rb +0 -24
  132. data/lib/babushka/core_patches/io.rb +0 -8
  133. data/lib/babushka/dep_runner.rb +0 -85
  134. data/lib/babushka/helpers/suggest_helpers.rb +0 -16
  135. data/lib/babushka/pkg_helpers/base_helper.rb +0 -19
  136. data/lib/babushka/pkg_helpers/macports_helper.rb +0 -22
  137. data/spec/babushka/dep_definer_support.rb +0 -36
  138. data/spec/babushka/meta_dep_definer_spec.rb +0 -127
  139. data/spec/babushka/meta_dep_wrapper_spec.rb +0 -32
  140. data/spec/babushka/resource_spec.rb +0 -141
  141. data/spec/babushka/run_helpers_spec.rb +0 -26
  142. data/spec/babushka/source_pool_support.rb +0 -31
@@ -2,7 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe Vars do
4
4
  before {
5
- Base.task.vars.define_var :username, :default => shell('whoami')
5
+ Base.task.process [], {} # a hack to assign Base.task.vars
6
+ Base.task.vars.define_var :username, :default => ShellHelpers.shell('whoami')
6
7
  Base.task.vars.define_var :domain, :default => :username
7
8
  Base.task.vars.define_var :db_name
8
9
  Base.task.vars.define_var :test_user, :default => :db_name
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  def version_of *args
4
- Babushka::VersionOf::Helpers.VersionOf *args
4
+ Babushka.VersionOf(*args)
5
5
  end
6
6
 
7
7
  describe "creation" do
@@ -25,6 +25,12 @@ describe "creation" do
25
25
  version_of(version_of('ruby', '1.8')).should == version_of('ruby', '1.8')
26
26
  version_of(version_of('ruby', '1.8'), '1.9').should == version_of('ruby', '1.9')
27
27
  end
28
+ it "should accept name with space" do
29
+ version_of('Google Chrome.app').name.should == 'Google Chrome.app'
30
+ version_of('Google Chrome.app').version.should == nil
31
+ end
32
+ # TODO: This is tricky, e.g. splitting "Sublime Text 2 >= 2.0.1".
33
+ # it "should accept name with space and version"
28
34
  end
29
35
 
30
36
  describe "to_s" do
@@ -39,9 +45,30 @@ describe "to_s" do
39
45
  end
40
46
  end
41
47
  describe "versioned" do
42
- it "should be separated with -" do
48
+ it "should be separated with - when no operator is specified" do
43
49
  version_of('ruby', '1.8').to_s.should == 'ruby-1.8'
44
50
  end
51
+ it "should be separated with - when the operator is ==" do
52
+ version_of('ruby', '== 1.8').to_s.should == 'ruby-1.8'
53
+ end
54
+ it "should be separated with - when no version is specified" do
55
+ version_of('ruby', '>= 1.8').to_s.should == 'ruby >= 1.8'
56
+ end
57
+ end
58
+ end
59
+
60
+ describe '#exact?' do
61
+ it "should be false when there is no version" do
62
+ version_of('ruby').should_not be_exact
63
+ end
64
+ it "should be true when there is a just version number" do
65
+ version_of('ruby', '1.8').should be_exact
66
+ end
67
+ it "should be true when the operator is ==" do
68
+ version_of('ruby', '== 1.8').should be_exact
69
+ end
70
+ it "should be false when the operator is not ==" do
71
+ version_of('ruby', '>= 1.8').should_not be_exact
45
72
  end
46
73
  end
47
74
 
@@ -1,56 +1,6 @@
1
1
  require 'spec_helper'
2
2
  require 'version_str_support'
3
3
 
4
- def compare_with operator
5
- pairs.zip(results[operator]).each {|pair,expected|
6
- result = VersionStr.new(pair.first).send operator, VersionStr.new(pair.last)
7
- it "#{pair.first} #{operator} #{pair.last}: #{result}" do
8
- result.should == expected
9
- end
10
- }
11
- end
12
-
13
- %w[== != > < >= <= ~>].each do |operator|
14
- describe operator do
15
- compare_with operator
16
- end
17
- end
18
-
19
- describe "comparing" do
20
- it "should work with other VersionStrs" do
21
- (VersionStr.new('0.3.1') > VersionStr.new('0.2.9')).should be_true
22
- end
23
-
24
- it "should work with strings" do
25
- (VersionStr.new('0.3.1') > '0.2.9').should be_true
26
- end
27
-
28
- it "should treat word pieces as less than no piece" do
29
- (VersionStr.new('3.0.0') > VersionStr.new('3.0.0.beta')).should be_true
30
- (VersionStr.new('3.0.0') > VersionStr.new('3.0.0.beta1')).should be_true
31
- (VersionStr.new('1.0.0') > VersionStr.new('1.0.0.rc.5')).should be_true
32
- end
33
-
34
- it "should compare word pieces alphabetically" do
35
- (VersionStr.new('3.0.0.beta') < VersionStr.new('3.0.0.pre')).should be_true
36
- (VersionStr.new('3.0.0.pre') < VersionStr.new('3.0.0.rc')).should be_true
37
- end
38
-
39
- it "should treat word pieces with a number as more than without one" do
40
- (VersionStr.new('3.0.0.beta1') > VersionStr.new('3.0.0.beta')).should be_true
41
- end
42
-
43
- it "should compare number parts of word pieces numerically" do
44
- (VersionStr.new('3.0.0.beta2') > VersionStr.new('3.0.0.beta1')).should be_true
45
- (VersionStr.new('3.0.0.beta10') > VersionStr.new('3.0.0.beta1')).should be_true
46
- end
47
-
48
- it "should allow for integers in strings and sort correctly" do
49
- (VersionStr.new('3.0.0.beta12') > VersionStr.new('3.0.0.beta2')).should be_true
50
- (VersionStr.new('R13B04') > VersionStr.new('R2B9')).should be_true
51
- end
52
- end
53
-
54
4
  describe "parsing" do
55
5
  it "should parse the version number" do
56
6
  VersionStr.new('0.2').pieces.should == [0, 2]
@@ -59,6 +9,7 @@ describe "parsing" do
59
9
  VersionStr.new('3.0.0.beta').pieces.should == [3, 0, 0, 'beta']
60
10
  VersionStr.new('3.0.0.beta3').pieces.should == [3, 0, 0, 'beta', 3]
61
11
  VersionStr.new('R13B04').pieces.should == ['R', 13, 'B', 4]
12
+ VersionStr.new('HEAD').pieces.should == ['HEAD']
62
13
  end
63
14
  it "should parse the operator if supplied" do
64
15
  v = VersionStr.new('>0.2')
@@ -91,23 +42,48 @@ describe "parsing" do
91
42
  v.pieces.should == [1, 9, 2, 'p', 180]
92
43
  v.operator.should == '>='
93
44
  end
94
- it "should reject invalid operators" do
95
- L{
96
- VersionStr.new('~ 0.2')
97
- }.should raise_error(InvalidVersionOperator, "VersionStr.new('~ 0.2'): invalid operator '~'.")
98
-
99
- L{
100
- VersionStr.new('>> 0.2')
101
- }.should raise_error(InvalidVersionOperator, "VersionStr.new('>> 0.2'): invalid operator '>>'.")
45
+ describe "invalid operators" do
46
+ it "should reject them" do
47
+ L{
48
+ VersionStr.new('~ 0.2')
49
+ }.should raise_error(InvalidVersionOperator, "VersionStr.new('~ 0.2'): invalid operator '~'.")
50
+ L{
51
+ VersionStr.new('>> 0.2')
52
+ }.should raise_error(InvalidVersionOperator, "VersionStr.new('>> 0.2'): invalid operator '>>'.")
53
+ end
54
+ end
55
+ describe "invalid version numbers" do
56
+ it "should reject version numbers that don't contain any digits" do
57
+ L{
58
+ VersionStr.new('nginx')
59
+ }.should raise_error(InvalidVersionStr, "VersionStr.new('nginx'): couldn't parse a version number.")
60
+ end
61
+ it "should reject numbers containing spaces" do
62
+ L{
63
+ VersionStr.new('0. 2')
64
+ }.should raise_error(InvalidVersionStr, "VersionStr.new('0. 2'): couldn't parse a version number.")
65
+ end
66
+ it "should reject numbers containing unexpected chars" do
67
+ L{
68
+ VersionStr.new('0.2!')
69
+ }.should raise_error(InvalidVersionStr, "VersionStr.new('0.2!'): couldn't parse a version number.")
70
+ end
102
71
  end
103
- it "should reject bad version numbers" do
104
- L{
105
- VersionStr.new('0. 2')
106
- }.should raise_error(InvalidVersionStr, "VersionStr.new('0. 2'): couldn't parse a version number.")
72
+ end
107
73
 
108
- L{
109
- VersionStr.new('0.2!')
110
- }.should raise_error(InvalidVersionStr, "VersionStr.new('0.2!'): couldn't parse a version number.")
74
+ describe '#parseable_version?' do
75
+ it 'should not report emptyness as parseable' do
76
+ VersionStr.parseable_version?(nil).should be_false
77
+ VersionStr.parseable_version?('').should be_false
78
+ VersionStr.parseable_version?(' ').should be_false
79
+ end
80
+ it "should not report digitless input as parseable" do
81
+ VersionStr.parseable_version?('nginx').should be_false
82
+ end
83
+ it "should not report input with digits as parseable" do
84
+ VersionStr.parseable_version?('3').should be_true
85
+ VersionStr.parseable_version?('R13B04').should be_true
86
+ VersionStr.parseable_version?('1.9.3-p0').should be_true
111
87
  end
112
88
  end
113
89
 
@@ -128,3 +104,53 @@ describe 'rendering' do
128
104
  VersionStr.new('3.0.0-beta').to_s.should == '3.0.0-beta'
129
105
  end
130
106
  end
107
+
108
+ def compare_with operator
109
+ pairs.zip(results[operator]).each {|pair,expected|
110
+ result = VersionStr.new(pair.first).send operator, VersionStr.new(pair.last)
111
+ it "#{pair.first} #{operator} #{pair.last}: #{result}" do
112
+ result.should == expected
113
+ end
114
+ }
115
+ end
116
+
117
+ %w[== != > < >= <= ~>].each do |operator|
118
+ describe operator do
119
+ compare_with operator
120
+ end
121
+ end
122
+
123
+ describe "comparing" do
124
+ it "should work with other VersionStrs" do
125
+ (VersionStr.new('0.3.1') > VersionStr.new('0.2.9')).should be_true
126
+ end
127
+
128
+ it "should work with strings" do
129
+ (VersionStr.new('0.3.1') > '0.2.9').should be_true
130
+ end
131
+
132
+ it "should treat word pieces as less than no piece" do
133
+ (VersionStr.new('3.0.0') > VersionStr.new('3.0.0.beta')).should be_true
134
+ (VersionStr.new('3.0.0') > VersionStr.new('3.0.0.beta1')).should be_true
135
+ (VersionStr.new('1.0.0') > VersionStr.new('1.0.0.rc.5')).should be_true
136
+ end
137
+
138
+ it "should compare word pieces alphabetically" do
139
+ (VersionStr.new('3.0.0.beta') < VersionStr.new('3.0.0.pre')).should be_true
140
+ (VersionStr.new('3.0.0.pre') < VersionStr.new('3.0.0.rc')).should be_true
141
+ end
142
+
143
+ it "should treat word pieces with a number as more than without one" do
144
+ (VersionStr.new('3.0.0.beta1') > VersionStr.new('3.0.0.beta')).should be_true
145
+ end
146
+
147
+ it "should compare number parts of word pieces numerically" do
148
+ (VersionStr.new('3.0.0.beta2') > VersionStr.new('3.0.0.beta1')).should be_true
149
+ (VersionStr.new('3.0.0.beta10') > VersionStr.new('3.0.0.beta1')).should be_true
150
+ end
151
+
152
+ it "should allow for integers in strings and sort correctly" do
153
+ (VersionStr.new('3.0.0.beta12') > VersionStr.new('3.0.0.beta2')).should be_true
154
+ (VersionStr.new('R13B04') > VersionStr.new('R2B9')).should be_true
155
+ end
156
+ end
@@ -95,4 +95,4 @@ def sample_xml
95
95
  </dict>
96
96
  </plist>
97
97
  }
98
- end
98
+ end
@@ -1,7 +1,7 @@
1
1
  dep 'broken test dep 1' do
2
- syntax error
3
2
  end
4
3
 
4
+ syntax } error
5
+
5
6
  dep 'test dep 2' do
6
-
7
7
  end
@@ -1,3 +1,2 @@
1
1
  dep 'test dep 1' do
2
-
3
2
  end
File without changes
@@ -1,11 +1,8 @@
1
1
  meta 'test_meta_1' do
2
-
3
2
  end
4
3
 
5
4
  dep 'test dep 1' do
6
-
7
5
  end
8
6
 
9
7
  dep 'test dep 2' do
10
-
11
8
  end
@@ -1,9 +1,7 @@
1
1
  dep 'test dep 1' do
2
-
3
2
  end
4
3
 
5
4
  dep 'externally templated', :template => 'nested source:test_template' do
6
-
7
5
  end
8
6
 
9
7
  meta 'local_template' do
@@ -111,6 +111,36 @@ describe Fancypath do
111
111
  it('removes directory') { @dir.create.remove.should_not exist }
112
112
  end
113
113
 
114
+ describe "#grep" do
115
+ before {
116
+ @file.write("some\ncontent\ncontentedness")
117
+ }
118
+ it("returns nil when the file doesn't exist") {
119
+ (@dir / 'missing').grep(/test/).should be_nil
120
+ }
121
+ it('returns nil on no match') {
122
+ @file.grep(/test/).should be_nil
123
+ }
124
+ it('returns the matches with string parameter') {
125
+ @file.grep("content").should == ['content']
126
+ }
127
+ it('returns the matches with regexp parameter') {
128
+ @file.grep(/cont/).should == ['content', 'contentedness']
129
+ }
130
+ end
131
+
132
+ describe "#yaml" do
133
+ before {
134
+ @file.write("
135
+ guise:
136
+ seriously: guise
137
+ ")
138
+ }
139
+ it('returns the file contents as yaml') {
140
+ @file.yaml.should == {'guise' => {'seriously' => 'guise'}}
141
+ }
142
+ end
143
+
114
144
  describe '#readlink' do
115
145
  before {
116
146
  @file.touch
@@ -1,5 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
+ require 'digest/sha1'
4
+
3
5
  describe "Inkan" do
4
6
  describe '.legitimate?' do
5
7
  context "without a hashbang" do
@@ -63,13 +65,13 @@ describe "Inkan" do
63
65
  end
64
66
  end
65
67
  end
66
-
68
+
67
69
  describe '.seal' do
68
70
  it "should write the file after closing the block" do
69
71
  Inkan.seal('/tmp/spec.txt') do |inkan|
70
72
  inkan.print 'foo bar baz'
71
73
  end
72
-
74
+
73
75
  contents = open('/tmp/spec.txt').read
74
76
  contents.should match(/foo bar baz$/)
75
77
  contents.should match(/^# Generated by Inkan/)
@@ -81,49 +83,49 @@ describe "Inkan" do
81
83
  result = Inkan.render do |inkan|
82
84
  inkan.print 'foo bar baz'
83
85
  end
84
-
86
+
85
87
  result.should match(/foo bar baz$/)
86
88
  result.should match(/^# Generated by Inkan/)
87
89
  end
88
90
  end
89
-
91
+
90
92
  describe '#seal' do
91
93
  let(:inkan) { Inkan.new('/tmp/spec.txt') }
92
-
94
+
93
95
  it "writes out the contents of the buffer" do
94
96
  inkan.print "foo bar baz"
95
97
  inkan.seal
96
-
98
+
97
99
  open('/tmp/spec.txt').read.should match(/foo bar baz$/)
98
100
  end
99
-
101
+
100
102
  it "adds the credit line to the top of the file" do
101
103
  inkan.print "foo bar baz"
102
104
  inkan.seal
103
-
105
+
104
106
  open('/tmp/spec.txt').read.should match(/^# Generated by Inkan/)
105
107
  end
106
-
108
+
107
109
  it "adds the SHA to the top of the file" do
108
110
  inkan.print "foo bar baz"
109
111
  inkan.seal
110
-
112
+
111
113
  sha = Digest::SHA1.hexdigest("foo bar baz")
112
-
114
+
113
115
  open('/tmp/spec.txt').read.should match(/#{sha}/)
114
116
  end
115
117
  end
116
118
 
117
119
  describe '#render' do
118
120
  let(:inkan) { Inkan.new(nil) }
119
-
120
- before { shell "rm -f /tmp/spec.txt" }
121
-
121
+
122
+ before { ShellHelpers.shell "rm -f /tmp/spec.txt" }
123
+
122
124
  it "writes out the contents of the buffer" do
123
125
  inkan.print "foo bar baz"
124
126
  inkan.render.should match(/foo bar baz$/)
125
127
  end
126
-
128
+
127
129
  context "when there is no hashbang" do
128
130
  before { inkan.print "foo bar baz" }
129
131
  it "adds the credit line to the top of the output" do
@@ -134,7 +136,7 @@ describe "Inkan" do
134
136
  inkan.render.split("\n").first.should match(/#{sha}/)
135
137
  end
136
138
  end
137
-
139
+
138
140
  context "when there is a hashbang" do
139
141
  before { inkan.print "#!/bin/sh\nfoo bar baz" }
140
142
  it "leaves the hashbang at the top of the file" do
@@ -148,69 +150,69 @@ describe "Inkan" do
148
150
  inkan.render.split("\n")[1].should match(/#{sha}/)
149
151
  end
150
152
  end
151
-
153
+
152
154
  it "doesn't write the file" do
153
155
  inkan.print "foo bar baz"
154
156
  inkan.render
155
157
  File.exists?('/tmp/spec.txt').should be_false
156
158
  end
157
159
  end
158
-
160
+
159
161
  describe '#puts' do
160
162
  let(:inkan) { Inkan.new('/tmp/spec.txt') }
161
-
163
+
162
164
  it "adds an extra new line to the output" do
163
165
  inkan.puts "foo bar baz"
164
166
  inkan.seal
165
-
167
+
166
168
  open('/tmp/spec.txt').read.should match(/foo bar baz\n$/)
167
169
  end
168
170
  end
169
-
171
+
170
172
  describe '#credit' do
171
173
  let(:inkan) { Inkan.new('/tmp/spec.txt') }
172
-
174
+
173
175
  it "defaults to 'Generated by Inkan'" do
174
176
  inkan.credit.should == 'Generated by Inkan'
175
177
  end
176
-
178
+
177
179
  it "should pass through changes to the file comment" do
178
180
  inkan.credit = "Pat's Magic Code"
179
181
  inkan.print "foo bar baz"
180
182
  inkan.seal
181
-
183
+
182
184
  open('/tmp/spec.txt').read.should match(/^# Pat's Magic Code/)
183
185
  end
184
186
  end
185
-
187
+
186
188
  describe '#comment' do
187
189
  let(:inkan) { Inkan.new('/tmp/spec.txt') }
188
-
190
+
189
191
  it "defaults to a hash symbol" do
190
192
  inkan.comment.should == '#'
191
193
  end
192
-
194
+
193
195
  it "should pass through changes to the file credit" do
194
196
  inkan.comment = "//"
195
197
  inkan.print "foo bar baz"
196
198
  inkan.seal
197
-
199
+
198
200
  open('/tmp/spec.txt').read.should match(/^\/\/ Generated by Inkan/)
199
201
  end
200
202
  end
201
-
203
+
202
204
  describe '#comment_suffix' do
203
205
  let(:inkan) { Inkan.new('/tmp/spec.txt') }
204
-
206
+
205
207
  it "defaults to a blank string" do
206
208
  inkan.comment_suffix.should == ''
207
209
  end
208
-
210
+
209
211
  it "should pass through changes to the file comment" do
210
212
  inkan.comment_suffix = "*/"
211
213
  inkan.print "foo bar baz"
212
214
  inkan.seal
213
-
215
+
214
216
  open('/tmp/spec.txt').read.should match(/\*\/\n/)
215
217
  end
216
218
  end