diff options
author | Markus Roberts <Markus@reality.com> | 2010-07-09 18:12:17 -0700 |
---|---|---|
committer | Markus Roberts <Markus@reality.com> | 2010-07-09 18:12:17 -0700 |
commit | 3180b9d9b2c844dade1d361326600f7001ec66dd (patch) | |
tree | 98fe7c5ac7eb942aac9c39f019a17b0b3f5a57f4 /spec/unit/util/loadedfile_spec.rb | |
parent | 543225970225de5697734bfaf0a6eee996802c04 (diff) | |
download | puppet-3180b9d9b2c844dade1d361326600f7001ec66dd.tar.gz puppet-3180b9d9b2c844dade1d361326600f7001ec66dd.tar.xz puppet-3180b9d9b2c844dade1d361326600f7001ec66dd.zip |
Code smell: Two space indentation
Replaced 106806 occurances of ^( +)(.*$) with
The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people
who learned ruby in the 1900s) uses two-space indentation.
3 Examples:
The code:
end
# Tell getopt which arguments are valid
def test_get_getopt_args
element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new
assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args")
becomes:
end
# Tell getopt which arguments are valid
def test_get_getopt_args
element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new
assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args")
The code:
assert_equal(str, val)
assert_instance_of(Float, result)
end
# Now test it with a passed object
becomes:
assert_equal(str, val)
assert_instance_of(Float, result)
end
# Now test it with a passed object
The code:
end
assert_nothing_raised do
klass[:Yay] = "boo"
klass["Cool"] = :yayness
end
becomes:
end
assert_nothing_raised do
klass[:Yay] = "boo"
klass["Cool"] = :yayness
end
Diffstat (limited to 'spec/unit/util/loadedfile_spec.rb')
-rwxr-xr-x | spec/unit/util/loadedfile_spec.rb | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/spec/unit/util/loadedfile_spec.rb b/spec/unit/util/loadedfile_spec.rb index 083120e20..3bc26a421 100755 --- a/spec/unit/util/loadedfile_spec.rb +++ b/spec/unit/util/loadedfile_spec.rb @@ -6,60 +6,60 @@ require 'tempfile' require 'puppet/util/loadedfile' describe Puppet::Util::LoadedFile do - before(:each) do - @f = Tempfile.new('loadedfile_test') - @f.puts "yayness" - @f.flush + before(:each) do + @f = Tempfile.new('loadedfile_test') + @f.puts "yayness" + @f.flush - @loaded = Puppet::Util::LoadedFile.new(@f.path) + @loaded = Puppet::Util::LoadedFile.new(@f.path) - fake_ctime = Time.now - (2 * Puppet[:filetimeout]) - @stat = stub('stat', :ctime => fake_ctime) - @fake_now = Time.now + (2 * Puppet[:filetimeout]) - end + fake_ctime = Time.now - (2 * Puppet[:filetimeout]) + @stat = stub('stat', :ctime => fake_ctime) + @fake_now = Time.now + (2 * Puppet[:filetimeout]) + end - it "should recognize when the file has not changed" do - # Use fake "now" so that we can be sure changed? actually checks, without sleeping - # for Puppet[:filetimeout] seconds. - Time.stubs(:now).returns(@fake_now) - @loaded.changed?.should == false - end + it "should recognize when the file has not changed" do + # Use fake "now" so that we can be sure changed? actually checks, without sleeping + # for Puppet[:filetimeout] seconds. + Time.stubs(:now).returns(@fake_now) + @loaded.changed?.should == false + end - it "should recognize when the file has changed" do - # Fake File.stat so we don't have to depend on the filesystem granularity. Doing a flush() - # just didn't do the job. - File.stubs(:stat).returns(@stat) - # Use fake "now" so that we can be sure changed? actually checks, without sleeping - # for Puppet[:filetimeout] seconds. - Time.stubs(:now).returns(@fake_now) - @loaded.changed?.should be_an_instance_of(Time) - end + it "should recognize when the file has changed" do + # Fake File.stat so we don't have to depend on the filesystem granularity. Doing a flush() + # just didn't do the job. + File.stubs(:stat).returns(@stat) + # Use fake "now" so that we can be sure changed? actually checks, without sleeping + # for Puppet[:filetimeout] seconds. + Time.stubs(:now).returns(@fake_now) + @loaded.changed?.should be_an_instance_of(Time) + end - it "should not catch a change until the timeout has elapsed" do - # Fake File.stat so we don't have to depend on the filesystem granularity. Doing a flush() - # just didn't do the job. - File.stubs(:stat).returns(@stat) - @loaded.changed?.should be(false) - # Use fake "now" so that we can be sure changed? actually checks, without sleeping - # for Puppet[:filetimeout] seconds. - Time.stubs(:now).returns(@fake_now) - @loaded.changed?.should_not be(false) - end + it "should not catch a change until the timeout has elapsed" do + # Fake File.stat so we don't have to depend on the filesystem granularity. Doing a flush() + # just didn't do the job. + File.stubs(:stat).returns(@stat) + @loaded.changed?.should be(false) + # Use fake "now" so that we can be sure changed? actually checks, without sleeping + # for Puppet[:filetimeout] seconds. + Time.stubs(:now).returns(@fake_now) + @loaded.changed?.should_not be(false) + end - it "should consider a file changed when that file is missing" do - @f.close! - # Use fake "now" so that we can be sure changed? actually checks, without sleeping - # for Puppet[:filetimeout] seconds. - Time.stubs(:now).returns(@fake_now) - @loaded.changed?.should_not be(false) - end + it "should consider a file changed when that file is missing" do + @f.close! + # Use fake "now" so that we can be sure changed? actually checks, without sleeping + # for Puppet[:filetimeout] seconds. + Time.stubs(:now).returns(@fake_now) + @loaded.changed?.should_not be(false) + end - it "should disable checking if Puppet[:filetimeout] is negative" do - Puppet[:filetimeout] = -1 - @loaded.changed?.should_not be(false) - end + it "should disable checking if Puppet[:filetimeout] is negative" do + Puppet[:filetimeout] = -1 + @loaded.changed?.should_not be(false) + end - after(:each) do - @f.close - end + after(:each) do + @f.close + end end |