Skip to content

Commit

Permalink
Prefer single quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
realityforge committed Feb 22, 2017
1 parent 68bf90f commit 7e87e04
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion lib/braid/commands/update.rb
Expand Up @@ -20,7 +20,7 @@ def update_all(options = {})
def update_one(path, options = {})
mirror = config.get!(path)

revision_message = options["revision"] ? " to #{display_revision(mirror, options["revision"])}" : ""
revision_message = options['revision'] ? " to #{display_revision(mirror, options['revision'])}" : ''
msg "Updating mirror '#{mirror.path}'#{revision_message}."

was_locked = mirror.locked?
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/updating_spec.rb
@@ -1,6 +1,6 @@
require File.dirname(__FILE__) + '/../integration_helper'

describe "Updating a mirror" do
describe 'Updating a mirror' do

before do
FileUtils.rm_rf(TMP_PATH)
Expand Down
6 changes: 3 additions & 3 deletions spec/integration_helper.rb
Expand Up @@ -6,9 +6,9 @@
require 'fileutils'
require 'pathname'

TMP_PATH = File.join(Dir.tmpdir, "braid_integration")
TMP_PATH = File.join(Dir.tmpdir, 'braid_integration')
BRAID_PATH = Pathname.new(File.dirname(__FILE__)).parent.realpath
FIXTURE_PATH = File.join(BRAID_PATH, "spec", "fixtures")
FIXTURE_PATH = File.join(BRAID_PATH, 'spec', 'fixtures')
FileUtils.rm_rf(TMP_PATH)
FileUtils.mkdir_p(TMP_PATH)

Expand All @@ -28,7 +28,7 @@ def run_command(command)
def update_dir_from_fixture(dir, fixture = dir)
to_dir = File.join(TMP_PATH, dir)
FileUtils.mkdir_p(to_dir)
FileUtils.cp_r(File.join(FIXTURE_PATH, fixture) + "/.", to_dir)
FileUtils.cp_r(File.join(FIXTURE_PATH, fixture) + '/.', to_dir)
end

def create_git_repo_from_fixture(fixture_name)
Expand Down
44 changes: 22 additions & 22 deletions spec/mirror_spec.rb
@@ -1,18 +1,18 @@
require File.dirname(__FILE__) + '/test_helper'

describe "Braid::Mirror.new_from_options" do
it "should default branch to master" do
new_from_options("git://path")
@mirror.branch.should == "master"
describe 'Braid::Mirror.new_from_options' do
it 'should default branch to master' do
new_from_options('git://path')
@mirror.branch.should == 'master'
end

it "should default mirror to last path part, ignoring trailing .git" do
new_from_options("http://path.git")
@mirror.path.should == "path"
it 'should default mirror to last path part, ignoring trailing .git' do
new_from_options('http://path.git')
@mirror.path.should == 'path'
end
end

describe "Braid::Mirror#diff" do
describe 'Braid::Mirror#diff' do
before(:each) do
@mirror = build_mirror('revision' => 'a' * 40, 'url' => 'git://path')
@mirror.stubs(:base_revision).returns(@mirror.revision) # bypass rev_parse
Expand All @@ -23,14 +23,14 @@ def set_hashes(remote_hash, local_hash)
git.expects(:tree_hash).with(@mirror.path).returns(local_hash)
end

it "should return an empty string when the hashes match" do
it 'should return an empty string when the hashes match' do
set_hashes('b' * 40, 'b' * 40)
git.expects(:fetch)
git.expects(:diff_tree).never
@mirror.diff.should == ""
@mirror.diff.should == ''
end

it "should generate a diff when the hashes do not match" do
it 'should generate a diff when the hashes do not match' do
set_hashes('b' * 40, 'c' * 40)
diff = "diff --git a/path b/path\n"
git.expects(:fetch)
Expand All @@ -39,24 +39,24 @@ def set_hashes(remote_hash, local_hash)
end
end

describe "Braid::Mirror#base_revision" do
it "should be inferred when no revision is set" do
describe 'Braid::Mirror#base_revision' do
it 'should be inferred when no revision is set' do
@mirror = build_mirror
@mirror.revision.should be_nil
@mirror.expects(:inferred_revision).returns('b' * 40)
@mirror.base_revision.should == 'b' * 40
end

it "should be the parsed hash for git mirrors" do
@mirror = build_mirror("revision" => 'a' * 7)
it 'should be the parsed hash for git mirrors' do
@mirror = build_mirror('revision' => 'a' * 7)
git.expects(:rev_parse).with('a' * 7).returns('a' * 40)
@mirror.base_revision.should == 'a' * 40
end
end

describe "Braid::Mirror#inferred_revision" do
it "should return the last commit before the most recent update" do
@mirror = new_from_options("git://path")
describe 'Braid::Mirror#inferred_revision' do
it 'should return the last commit before the most recent update' do
@mirror = new_from_options('git://path')
git.expects(:rev_list).times(2).returns(
"#{'a' * 40}\n",
"commit #{'b' * 40}\n#{'t' * 40}\n"
Expand All @@ -66,17 +66,17 @@ def set_hashes(remote_hash, local_hash)
end
end

describe "Braid::Mirror#cached?" do
describe 'Braid::Mirror#cached?' do
before(:each) do
@mirror = new_from_options("git://path")
@mirror = new_from_options('git://path')
end

it "should be true when the remote path matches the cache path" do
it 'should be true when the remote path matches the cache path' do
git.expects(:remote_url).with(@mirror.remote).returns(git_cache.path(@mirror.url))
@mirror.should be_cached
end

it "should be false if the remote does not point to the cache" do
it 'should be false if the remote does not point to the cache' do
git.expects(:remote_url).with(@mirror.remote).returns(@mirror.url)
@mirror.should_not be_cached
end
Expand Down
44 changes: 22 additions & 22 deletions spec/operations_spec.rb
@@ -1,66 +1,66 @@
require File.dirname(__FILE__) + '/test_helper'

describe "Braid::Operations::Git#remote_url" do
it "should use git config" do
describe 'Braid::Operations::Git#remote_url' do
it 'should use git config' do
# FIXME weak test
git.stubs(:invoke).with(:config, 'remote.braid/git/one.url').returns("git://path")
git.remote_url("braid/git/one").should == "git://path"
git.stubs(:invoke).with(:config, 'remote.braid/git/one.url').returns('git://path')
git.remote_url('braid/git/one').should == 'git://path'
end
end

describe "Braid::Operations::Git#rev_parse" do
it "should return the full hash when a hash is found" do
describe 'Braid::Operations::Git#rev_parse' do
it 'should return the full hash when a hash is found' do
full_revision = 'a' * 40
git.expects(:exec).returns([0, full_revision, ""])
git.expects(:exec).returns([0, full_revision, ''])
git.rev_parse('a' * 7).should == full_revision
end

it "should raise a revision error when the hash is not found" do
it 'should raise a revision error when the hash is not found' do
ambiguous_revision = 'b' * 7
git.expects(:exec).returns([1, ambiguous_revision, "fatal: ..."])
git.expects(:exec).returns([1, ambiguous_revision, 'fatal: ...'])
lambda { git.rev_parse(ambiguous_revision) }.should raise_error(Braid::Operations::UnknownRevision)
end
end

describe "Braid::Operations::Git#version" do
ACTUAL_VERSION = "1.5.5.1.98.gf0ec4"
describe 'Braid::Operations::Git#version' do
ACTUAL_VERSION = '1.5.5.1.98.gf0ec4'

before(:each) do
git.expects(:exec).returns([0, "git version #{ACTUAL_VERSION}\n", ""])
git.expects(:exec).returns([0, "git version #{ACTUAL_VERSION}\n", ''])
end

it "should extract from git --version output" do
it 'should extract from git --version output' do
git.version.should == ACTUAL_VERSION
end
end

describe "Braid::Operations::Git#require_version" do
REQUIRED_VERSION = "1.5.4.5"
describe 'Braid::Operations::Git#require_version' do
REQUIRED_VERSION = '1.5.4.5'
PASS_VERSIONS = %w(1.5.4.6 1.5.5 1.6 1.5.4.5.2 1.5.5.1.98.gf0ec4)
FAIL_VERSIONS = %w(1.5.4.4 1.5.4 1.5.3 1.4.5.6)

def set_version(str)
git.expects(:exec).returns([0, "git version #{str}\n", ""])
git.expects(:exec).returns([0, "git version #{str}\n", ''])
end

it "should return true for higher revisions" do
it 'should return true for higher revisions' do
PASS_VERSIONS.each do |version|
set_version(version)
git.require_version(REQUIRED_VERSION).should == true
end
end

it "should return false for lower revisions" do
it 'should return false for lower revisions' do
FAIL_VERSIONS.each do |version|
set_version(version)
git.require_version(REQUIRED_VERSION).should == false
end
end
end

describe "Braid::Operations::GitCache#path" do
it "should use the local cache directory and strip characters" do
git_cache.path("git://path").should == File.join(Braid.local_cache_dir, "git___path")
git_cache.path("git@domain:repository.git").should == File.join(Braid.local_cache_dir, "git_domain_repository.git")
describe 'Braid::Operations::GitCache#path' do
it 'should use the local cache directory and strip characters' do
git_cache.path('git://path').should == File.join(Braid.local_cache_dir, 'git___path')
git_cache.path('git@domain:repository.git').should == File.join(Braid.local_cache_dir, 'git_domain_repository.git')
end
end

0 comments on commit 7e87e04

Please sign in to comment.