librarian 0.0.23 → 0.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,47 @@
1
+ require "yaml"
2
+
3
+ require "librarian/config/source"
4
+
5
+ module Librarian
6
+ module Config
7
+ class FileSource < Source
8
+
9
+ attr_accessor :config_path
10
+ private :config_path=
11
+
12
+ def initialize(adapter_name, options = { })
13
+ super
14
+
15
+ self.config_path = options.delete(:config_path) or raise ArgumentError, "must provide config_path"
16
+ end
17
+
18
+ def to_s
19
+ config_path
20
+ end
21
+
22
+ private
23
+
24
+ def load
25
+ return { } unless File.file?(config_path)
26
+
27
+ raw = YAML.load_file(config_path)
28
+ return { } unless Hash === raw
29
+
30
+ translate_raw_to_config(raw)
31
+ end
32
+
33
+ def save(config)
34
+ raw = translate_config_to_raw(config)
35
+
36
+ if config.empty?
37
+ File.delete(config_path) if File.file?(config_path)
38
+ else
39
+ config_dir = File.dirname(config_path)
40
+ FileUtils.mkpath(config_dir) unless File.directory?(config_dir)
41
+ File.open(config_path, "wb"){|f| YAML.dump(raw, f)}
42
+ end
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,33 @@
1
+ require "librarian/source"
2
+
3
+ module Librarian
4
+ module Config
5
+ class HashSource < Source
6
+
7
+ attr_accessor :name, :raw
8
+ private :name=, :raw=
9
+
10
+ def initialize(adapter_name, options = { })
11
+ super
12
+
13
+ self.name = options.delete(:name) or raise ArgumentError, "must provide name"
14
+ self.raw = options.delete(:raw) or raise ArgumentError, "must provide raw"
15
+ end
16
+
17
+ def to_s
18
+ name
19
+ end
20
+
21
+ private
22
+
23
+ def load
24
+ translate_raw_to_config(raw)
25
+ end
26
+
27
+ def save(config)
28
+ raise Error, "nonsense!"
29
+ end
30
+
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,149 @@
1
+ require "librarian/error"
2
+
3
+ module Librarian
4
+ module Config
5
+ class Source
6
+
7
+ RAW_KEY_SUFFIX_VALIDITY_PATTERN =
8
+ /\A[A-Z0-9_]+\z/
9
+ CONFIG_KEY_VALIDITY_PATTERN =
10
+ /\A[a-z][a-z0-9\-]+(?:\.[a-z0-9\-]+)*\z/
11
+
12
+ class << self
13
+ def raw_key_suffix_validity_pattern
14
+ RAW_KEY_SUFFIX_VALIDITY_PATTERN
15
+ end
16
+ def config_key_validity_pattern
17
+ CONFIG_KEY_VALIDITY_PATTERN
18
+ end
19
+ end
20
+
21
+ attr_accessor :adapter_name
22
+ private :adapter_name=
23
+
24
+ def initialize(adapter_name, options = { })
25
+ self.adapter_name = adapter_name
26
+
27
+ self.forbidden_keys = options.delete(:forbidden_keys) || []
28
+ end
29
+
30
+ def [](key)
31
+ load!
32
+
33
+ data[key]
34
+ end
35
+
36
+ def []=(key, value)
37
+ key_permitted?(key) or raise Error, "key not permitted: #{key.inspect}"
38
+ value_permitted?(key, value) or raise Error, "value for key #{key.inspect} not permitted: #{value.inspect}"
39
+
40
+ load!
41
+ if value.nil?
42
+ data.delete(key)
43
+ else
44
+ data[key] = value
45
+ end
46
+ save(data)
47
+ end
48
+
49
+ def keys
50
+ load!
51
+
52
+ data.keys
53
+ end
54
+
55
+ private
56
+
57
+ attr_accessor :data, :forbidden_keys
58
+
59
+ def load!
60
+ self.data = load unless data
61
+ end
62
+
63
+ def key_permitted?(key)
64
+ String === key &&
65
+ config_key_validity_pattern === key &&
66
+ !forbidden_keys.any?{|k| k === key}
67
+ end
68
+
69
+ def value_permitted?(key, value)
70
+ return true if value.nil?
71
+
72
+ String === value
73
+ end
74
+
75
+ def raw_key_valid?(key)
76
+ return false unless key.start_with?(raw_key_prefix)
77
+
78
+ suffix = key[raw_key_prefix.size..-1]
79
+ raw_key_suffix_validity_pattern =~ suffix
80
+ end
81
+
82
+ def raw_key_suffix_validity_pattern
83
+ self.class.raw_key_suffix_validity_pattern
84
+ end
85
+
86
+ def config_key_valid?(key)
87
+ config_key_validity_pattern === key
88
+ end
89
+
90
+ def config_key_validity_pattern
91
+ self.class.config_key_validity_pattern
92
+ end
93
+
94
+ def raw_key_prefix
95
+ @key_prefix ||= "LIBRARIAN_#{adapter_name.upcase}_"
96
+ end
97
+
98
+ def assert_raw_keys_valid!(raw)
99
+ bad_keys = raw.keys.reject{|k| raw_key_valid?(k)}
100
+ unless bad_keys.empty?
101
+ config_path_s = config_path.to_s.inspect
102
+ bad_keys_s = bad_keys.map(&:inspect).join(", ")
103
+ raise Error, "config #{to_s} has bad keys: #{bad_keys_s}"
104
+ end
105
+ end
106
+
107
+ def assert_config_keys_valid!(config)
108
+ bad_keys = config.keys.reject{|k| config_key_valid?(k)}
109
+ unless bad_keys.empty?
110
+ bad_keys_s = bad_keys.map(&:inspect).join(", ")
111
+ raise Error, "config has bad keys: #{bad_keys_s}"
112
+ end
113
+ end
114
+
115
+ def assert_values_valid!(data)
116
+ bad_data = data.reject{|k, v| String === v}
117
+ bad_keys = bad_data.keys
118
+
119
+ unless bad_keys.empty?
120
+ bad_keys_s = bad_keys.map(&:inspect).join(", ")
121
+ raise Error, "config has bad values for keys: #{bad_keys_s}"
122
+ end
123
+ end
124
+
125
+ def translate_raw_to_config(raw)
126
+ assert_raw_keys_valid!(raw)
127
+ assert_values_valid!(raw)
128
+
129
+ Hash[raw.map do |key, value|
130
+ key = key[raw_key_prefix.size .. -1]
131
+ key = key.downcase.gsub(/__/, ".").gsub(/_/, "-")
132
+ [key, value]
133
+ end]
134
+ end
135
+
136
+ def translate_config_to_raw(config)
137
+ assert_config_keys_valid!(config)
138
+ assert_values_valid!(config)
139
+
140
+ Hash[config.map do |key, value|
141
+ key = key.gsub(/\./, "__").gsub(/\-/, "_").upcase
142
+ key = "#{raw_key_prefix}#{key}"
143
+ [key, value]
144
+ end]
145
+ end
146
+
147
+ end
148
+ end
149
+ end
@@ -4,6 +4,7 @@ require "librarian/helpers/debug"
4
4
  require "librarian/support/abstract_method"
5
5
 
6
6
  require "librarian/error"
7
+ require "librarian/config"
7
8
  require "librarian/lockfile"
8
9
  require "librarian/specfile"
9
10
  require "librarian/resolver"
@@ -21,25 +22,25 @@ module Librarian
21
22
  abstract_method :specfile_name, :dsl_class, :install_path
22
23
 
23
24
  def initialize(options = { })
25
+ @pwd = options.fetch(:pwd) { Dir.pwd }
26
+ @env = options.fetch(:env) { ENV.to_hash }
27
+ @home = options.fetch(:home) { File.expand_path("~") }
24
28
  @project_path = options[:project_path]
25
29
  @specfile_name = options[:specfile_name]
26
30
  end
27
31
 
28
- def project_path
29
- @project_path ||= begin
30
- root = Pathname.new(Dir.pwd)
31
- root = root.dirname until project_path?(root)
32
- path = root.join(specfile_name)
33
- path.file? ? root : nil
32
+ def config_db
33
+ @config_db ||= begin
34
+ Config::Database.new(adapter_name,
35
+ :pwd => @pwd,
36
+ :env => @env,
37
+ :home => @home,
38
+ :project_path => @project_path,
39
+ :specfile_name => default_specfile_name
40
+ )
34
41
  end
35
42
  end
36
43
 
37
- def project_path?(path)
38
- path.join(config_name).directory? ||
39
- path.join(specfile_name).file? ||
40
- path.dirname == path
41
- end
42
-
43
44
  def default_specfile_name
44
45
  @default_specfile_name ||= begin
45
46
  capped = adapter_name.capitalize
@@ -47,12 +48,16 @@ module Librarian
47
48
  end
48
49
  end
49
50
 
51
+ def project_path
52
+ config_db.project_path
53
+ end
54
+
50
55
  def specfile_name
51
- @specfile_name ||= default_specfile_name
56
+ config_db.specfile_name
52
57
  end
53
58
 
54
59
  def specfile_path
55
- project_path.join(specfile_name)
60
+ config_db.specfile_path
56
61
  end
57
62
 
58
63
  def specfile
@@ -63,20 +68,12 @@ module Librarian
63
68
  nil
64
69
  end
65
70
 
66
- def config_name
67
- File.join(*[config_prefix, adapter_name].compact)
68
- end
69
-
70
- def config_prefix
71
- ".librarian"
72
- end
73
-
74
71
  def lockfile_name
75
- "#{specfile_name}.lock"
72
+ config_db.lockfile_name
76
73
  end
77
74
 
78
75
  def lockfile_path
79
- project_path.join(lockfile_name)
76
+ config_db.lockfile_path
80
77
  end
81
78
 
82
79
  def lockfile
@@ -119,6 +116,11 @@ module Librarian
119
116
  self.class.name.split("::")[0 ... -1].inject(Object, &:const_get)::Dsl
120
117
  end
121
118
 
119
+ def config_keys
120
+ %[
121
+ ]
122
+ end
123
+
122
124
  private
123
125
 
124
126
  def environment
@@ -34,7 +34,7 @@ module Librarian
34
34
  path = File.expand_path(path)
35
35
  exts.each do |ext|
36
36
  exe = File.join(path, cmd + ext)
37
- return exe if File.executable?(exe)
37
+ return exe if File.file?(exe) && File.executable?(exe)
38
38
  end
39
39
  end
40
40
  nil
@@ -127,7 +127,7 @@ module Librarian
127
127
  reference = "#{remote}/#{reference}"
128
128
  end
129
129
 
130
- command = %W(rev-parse #{reference} --quiet)
130
+ command = %W(rev-list #{reference} -1)
131
131
  run!(command, :chdir => true).strip
132
132
  end
133
133
 
@@ -1,3 +1,3 @@
1
1
  module Librarian
2
- VERSION = "0.0.23"
2
+ VERSION = "0.0.24"
3
3
  end
data/librarian.gemspec CHANGED
@@ -2,19 +2,19 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "librarian"
5
- s.version = "0.0.23"
5
+ s.version = "0.0.24"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jay Feldblum"]
9
- s.date = "2012-05-14"
9
+ s.date = "2012-06-23"
10
10
  s.description = "Librarian"
11
11
  s.email = ["y_feldblum@yahoo.com"]
12
12
  s.executables = ["librarian-chef", "librarian-mock"]
13
- s.files = [".gitignore", ".rspec", ".travis.yml", "CHANGELOG.md", "Gemfile", "MIT-LICENSE", "README.md", "Rakefile", "bin/librarian-chef", "bin/librarian-mock", "config/cucumber.yaml", "features/chef/cli/init.feature", "features/chef/cli/install.feature", "features/chef/cli/show.feature", "features/chef/cli/version.feature", "features/support/env.rb", "lib/librarian.rb", "lib/librarian/action.rb", "lib/librarian/action/base.rb", "lib/librarian/action/clean.rb", "lib/librarian/action/ensure.rb", "lib/librarian/action/install.rb", "lib/librarian/action/resolve.rb", "lib/librarian/action/update.rb", "lib/librarian/chef.rb", "lib/librarian/chef/cli.rb", "lib/librarian/chef/dsl.rb", "lib/librarian/chef/environment.rb", "lib/librarian/chef/extension.rb", "lib/librarian/chef/integration/knife.rb", "lib/librarian/chef/manifest_reader.rb", "lib/librarian/chef/source.rb", "lib/librarian/chef/source/git.rb", "lib/librarian/chef/source/local.rb", "lib/librarian/chef/source/path.rb", "lib/librarian/chef/source/site.rb", "lib/librarian/chef/templates/Cheffile", "lib/librarian/cli.rb", "lib/librarian/cli/manifest_presenter.rb", "lib/librarian/dependency.rb", "lib/librarian/dsl.rb", "lib/librarian/dsl/receiver.rb", "lib/librarian/dsl/target.rb", "lib/librarian/environment.rb", "lib/librarian/error.rb", "lib/librarian/helpers.rb", "lib/librarian/helpers/debug.rb", "lib/librarian/lockfile.rb", "lib/librarian/lockfile/compiler.rb", "lib/librarian/lockfile/parser.rb", "lib/librarian/manifest.rb", "lib/librarian/manifest_set.rb", "lib/librarian/mock.rb", "lib/librarian/mock/cli.rb", "lib/librarian/mock/dsl.rb", "lib/librarian/mock/environment.rb", "lib/librarian/mock/extension.rb", "lib/librarian/mock/source.rb", "lib/librarian/mock/source/mock.rb", "lib/librarian/mock/source/mock/registry.rb", "lib/librarian/resolution.rb", "lib/librarian/resolver.rb", "lib/librarian/resolver/implementation.rb", "lib/librarian/source.rb", "lib/librarian/source/git.rb", "lib/librarian/source/git/repository.rb", "lib/librarian/source/local.rb", "lib/librarian/source/path.rb", "lib/librarian/spec.rb", "lib/librarian/spec_change_set.rb", "lib/librarian/specfile.rb", "lib/librarian/support/abstract_method.rb", "lib/librarian/ui.rb", "lib/librarian/version.rb", "librarian.gemspec", "spec/functional/chef/source/git_spec.rb", "spec/functional/chef/source/site_spec.rb", "spec/unit/action/base_spec.rb", "spec/unit/action/clean_spec.rb", "spec/unit/action/ensure_spec.rb", "spec/unit/action/install_spec.rb", "spec/unit/dependency_spec.rb", "spec/unit/dsl_spec.rb", "spec/unit/environment_spec.rb", "spec/unit/lockfile/parser_spec.rb", "spec/unit/lockfile_spec.rb", "spec/unit/manifest_set_spec.rb", "spec/unit/manifest_spec.rb", "spec/unit/mock/source/mock_spec.rb", "spec/unit/resolver_spec.rb", "spec/unit/source/git_spec.rb", "spec/unit/spec_change_set_spec.rb"]
13
+ s.files = [".gitignore", ".rspec", ".travis.yml", "CHANGELOG.md", "Gemfile", "MIT-LICENSE", "README.md", "Rakefile", "bin/librarian-chef", "bin/librarian-mock", "config/cucumber.yaml", "features/chef/cli/init.feature", "features/chef/cli/install.feature", "features/chef/cli/show.feature", "features/chef/cli/version.feature", "features/support/env.rb", "lib/librarian.rb", "lib/librarian/action.rb", "lib/librarian/action/base.rb", "lib/librarian/action/clean.rb", "lib/librarian/action/ensure.rb", "lib/librarian/action/install.rb", "lib/librarian/action/resolve.rb", "lib/librarian/action/update.rb", "lib/librarian/chef.rb", "lib/librarian/chef/cli.rb", "lib/librarian/chef/dsl.rb", "lib/librarian/chef/environment.rb", "lib/librarian/chef/extension.rb", "lib/librarian/chef/integration/knife.rb", "lib/librarian/chef/manifest_reader.rb", "lib/librarian/chef/source.rb", "lib/librarian/chef/source/git.rb", "lib/librarian/chef/source/local.rb", "lib/librarian/chef/source/path.rb", "lib/librarian/chef/source/site.rb", "lib/librarian/chef/templates/Cheffile", "lib/librarian/cli.rb", "lib/librarian/cli/manifest_presenter.rb", "lib/librarian/config.rb", "lib/librarian/config/database.rb", "lib/librarian/config/file_source.rb", "lib/librarian/config/hash_source.rb", "lib/librarian/config/source.rb", "lib/librarian/dependency.rb", "lib/librarian/dsl.rb", "lib/librarian/dsl/receiver.rb", "lib/librarian/dsl/target.rb", "lib/librarian/environment.rb", "lib/librarian/error.rb", "lib/librarian/helpers.rb", "lib/librarian/helpers/debug.rb", "lib/librarian/lockfile.rb", "lib/librarian/lockfile/compiler.rb", "lib/librarian/lockfile/parser.rb", "lib/librarian/manifest.rb", "lib/librarian/manifest_set.rb", "lib/librarian/mock.rb", "lib/librarian/mock/cli.rb", "lib/librarian/mock/dsl.rb", "lib/librarian/mock/environment.rb", "lib/librarian/mock/extension.rb", "lib/librarian/mock/source.rb", "lib/librarian/mock/source/mock.rb", "lib/librarian/mock/source/mock/registry.rb", "lib/librarian/resolution.rb", "lib/librarian/resolver.rb", "lib/librarian/resolver/implementation.rb", "lib/librarian/source.rb", "lib/librarian/source/git.rb", "lib/librarian/source/git/repository.rb", "lib/librarian/source/local.rb", "lib/librarian/source/path.rb", "lib/librarian/spec.rb", "lib/librarian/spec_change_set.rb", "lib/librarian/specfile.rb", "lib/librarian/support/abstract_method.rb", "lib/librarian/ui.rb", "lib/librarian/version.rb", "librarian.gemspec", "spec/functional/chef/source/git_spec.rb", "spec/functional/chef/source/site_spec.rb", "spec/functional/source/git/repository_spec.rb", "spec/unit/action/base_spec.rb", "spec/unit/action/clean_spec.rb", "spec/unit/action/ensure_spec.rb", "spec/unit/action/install_spec.rb", "spec/unit/config/database_spec.rb", "spec/unit/dependency_spec.rb", "spec/unit/dsl_spec.rb", "spec/unit/environment_spec.rb", "spec/unit/lockfile/parser_spec.rb", "spec/unit/lockfile_spec.rb", "spec/unit/manifest_set_spec.rb", "spec/unit/manifest_spec.rb", "spec/unit/mock/source/mock_spec.rb", "spec/unit/resolver_spec.rb", "spec/unit/source/git_spec.rb", "spec/unit/spec_change_set_spec.rb"]
14
14
  s.homepage = ""
15
15
  s.require_paths = ["lib"]
16
16
  s.rubyforge_project = "librarian"
17
- s.rubygems_version = "1.8.17"
17
+ s.rubygems_version = "1.8.24"
18
18
  s.summary = "Librarian"
19
19
 
20
20
  if s.respond_to? :specification_version then
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.add_development_dependency(%q<cucumber>, [">= 0"])
28
28
  s.add_development_dependency(%q<aruba>, [">= 0"])
29
29
  s.add_development_dependency(%q<webmock>, [">= 0"])
30
+ s.add_development_dependency(%q<fakefs>, [">= 0"])
30
31
  s.add_runtime_dependency(%q<chef>, [">= 0.10"])
31
32
  s.add_runtime_dependency(%q<highline>, [">= 0"])
32
33
  s.add_runtime_dependency(%q<archive-tar-minitar>, [">= 0.5.2"])
@@ -37,6 +38,7 @@ Gem::Specification.new do |s|
37
38
  s.add_dependency(%q<cucumber>, [">= 0"])
38
39
  s.add_dependency(%q<aruba>, [">= 0"])
39
40
  s.add_dependency(%q<webmock>, [">= 0"])
41
+ s.add_dependency(%q<fakefs>, [">= 0"])
40
42
  s.add_dependency(%q<chef>, [">= 0.10"])
41
43
  s.add_dependency(%q<highline>, [">= 0"])
42
44
  s.add_dependency(%q<archive-tar-minitar>, [">= 0.5.2"])
@@ -48,6 +50,7 @@ Gem::Specification.new do |s|
48
50
  s.add_dependency(%q<cucumber>, [">= 0"])
49
51
  s.add_dependency(%q<aruba>, [">= 0"])
50
52
  s.add_dependency(%q<webmock>, [">= 0"])
53
+ s.add_dependency(%q<fakefs>, [">= 0"])
51
54
  s.add_dependency(%q<chef>, [">= 0.10"])
52
55
  s.add_dependency(%q<highline>, [">= 0"])
53
56
  s.add_dependency(%q<archive-tar-minitar>, [">= 0.5.2"])
@@ -0,0 +1,149 @@
1
+ require "fileutils"
2
+ require "pathname"
3
+ require "securerandom"
4
+
5
+ require "librarian/source/git/repository"
6
+
7
+ describe Librarian::Source::Git::Repository do
8
+
9
+ let(:env) do
10
+ double(:ui => nil)
11
+ end
12
+
13
+ let(:project_path) do
14
+ project_path = Pathname.new(__FILE__).expand_path
15
+ project_path = project_path.dirname until project_path.join("Rakefile").exist?
16
+ project_path
17
+ end
18
+ let(:tmp_path) { project_path + "tmp/spec/unit/source/git/repository-spec" }
19
+ let(:git_source_path) { tmp_path + SecureRandom.hex(16) }
20
+ let(:branch) { "the-branch" }
21
+ let(:tag) { "the-tag" }
22
+ let(:atag) { "the-atag" }
23
+
24
+ before do
25
+ git_source_path.mkpath
26
+ Dir.chdir(git_source_path) do
27
+ `git init`
28
+
29
+ # master
30
+ `touch butter.txt`
31
+ `git add butter.txt`
32
+ `git commit -m "Initial Commit"`
33
+
34
+ # branch
35
+ `git checkout -b #{branch} --quiet`
36
+ `touch jam.txt`
37
+ `git add jam.txt`
38
+ `git commit -m "Branch Commit"`
39
+ `git checkout master --quiet`
40
+
41
+ # tag
42
+ `git checkout -b deletable --quiet`
43
+ `touch jelly.txt`
44
+ `git add jelly.txt`
45
+ `git commit -m "Tag Commit"`
46
+ `git tag #{tag}`
47
+ `git checkout master --quiet`
48
+ `git branch -D deletable`
49
+
50
+ # annotated tag
51
+ `git checkout -b deletable --quiet`
52
+ `touch jelly.txt`
53
+ `git add jelly.txt`
54
+ `git commit -m "Tag Commit"`
55
+ `git tag -am "Annotated Tag Commit" #{atag}`
56
+ `git checkout master --quiet`
57
+ `git branch -D deletable`
58
+ end
59
+ end
60
+
61
+ context "the original" do
62
+ subject { described_class.new(env, git_source_path) }
63
+
64
+ it "should recognize it" do
65
+ subject.should be_git
66
+ end
67
+
68
+ it "should not list any remotes for it" do
69
+ subject.remote_names.should be_empty
70
+ end
71
+
72
+ it "should not list any remote branches for it" do
73
+ subject.remote_branch_names.should be_empty
74
+ end
75
+ end
76
+
77
+ context "a clone" do
78
+ let(:git_clone_path) { tmp_path + SecureRandom.hex(16) }
79
+ subject { described_class.clone!(env, git_clone_path, git_source_path) }
80
+
81
+ let(:master_sha) { subject.hash_from("origin", "master") }
82
+ let(:branch_sha) { subject.hash_from("origin", branch) }
83
+ let(:tag_sha) { subject.hash_from("origin", tag) }
84
+ let(:atag_sha) { subject.hash_from("origin", atag) }
85
+
86
+ it "should recognize it" do
87
+ subject.should be_git
88
+ end
89
+
90
+ it "should have a single remote for it" do
91
+ subject.should have(1).remote_names
92
+ end
93
+
94
+ it "should have a remote with the expected name" do
95
+ subject.remote_names.first.should == "origin"
96
+ end
97
+
98
+ it "should have the remote branch" do
99
+ subject.remote_branch_names["origin"].should include branch
100
+ end
101
+
102
+ it "should be checked out on the master" do
103
+ subject.should be_checked_out(master_sha)
104
+ end
105
+
106
+ context "checking out the branch" do
107
+ before do
108
+ subject.checkout! branch
109
+ end
110
+
111
+ it "should be checked out on the branch" do
112
+ subject.should be_checked_out(branch_sha)
113
+ end
114
+
115
+ it "should not be checked out on the master" do
116
+ subject.should_not be_checked_out(master_sha)
117
+ end
118
+ end
119
+
120
+ context "checking out the tag" do
121
+ before do
122
+ subject.checkout! tag
123
+ end
124
+
125
+ it "should be checked out on the tag" do
126
+ subject.should be_checked_out(tag_sha)
127
+ end
128
+
129
+ it "should not be checked out on the master" do
130
+ subject.should_not be_checked_out(master_sha)
131
+ end
132
+ end
133
+
134
+ context "checking out the annotated tag" do
135
+ before do
136
+ subject.checkout! atag
137
+ end
138
+
139
+ it "should be checked out on the annotated tag" do
140
+ subject.should be_checked_out(atag_sha)
141
+ end
142
+
143
+ it "should not be checked out on the master" do
144
+ subject.should_not be_checked_out(master_sha)
145
+ end
146
+ end
147
+ end
148
+
149
+ end