nkryptic-sandbox 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -44,31 +44,28 @@ should be reset when you deactivate the sandbox.
44
44
 
45
45
  == USAGE:
46
46
 
47
- Create a new sandbox (rake gem installed by default):
47
+ Create a new sandbox (verbose output by default):
48
48
  $ cd ~/ruby-projects
49
49
  $ sandbox my-new-sandbox
50
-
51
- Create a new sandbox with output (rake gem installed by default):
52
- $ cd ~/ruby-projects
53
- $ sandbox my-new-sandbox -v
54
50
  creating new sandbox in /home/nkryptic/ruby-projects/my-new-sandbox
51
+ installing activation script
52
+ installing .gemrc
55
53
  installing gems:
56
- gem: rake
54
+ nothing to do
57
55
 
58
- Create a new sandbox with no gems installed:
56
+ Create a new sandbox with no output:
59
57
  $ cd ~/ruby-projects
60
- $ sandbox my-new-sandbox -n
61
- creating new sandbox in /home/nkryptic/ruby-projects/my-new-sandbox
62
- installing gems:
58
+ $ sandbox my-new-sandbox -q
63
59
 
64
60
  Create a new sandbox with specific gems:
65
61
  $ cd ~/ruby-projects
66
62
  $ sandbox my-new-sandbox -g rake,rails
67
63
  creating new sandbox in /home/nkryptic/ruby-projects/my-new-sandbox
64
+ installing activation script
65
+ installing .gemrc
68
66
  installing gems:
69
67
  gem: rake
70
68
  gem: rails
71
- gem: rspec
72
69
 
73
70
  == FUTURE PLANS:
74
71
 
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
-
3
+
4
4
  require 'lib/sandbox' unless defined? Sandbox
5
5
 
6
6
  begin
data/TODO CHANGED
@@ -1,7 +1,4 @@
1
1
  TODO: fix dependencies in rake files
2
- TODO: add 'gem: --no-ri --no-rdoc' to .gemrc in new sandbox
3
- TODO: do 'gem sources -a http://gems.github.com'
4
- TODO: 0 gems initially to be installed
5
2
  TODO: put in timeout when installing gems
6
3
  TODO: check for network connection
7
4
  TODO: perhaps look in installed rubygems cache first
@@ -28,7 +25,6 @@ TODO: better documentation
28
25
  TODO: improve ui output
29
26
  * use verbosity level
30
27
  * include more messages about status
31
- * move to ui class?
32
28
  TODO: user config
33
29
  * set list of ruby variants to query?
34
30
  * list of gems to install
data/lib/sandbox.rb CHANGED
@@ -19,7 +19,7 @@ module Sandbox
19
19
  end
20
20
 
21
21
  def quiet?() verbosity < 0 end
22
- def really_quiet?() verbosity < 1 end
22
+ def really_quiet?() verbosity < -1 end
23
23
  def verbose?() verbosity > 0 end
24
24
  def really_verbose?() verbosity > 1 end
25
25
 
@@ -29,5 +29,6 @@ end
29
29
 
30
30
  require 'sandbox/version'
31
31
  require 'sandbox/errors'
32
+ require 'sandbox/output'
32
33
  require 'sandbox/installer'
33
34
 
data/lib/sandbox/cli.rb CHANGED
@@ -4,9 +4,12 @@ require 'sandbox'
4
4
 
5
5
  module Sandbox
6
6
  class CLI
7
+ include Sandbox::Output
8
+ extend Sandbox::Output
7
9
 
8
10
  DEFAULTS = {
9
- :gems => [ 'rake', ]
11
+ # :gems => [ 'rake', ]
12
+ :gems => []
10
13
  }
11
14
 
12
15
  ## CLASS METHODS
@@ -37,13 +40,12 @@ module Sandbox
37
40
  def handle_error( error )
38
41
  case error
39
42
  when Sandbox::Error
40
- puts error.message
43
+ tell_unless_really_quiet( error.message )
41
44
  when StandardError #, Timeout::Error
42
- message = [ "Error: #{error.message}" ]
43
- message.concat( error.backtrace.collect { |bt| " #{bt}" } ) if Sandbox.really_verbose?
44
- puts message.join( "\n" )
45
+ tell_unless_really_quiet( "Error: #{error.message}" )
46
+ tell_when_really_verbose( error.backtrace.collect { |bt| " #{bt}" }.join( "\n" ) ) if error.backtrace
45
47
  when Interrupt
46
- puts "Interrupted"
48
+ tell_unless_really_quiet( "Interrupted" )
47
49
  else
48
50
  raise error
49
51
  end
@@ -111,19 +113,19 @@ module Sandbox
111
113
  o.separator ""
112
114
 
113
115
  o.separator "OPTIONS"
114
- o.on( '-g', '--gems gem1,gem2', Array, 'Gems to install after sandbox is created. (defaults to [rake])' ) { |gems| @options[ :gems ] = gems }
115
- o.on( '-n', '--no-gems', 'Do not install any gems after sandbox is created.)' ) { @options[ :gems ] = [] }
116
+ o.on( '-g', '--gems gem1,gem2', Array, 'Gems to install after sandbox is created.' ) { |gems| @options[ :gems ] = gems }
117
+ o.on( '-n', '--no-gems', 'Do not install any gems after sandbox is created.' ) { @options[ :gems ] = [] }
116
118
  o.on( '-q', '--quiet', 'Show less output. (multiple allowed)' ) { |f| Sandbox.decrease_verbosity }
117
119
  o.on( '-v', '--verbose', 'Show more output. (multiple allowed)' ) { |f| Sandbox.increase_verbosity }
118
- o.on_tail( '-h', '--help', 'Show this help message and exit.' ) { puts o; exit }
119
- o.on_tail( '-H', '--long-help', 'Show the full description about the program' ) { puts long_help; exit }
120
- o.on_tail( '-V', '--version', 'Display the program version and exit.' ) { puts Sandbox::Version::STRING; exit }
120
+ o.on_tail( '-h', '--help', 'Show this help message and exit.' ) { tell_unless_really_quiet( o ); exit }
121
+ o.on_tail( '-H', '--long-help', 'Show the full description about the program' ) { tell_unless_really_quiet( long_help ); exit }
122
+ o.on_tail( '-V', '--version', 'Display the program version and exit.' ) { tell_unless_really_quiet( Sandbox::Version::STRING ); exit }
121
123
  o.separator ""
122
124
  end
123
125
  end
124
126
 
125
127
  # def show_help
126
- # puts parser
128
+ # tell( parser )
127
129
  # end
128
130
 
129
131
  def long_help
@@ -1,10 +1,14 @@
1
1
 
2
2
  require 'fileutils'
3
+ # require 'ping'
4
+ # require 'timeout'
3
5
  require 'erb'
4
6
 
5
7
  module Sandbox
6
8
 
7
9
  class Installer
10
+ include Sandbox::Output
11
+ extend Sandbox::Output
8
12
 
9
13
  ## CLASS METHODS
10
14
  class << self
@@ -27,9 +31,13 @@ module Sandbox
27
31
  end
28
32
 
29
33
  def populate
30
- puts "creating sandbox at: #{target}" if Sandbox.verbose?
34
+ tell( "creating sandbox at: #{target}" )
31
35
  create_directories
36
+ tell( "installing activation script" )
32
37
  install_scripts
38
+ tell( "installing .gemrc" )
39
+ install_gemrc
40
+ tell( "installing gems" )
33
41
  install_gems
34
42
  end
35
43
 
@@ -48,6 +56,16 @@ module Sandbox
48
56
  FileUtils.ln_s( gembin, bin )
49
57
  end
50
58
 
59
+ def install_gemrc
60
+ filename = File.join( target, '.gemrc' )
61
+ template = File.read( File.dirname( __FILE__ ) + '/templates/gemrc.erb' )
62
+ script = ERB.new( template )
63
+ output = script.result( binding )
64
+ File.open( filename, 'w' ) do |f|
65
+ f.write output
66
+ end
67
+ end
68
+
51
69
  def install_scripts
52
70
  filename = File.join( target, 'bin', 'activate_sandbox' )
53
71
  template = File.read( File.dirname( __FILE__ ) + '/templates/activate_sandbox.erb' )
@@ -61,16 +79,21 @@ module Sandbox
61
79
  def install_gems
62
80
  # gem = `which gem`.chomp
63
81
  # return if gem.empty?
64
- puts "installing gems" if Sandbox.verbose?
82
+ gems = options[ :gems ] || []
83
+ if gems.size == 0
84
+ tell( " nothing to install" )
85
+ return
86
+ end
87
+
65
88
  begin
66
89
  setup_sandbox_env
67
- options[ :gems ].each do |gem|
68
- puts " gem: #{gem}" if Sandbox.verbose?
90
+ gems.each do |gem|
91
+ tell_unless_really_quiet( " gem: #{gem}" )
69
92
  cmd = "gem install #{gem}"
70
93
  # cmd = cmd + ' -V' if Sandbox.really_verbose?
71
94
  status, output = shell_out( cmd )
72
95
  unless status
73
- warn "failed to install gem: #{gem}"
96
+ tell_unless_really_quiet( " failed to install gem: #{gem}" )
74
97
  end
75
98
  end
76
99
  ensure
@@ -0,0 +1,26 @@
1
+
2
+ module Sandbox
3
+ module Output
4
+
5
+ def tell( msg )
6
+ tell_unless_quiet( msg )
7
+ end
8
+
9
+ def tell_when_verbose( msg )
10
+ puts msg if Sandbox.verbose?
11
+ end
12
+
13
+ def tell_when_really_verbose( msg )
14
+ puts msg if Sandbox.really_verbose?
15
+ end
16
+
17
+ def tell_unless_quiet( msg )
18
+ puts msg unless Sandbox.quiet?
19
+ end
20
+
21
+ def tell_unless_really_quiet( msg )
22
+ puts msg unless Sandbox.really_quiet?
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,10 @@
1
+ ---
2
+ :benchmark: false
3
+ :update_sources: true
4
+ :bulk_threshold: 1000
5
+ :verbose: true
6
+ :backtrace: false
7
+ :sources:
8
+ - http://gems.rubyforge.org/
9
+ - http://gems.github.com
10
+ gem: --no-ri --no-rdoc
@@ -5,7 +5,7 @@ module Sandbox
5
5
 
6
6
  MAJOR = 0
7
7
  MINOR = 2
8
- TINY = 2
8
+ TINY = 3
9
9
 
10
10
  STRING = [ MAJOR, MINOR, TINY ].join( '.' )
11
11
 
data/sandbox.gemspec CHANGED
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{sandbox}
5
- s.version = "0.2.2"
5
+ s.version = "0.2.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jacob Radford"]
9
- s.date = %q{2008-12-06}
9
+ s.date = %q{2008-12-07}
10
10
  s.default_executable = %q{sandbox}
11
11
  s.description = %q{Create virtual ruby/rubygems sandboxes.}
12
12
  s.email = %q{nkryptic@gmail.com}
13
13
  s.executables = ["sandbox"]
14
- s.extra_rdoc_files = ["CHANGELOG", "TODO", "README.rdoc", "tasks/rspec.rake", "tasks/cucumber.rake", "tasks/gem.rake", "tasks/dcov.rake", "lib/sandbox.rb", "lib/sandbox/installer.rb", "lib/sandbox/cli.rb", "lib/sandbox/templates/activate_sandbox.erb", "lib/sandbox/version.rb", "lib/sandbox/errors.rb", "bin/sandbox"]
15
- s.files = ["sandbox.gemspec", "CHANGELOG", "TODO", "spec/sandbox/errors_spec.rb", "spec/sandbox/cli_spec.rb", "spec/sandbox/installer_spec.rb", "spec/sandbox_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "Manifest", "features/steps/common.rb", "features/steps/env.rb", "features/development.feature", "README.rdoc", "tasks/rspec.rake", "tasks/cucumber.rake", "tasks/gem.rake", "tasks/dcov.rake", "Rakefile", "lib/sandbox.rb", "lib/sandbox/installer.rb", "lib/sandbox/cli.rb", "lib/sandbox/templates/activate_sandbox.erb", "lib/sandbox/version.rb", "lib/sandbox/errors.rb", "bin/sandbox"]
14
+ s.extra_rdoc_files = ["CHANGELOG", "TODO", "README.rdoc", "tasks/rspec.rake", "tasks/cucumber.rake", "tasks/gem.rake", "tasks/dcov.rake", "lib/sandbox.rb", "lib/sandbox/installer.rb", "lib/sandbox/cli.rb", "lib/sandbox/templates/gemrc.erb", "lib/sandbox/templates/activate_sandbox.erb", "lib/sandbox/version.rb", "lib/sandbox/errors.rb", "lib/sandbox/output.rb", "bin/sandbox"]
15
+ s.files = ["sandbox.gemspec", "CHANGELOG", "TODO", "spec/sandbox/errors_spec.rb", "spec/sandbox/cli_spec.rb", "spec/sandbox/output_spec.rb", "spec/sandbox/installer_spec.rb", "spec/sandbox_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "Manifest", "features/steps/common.rb", "features/steps/env.rb", "features/development.feature", "README.rdoc", "tasks/rspec.rake", "tasks/cucumber.rake", "tasks/gem.rake", "tasks/dcov.rake", "Rakefile", "lib/sandbox.rb", "lib/sandbox/installer.rb", "lib/sandbox/cli.rb", "lib/sandbox/templates/gemrc.erb", "lib/sandbox/templates/activate_sandbox.erb", "lib/sandbox/version.rb", "lib/sandbox/errors.rb", "lib/sandbox/output.rb", "bin/sandbox"]
16
16
  s.has_rdoc = true
17
17
  s.homepage = %q{http://github.com/nkryptic/sandbox}
18
18
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Sandbox", "--main", "README.rdoc"]
@@ -50,19 +50,19 @@ describe Sandbox::CLI do
50
50
  describe "handling errors" do
51
51
  it "should just print Sandbox::Error message" do
52
52
  err = Sandbox::Error.new( "spec test msg" )
53
- Sandbox::CLI.expects( :puts ).once.with( regexp_matches( /^Sandbox error: spec test msg/ ) )
53
+ Sandbox::CLI.expects( :tell_unless_really_quiet ).once.with( regexp_matches( /^Sandbox error: spec test msg/ ) )
54
54
  Sandbox::CLI.handle_error( err )
55
55
  end
56
56
 
57
57
  it "should just print wrapped StandardError message" do
58
58
  err = StandardError.new( "spec test msg" )
59
- Sandbox::CLI.expects( :puts ).once.with( regexp_matches( /^Error: spec test msg/ ) )
59
+ Sandbox::CLI.expects( :tell_unless_really_quiet ).once.with( regexp_matches( /^Error: spec test msg/ ) )
60
60
  Sandbox::CLI.handle_error( err )
61
61
  end
62
62
 
63
63
  it "should have simple message for Interrupt" do
64
64
  err = Interrupt.new( "spec test msg" )
65
- Sandbox::CLI.expects( :puts ).once.with( 'Interrupted' )
65
+ Sandbox::CLI.expects( :tell_unless_really_quiet ).once.with( 'Interrupted' )
66
66
  Sandbox::CLI.handle_error( err )
67
67
  end
68
68
 
@@ -79,8 +79,8 @@ describe Sandbox::CLI do
79
79
  @cli = Sandbox::CLI.new
80
80
  end
81
81
 
82
- it "should have default 'gems to install'" do
83
- @cli.options[ :gems ] = [ 'rake' ]
82
+ it "should have no default 'gems to install'" do
83
+ @cli.options[ :gems ].should == []
84
84
  end
85
85
 
86
86
  describe "instance calling parse_args!" do
@@ -98,7 +98,7 @@ describe Sandbox::CLI do
98
98
  describe "using VALID arguments" do
99
99
  [ '-V', '--version' ].each do |arg|
100
100
  it "should print the version for switch '#{arg}'" do
101
- @cli.expects( :puts ).with( Sandbox::Version::STRING )
101
+ @cli.expects( :tell_unless_really_quiet ).with( Sandbox::Version::STRING )
102
102
  processor( arg ).should raise_error( SystemExit ) { |error| error.status.should == 0 }
103
103
  end
104
104
  end
@@ -106,7 +106,7 @@ describe Sandbox::CLI do
106
106
  [ '-V', '--version' ].each do |arg|
107
107
  it "should ignore additional arguments after '#{arg}'" do
108
108
  # @cli.stubs(:puts)
109
- @cli.expects( :puts ).with( Sandbox::Version::STRING ).times(2)
109
+ @cli.expects( :tell_unless_really_quiet ).with( Sandbox::Version::STRING ).times(2)
110
110
  processor( arg, '-x' ).should raise_error( SystemExit ) { |error| error.status.should == 0 }
111
111
  processor( arg, 'unknown' ).should raise_error( SystemExit ) { |error| error.status.should == 0 }
112
112
  end
@@ -114,14 +114,14 @@ describe Sandbox::CLI do
114
114
 
115
115
  [ '-h', '--help' ].each do |arg|
116
116
  it "should show help for '#{arg}'" do
117
- @cli.expects( :puts ).with( instance_of( OptionParser ) )
117
+ @cli.expects( :tell_unless_really_quiet ).with( instance_of( OptionParser ) )
118
118
  processor( arg ).should raise_error( SystemExit ) { |error| error.status.should == 0 }
119
119
  end
120
120
  end
121
121
 
122
122
  [ '-h', '--help' ].each do |arg|
123
123
  it "should ignore additional arguments after '#{arg}'" do
124
- @cli.expects( :puts ).with( instance_of( OptionParser ) ).times(2)
124
+ @cli.expects( :tell_unless_really_quiet ).with( instance_of( OptionParser ) ).times(2)
125
125
  processor( arg, '-x' ).should raise_error( SystemExit ) { |error| error.status.should == 0 }
126
126
  processor( arg, 'unknown' ).should raise_error( SystemExit ) { |error| error.status.should == 0 }
127
127
  end
@@ -129,7 +129,7 @@ describe Sandbox::CLI do
129
129
 
130
130
  [ '-H', '--long-help' ].each do |arg|
131
131
  it "should show long help for '#{arg}'" do
132
- @cli.expects( :puts )
132
+ @cli.expects( :tell_unless_really_quiet )
133
133
  @cli.expects( :long_help )
134
134
  processor( arg ).should raise_error( SystemExit ) { |error| error.status.should == 0 }
135
135
  end
@@ -34,8 +34,11 @@ describe Sandbox::Installer, "(mocked)" do
34
34
  describe "when populate called" do
35
35
  it "should call all steps of populate process" do
36
36
  @installer = Sandbox::Installer.new
37
+ @installer.stubs( :tell )
38
+ @installer.stubs( :target ).returns( '/tmp/sandbox' )
37
39
  @installer.expects( :create_directories )
38
40
  @installer.expects( :install_scripts )
41
+ @installer.expects( :install_gemrc )
39
42
  @installer.expects( :install_gems )
40
43
  @installer.populate
41
44
  end
@@ -83,6 +86,29 @@ describe Sandbox::Installer, "(mocked)" do
83
86
  file.string.should == @path
84
87
  end
85
88
  end
89
+
90
+ # install_gemrc
91
+ describe "when install_gemrc called" do
92
+ before( :each ) do
93
+ @path = '/some/new/target'
94
+ @installer = Sandbox::Installer.new
95
+ @installer.stubs( :target ).returns( @path )
96
+ end
97
+
98
+ it "should read template file" do
99
+ File.expects( :read ).with( regexp_matches( /templates\/gemrc\.erb/ ) ).returns( '' )
100
+ File.stubs( :open )
101
+ @installer.install_gemrc
102
+ end
103
+
104
+ it "should write out gemrc to SANDBOX/.gemrc" do
105
+ file = StringIO.new
106
+ File.stubs( :read ).returns( 'gemrc' )
107
+ File.expects( :open ).with( @path + '/.gemrc', 'w' ).yields( file )
108
+ @installer.install_gemrc
109
+ file.string.should == 'gemrc'
110
+ end
111
+ end
86
112
 
87
113
  # install_gems
88
114
  describe "when install_gems called" do
@@ -90,8 +116,15 @@ describe Sandbox::Installer, "(mocked)" do
90
116
  @installer = Sandbox::Installer.new( :gems => [ 'mygem' ] )
91
117
  @installer.stubs( :setup_sandbox_env )
92
118
  @installer.stubs( :restore_sandbox_env )
119
+ @installer.stubs( :tell )
120
+ @installer.stubs( :tell_unless_really_quiet )
93
121
  end
94
122
 
123
+ # it "should skip install when network is not available" do
124
+ # Ping.expects( :pingecho ).with( 'gems.rubyforge.org' ).returns( false )
125
+ # @installer.install_gems.should be_false
126
+ # end
127
+
95
128
  it "should install a good gem" do
96
129
  @installer.expects( :shell_out ).with( 'gem install mygem' ).returns( [ true, 'blah' ] )
97
130
  @installer.install_gems
@@ -99,7 +132,7 @@ describe Sandbox::Installer, "(mocked)" do
99
132
 
100
133
  it "should gracefully handle a bad gem" do
101
134
  @installer.expects( :shell_out ).with( 'gem install mygem' ).returns( [ false, 'blah' ] )
102
- @installer.expects( :warn )
135
+ @installer.expects( :tell_unless_really_quiet ).with( regexp_matches( /failed/ ) )
103
136
  @installer.install_gems
104
137
  end
105
138
  end
@@ -191,13 +224,13 @@ describe Sandbox::Installer, "(mocked)" do
191
224
  describe "when shell_out called" do
192
225
  it "should record true when successful" do
193
226
  @installer = Sandbox::Installer.new
194
- result = @installer.shell_out( '/bin/true' )
227
+ result = @installer.shell_out( 'true' )
195
228
  result.first.should be_true
196
229
  end
197
230
 
198
231
  it "should record false when unsuccessful" do
199
232
  @installer = Sandbox::Installer.new
200
- result = @installer.shell_out( '/bin/false' )
233
+ result = @installer.shell_out( 'false' )
201
234
  result.first.should_not be_true
202
235
  end
203
236
 
@@ -209,7 +242,7 @@ describe Sandbox::Installer, "(mocked)" do
209
242
 
210
243
  it "should ignore std error" do
211
244
  @installer = Sandbox::Installer.new
212
- result = @installer.shell_out( 'ls -d / 1>&2' )
245
+ result = @installer.shell_out( 'ls -d / 1>/dev/null' )
213
246
  result.last.chomp.should == ''
214
247
  end
215
248
  end
@@ -0,0 +1,146 @@
1
+
2
+ require File.dirname( __FILE__ ) + '/../spec_helper.rb'
3
+
4
+ describe 'including', Sandbox::Output do
5
+ class Tester
6
+ include Sandbox::Output
7
+ end
8
+
9
+ before( :each ) do
10
+ Sandbox.instance_eval { instance_variables.each { |v| remove_instance_variable v } }
11
+ @tester = Tester.new
12
+ end
13
+
14
+ it "should have tell method" do
15
+ @tester.should respond_to( :tell )
16
+ end
17
+
18
+ it "should have tell_when_verbose method" do
19
+ @tester.should respond_to( :tell_when_verbose )
20
+ end
21
+
22
+ it "should have tell_when_really_verbose method" do
23
+ @tester.should respond_to( :tell_when_really_verbose )
24
+ end
25
+
26
+ it "should have tell_unless_quiet method" do
27
+ @tester.should respond_to( :tell_unless_quiet )
28
+ end
29
+
30
+ it "should have tell_unless_really_quiet method" do
31
+ @tester.should respond_to( :tell_unless_really_quiet )
32
+ end
33
+
34
+ describe "calling tell" do
35
+ it "should require message" do
36
+ lambda { @tester.tell }.should raise_error( ArgumentError )
37
+ end
38
+
39
+ it "should call puts when normal" do
40
+ @tester.expects( :puts )
41
+ @tester.tell( "message" )
42
+ end
43
+
44
+ it "should not call puts when below normal verbosity" do
45
+ Sandbox.decrease_verbosity
46
+ @tester.expects( :puts ).never
47
+ @tester.tell( "message" )
48
+ end
49
+
50
+ it "should call puts when above normal verbosity" do
51
+ Sandbox.increase_verbosity
52
+ @tester.expects( :puts )
53
+ @tester.tell( "message" )
54
+ end
55
+ end
56
+
57
+ describe "calling tell_when_verbose" do
58
+ it "should require message" do
59
+ lambda { @tester.tell_when_verbose }.should raise_error( ArgumentError )
60
+ end
61
+
62
+ it "should not call puts when normal verbosity" do
63
+ @tester.expects( :puts ).never
64
+ @tester.tell_when_verbose( "message" )
65
+ end
66
+
67
+ it "should call puts when above normal verbosity" do
68
+ Sandbox.increase_verbosity
69
+ @tester.expects( :puts )
70
+ @tester.tell_when_verbose( "message" )
71
+ end
72
+ end
73
+
74
+ describe "calling tell_when_really_verbose" do
75
+ it "should require message" do
76
+ lambda { @tester.tell_when_really_verbose }.should raise_error( ArgumentError )
77
+ end
78
+
79
+ it "should not call puts when normal verbosity" do
80
+ @tester.expects( :puts ).never
81
+ @tester.tell_when_really_verbose( "message" )
82
+ end
83
+
84
+ it "should call puts when above normal verbosity" do
85
+ Sandbox.increase_verbosity
86
+ @tester.expects( :puts ).never
87
+ @tester.tell_when_really_verbose( "message" )
88
+ end
89
+
90
+ it "should call puts when really above normal verbosity" do
91
+ Sandbox.increase_verbosity
92
+ Sandbox.increase_verbosity
93
+ @tester.expects( :puts )
94
+ @tester.tell_when_really_verbose( "message" )
95
+ end
96
+ end
97
+
98
+ describe "calling tell_unless_quiet" do
99
+ it "should require message" do
100
+ lambda { @tester.tell_unless_quiet }.should raise_error( ArgumentError )
101
+ end
102
+
103
+ it "should call puts when normal" do
104
+ @tester.expects( :puts )
105
+ @tester.tell_unless_quiet( "message" )
106
+ end
107
+
108
+ it "should not call puts when below normal verbosity" do
109
+ Sandbox.decrease_verbosity
110
+ @tester.expects( :puts ).never
111
+ @tester.tell_unless_quiet( "message" )
112
+ end
113
+
114
+ it "should call puts when above normal verbosity" do
115
+ Sandbox.increase_verbosity
116
+ @tester.expects( :puts )
117
+ @tester.tell_unless_quiet( "message" )
118
+ end
119
+ end
120
+
121
+ describe "calling tell_unless_really_quiet" do
122
+ it "should require message" do
123
+ lambda { @tester.tell_unless_really_quiet }.should raise_error( ArgumentError )
124
+ end
125
+
126
+ it "should call puts when normal" do
127
+ @tester.expects( :puts )
128
+ @tester.tell_unless_really_quiet( "message" )
129
+ end
130
+
131
+ it "should call puts when below normal verbosity" do
132
+ Sandbox.decrease_verbosity
133
+ @tester.expects( :puts )
134
+ @tester.tell_unless_really_quiet( "message" )
135
+ end
136
+
137
+ it "should not call puts when really below normal verbosity" do
138
+ Sandbox.decrease_verbosity
139
+ Sandbox.decrease_verbosity
140
+ @tester.expects( :puts ).never
141
+ @tester.tell_unless_really_quiet( "message" )
142
+ end
143
+ end
144
+
145
+ end
146
+
data/tasks/cucumber.rake CHANGED
@@ -1,25 +1,18 @@
1
1
  begin
2
2
  require 'cucumber'
3
- rescue LoadError
4
- require 'rubygems'
5
- require 'cucumber'
6
- end
7
- begin
8
3
  require 'cucumber/rake/task'
4
+ # Try these:
5
+ #
6
+ # rake features
7
+ # rake features PROFILE=html
8
+ Cucumber::Rake::Task.new do |t|
9
+ # profile = ENV[ 'PROFILE' ] || 'default'
10
+ # t.cucumber_opts = "--profile #{profile}"
11
+ t.cucumber_opts = "--format pretty"
12
+ end
9
13
  rescue LoadError
10
14
  puts <<-EOS
11
15
  To use cucumber for testing you must install cucumber gem:
12
16
  gem install cucumber
13
17
  EOS
14
- exit( 0 )
15
- end
16
-
17
- # Try these:
18
- #
19
- # rake features
20
- # rake features PROFILE=html
21
- Cucumber::Rake::Task.new do |t|
22
- # profile = ENV[ 'PROFILE' ] || 'default'
23
- # t.cucumber_opts = "--profile #{profile}"
24
- t.cucumber_opts = "--format pretty"
25
18
  end
data/tasks/dcov.rake CHANGED
@@ -1,37 +1,34 @@
1
+
1
2
  begin
2
3
  require 'dcov'
4
+
5
+ desc "Generate coverage report for lib directory"
6
+ task :dcov do
7
+ root = Dir.pwd
8
+ dcov_dir = File.join( root, 'coverage' )
9
+ lib_dir = File.join( root, 'lib' )
10
+
11
+ unless File.directory?( lib_dir )
12
+ puts "Aborting: please run from the root of the project"
13
+ exit( 0 )
14
+ end
15
+
16
+ # files = Dir[ File.join( lib_dir, '**', '*.rb' ) ]
17
+ options = {
18
+ :path => dcov_dir,
19
+ :output_format => 'html',
20
+ :files => lib_dir
21
+ # :files => files
22
+ }
23
+
24
+ Dir.mkdir( dcov_dir ) unless File.directory?( dcov_dir )
25
+ Dcov::Analyzer.new( options )
26
+ end
27
+
3
28
  rescue LoadError
4
- require 'rubygems'
5
- begin
6
- require 'dcov'
7
- rescue LoadError
8
- puts <<-EOS
29
+ puts <<-EOS
9
30
  To generate documentation coverage with dcov you must install dcov gem:
10
31
  gem install dcov
11
32
  EOS
12
- exit( 0 )
13
- end
14
33
  end
15
34
 
16
- desc "Generate coverage report for lib directory"
17
- task :dcov do
18
- root = Dir.pwd
19
- dcov_dir = File.join( root, 'coverage' )
20
- lib_dir = File.join( root, 'lib' )
21
-
22
- unless File.directory?( lib_dir )
23
- puts "Aborting: please run from the root of the project"
24
- exit( 0 )
25
- end
26
-
27
- # files = Dir[ File.join( lib_dir, '**', '*.rb' ) ]
28
- options = {
29
- :path => dcov_dir,
30
- :output_format => 'html',
31
- :files => lib_dir
32
- # :files => files
33
- }
34
-
35
- Dir.mkdir( dcov_dir ) unless File.directory?( dcov_dir )
36
- Dcov::Analyzer.new( options )
37
- end
data/tasks/rspec.rake CHANGED
@@ -1,51 +1,46 @@
1
1
  begin
2
2
  require 'spec'
3
- rescue LoadError
4
- require 'rubygems'
5
- require 'spec'
6
- end
7
- begin
8
3
  require 'spec/rake/spectask'
9
- rescue LoadError
10
- puts <<-EOS
11
- To use rspec for testing you must install rspec gem:
12
- gem install rspec
13
- EOS
14
- exit(0)
15
- end
16
-
17
- desc "Run all the specs in spec directory"
18
- Spec::Rake::SpecTask.new( :spec ) do |t|
19
- t.spec_opts = [ '--options', "spec/spec.opts" ]
20
- t.spec_files = FileList[ 'spec/**/*_spec.rb' ]
21
- end
22
-
23
- namespace :spec do
24
- desc "Run all specs in spec directory with RCov"
25
- Spec::Rake::SpecTask.new( :rcov ) do |t|
4
+
5
+ desc "Run all the specs in spec directory"
6
+ Spec::Rake::SpecTask.new( :spec ) do |t|
26
7
  t.spec_opts = [ '--options', "spec/spec.opts" ]
27
8
  t.spec_files = FileList[ 'spec/**/*_spec.rb' ]
28
- t.rcov = true
29
- # t.rcov_opts = [ '--exclude', "spec/*" ]
30
- t.rcov_opts = [ '--exclude', "spec" ]
31
9
  end
32
10
 
33
- desc "Print Specdoc for all specs in spec directory"
34
- Spec::Rake::SpecTask.new( :doc ) do |t|
35
- t.spec_opts = [ "--format", "specdoc", "--dry-run" ]
36
- # t.spec_opts = [ "--format", "specdoc" ]
37
- t.spec_files = FileList[ 'spec/**/*_spec.rb' ]
38
- end
39
-
40
- desc "Run all the specs in spec directory individually"
41
- task :deps do
42
- individual_specs = Dir["spec/**/*_spec.rb"]
43
- individual_specs.each do |single_spec|
44
- if not system "spec #{single_spec} --options spec/spec.opts &> /dev/null"
45
- puts "Dependency Issues: #{single_spec}"
46
- else
47
- puts "OK: #{single_spec}"
11
+ namespace :spec do
12
+ desc "Run all specs in spec directory with RCov"
13
+ Spec::Rake::SpecTask.new( :rcov ) do |t|
14
+ t.spec_opts = [ '--options', "spec/spec.opts" ]
15
+ t.spec_files = FileList[ 'spec/**/*_spec.rb' ]
16
+ t.rcov = true
17
+ # t.rcov_opts = [ '--exclude', "spec/*" ]
18
+ t.rcov_opts = [ '--exclude', "spec" ]
19
+ end
20
+
21
+ desc "Print Specdoc for all specs in spec directory"
22
+ Spec::Rake::SpecTask.new( :doc ) do |t|
23
+ t.spec_opts = [ "--format", "specdoc", "--dry-run" ]
24
+ # t.spec_opts = [ "--format", "specdoc" ]
25
+ t.spec_files = FileList[ 'spec/**/*_spec.rb' ]
26
+ end
27
+
28
+ desc "Run all the specs in spec directory individually"
29
+ task :deps do
30
+ individual_specs = Dir["spec/**/*_spec.rb"]
31
+ individual_specs.each do |single_spec|
32
+ if not system "spec #{single_spec} --options spec/spec.opts &> /dev/null"
33
+ puts "Dependency Issues: #{single_spec}"
34
+ else
35
+ puts "OK: #{single_spec}"
36
+ end
48
37
  end
49
38
  end
50
39
  end
40
+
41
+ rescue LoadError
42
+ puts <<-EOS
43
+ To use rspec for testing you must install rspec gem:
44
+ gem install rspec
45
+ EOS
51
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nkryptic-sandbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Radford
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-06 00:00:00 -08:00
12
+ date: 2008-12-07 00:00:00 -08:00
13
13
  default_executable: sandbox
14
14
  dependencies: []
15
15
 
@@ -30,9 +30,11 @@ extra_rdoc_files:
30
30
  - lib/sandbox.rb
31
31
  - lib/sandbox/installer.rb
32
32
  - lib/sandbox/cli.rb
33
+ - lib/sandbox/templates/gemrc.erb
33
34
  - lib/sandbox/templates/activate_sandbox.erb
34
35
  - lib/sandbox/version.rb
35
36
  - lib/sandbox/errors.rb
37
+ - lib/sandbox/output.rb
36
38
  - bin/sandbox
37
39
  files:
38
40
  - sandbox.gemspec
@@ -40,6 +42,7 @@ files:
40
42
  - TODO
41
43
  - spec/sandbox/errors_spec.rb
42
44
  - spec/sandbox/cli_spec.rb
45
+ - spec/sandbox/output_spec.rb
43
46
  - spec/sandbox/installer_spec.rb
44
47
  - spec/sandbox_spec.rb
45
48
  - spec/spec.opts
@@ -57,9 +60,11 @@ files:
57
60
  - lib/sandbox.rb
58
61
  - lib/sandbox/installer.rb
59
62
  - lib/sandbox/cli.rb
63
+ - lib/sandbox/templates/gemrc.erb
60
64
  - lib/sandbox/templates/activate_sandbox.erb
61
65
  - lib/sandbox/version.rb
62
66
  - lib/sandbox/errors.rb
67
+ - lib/sandbox/output.rb
63
68
  - bin/sandbox
64
69
  has_rdoc: true
65
70
  homepage: http://github.com/nkryptic/sandbox