Sha256: 826664d158eddfa55be12d6e54b48b2de1fb7587471afda0b4d19645204fad55

Contents?: true

Size: 1.2 KB

Versions: 26

Compression:

Stored size: 1.2 KB

Contents

def stub_io
  stub_screen_io
  stub_file_io
  stub_file_utils
  stub_yaml
  stub_yrb
  stub_growl
end

def stub_screen_io
  $stdout.stub!(:puts)
  $stdout.stub!(:print)    
end

def stub_file_io(unprocessed_file="")
  @file ||= mock('file').as_null_object
  @file.stub!(:read).and_return(unprocessed_file)
  @file.stub!(:write)
  @file.stub!(:puts)
  
  File.stub!(:new).and_return(@file)
  File.stub!(:exists?).and_return(false)
  File.stub!(:open).and_yield(@file) 
  File.stub!(:read).and_return(unprocessed_file)
  File.stub!(:readlines).and_return(["first\n", "second\n"])
end

def stub_file_utils
  FileUtils.stub!(:rm)
  FileUtils.stub!(:rm_rf)
  FileUtils.stub!(:cp_r)
  FileUtils.stub!(:mkdir_p)
end

def stub_yaml(output_hash={})
  YAML.stub!(:load_file).and_return(output_hash)
end

def stub_yrb(output_hash={})
  YRB.stub!(:load_file).and_return(output_hash)
end

def stub_timer
  @timer = mock('timer').as_null_object
  @timer.stub!(:time).and_yield
  Timer.stub!(:new).and_return(@timer)
end

def stub_growl
  @g = Object.new
  Growl.stub(:new).and_return(@g)
  @g.stub(:notify).as_null_object  
end

def reset_constant(constant, value)
  Object.send(:remove_const, constant)
  Object.const_set(constant, value)
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
idiom-0.7.3 spec/stubs.rb
idiom-0.7.2 spec/stubs.rb
idiom-0.7.1 spec/stubs.rb
idiom-0.7.0 spec/stubs.rb
idiom-0.6.0 spec/stubs.rb
idiom-0.5.5 spec/stubs.rb
idiom-0.5.4 spec/stubs.rb
idiom-0.5.3 spec/stubs.rb
idiom-0.5.2 spec/stubs.rb
idiom-0.5.1 spec/stubs.rb
idiom-0.5.0 spec/stubs.rb
idiom-0.4.4 spec/stubs.rb
idiom-0.4.3 spec/stubs.rb
idiom-0.4.2 spec/stubs.rb
idiom-0.4.1 spec/stubs.rb
idiom-0.3.1 spec/stubs.rb
idiom-0.4.0 spec/stubs.rb
idiom-0.3.0 spec/stubs.rb
idiom-0.2.2 spec/stubs.rb
idiom-0.2.0 spec/stubs.rb