githug 0.2.11 → 0.2.12
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENCE.txt +22 -0
- data/README.md +39 -30
- data/levels/add.rb +2 -1
- data/levels/bisect.rb +1 -1
- data/levels/blame/config.rb +1 -1
- data/levels/branch_at.rb +1 -1
- data/levels/commit_amend.rb +1 -1
- data/levels/config.rb +2 -2
- data/levels/ignore.rb +5 -1
- data/levels/log.rb +2 -2
- data/levels/merge.rb +1 -1
- data/levels/merge_squash.rb +4 -4
- data/levels/rm.rb +1 -1
- data/levels/stash/.githug/COMMIT_EDITMSG +1 -0
- data/levels/stash/.githug/HEAD +1 -0
- data/levels/stash/.githug/config +7 -0
- data/levels/stash/.githug/description +1 -0
- data/levels/stash/.githug/hooks/applypatch-msg.sample +15 -0
- data/levels/stash/.githug/hooks/commit-msg.sample +24 -0
- data/levels/stash/.githug/hooks/post-update.sample +8 -0
- data/levels/stash/.githug/hooks/pre-applypatch.sample +14 -0
- data/levels/stash/.githug/hooks/pre-commit.sample +50 -0
- data/levels/stash/.githug/hooks/pre-rebase.sample +169 -0
- data/levels/stash/.githug/hooks/prepare-commit-msg.sample +36 -0
- data/levels/stash/.githug/hooks/update.sample +128 -0
- data/levels/stash/.githug/index +0 -0
- data/levels/stash/.githug/info/exclude +6 -0
- data/levels/stash/.githug/logs/HEAD +1 -0
- data/levels/stash/.githug/logs/refs/heads/master +1 -0
- data/levels/stash/.githug/objects/02/060592b31c9e12ffe1b282addf9537c5ef8e1f +0 -0
- data/levels/stash/.githug/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
- data/levels/stash/.githug/objects/7f/82d7e4fba66980af16da540e18d8955518cdc2 +0 -0
- data/levels/stash/.githug/objects/85/e560abcd7e3255dcd91982476e432f4d3d1b51 +0 -0
- data/levels/stash/.githug/refs/heads/master +1 -0
- data/levels/stash/lyrics.txt +13 -0
- data/levels/stash.rb +16 -0
- data/levels/status.rb +1 -1
- data/lib/githug/cli.rb +2 -2
- data/lib/githug/game.rb +1 -1
- data/lib/githug/level.rb +14 -12
- data/lib/githug/profile.rb +1 -1
- data/lib/githug/repository.rb +3 -3
- data/lib/githug/ui.rb +6 -15
- data/lib/githug/version.rb +1 -1
- data/spec/githug/cli_spec.rb +11 -11
- data/spec/githug/game_spec.rb +6 -6
- data/spec/githug/level_spec.rb +17 -17
- data/spec/githug/profile_spec.rb +4 -4
- data/spec/githug/repository_spec.rb +14 -14
- data/spec/githug/ui_spec.rb +13 -11
- data/spec/githug_spec.rb +242 -0
- metadata +93 -55
@@ -0,0 +1,128 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
# An example hook script to blocks unannotated tags from entering.
|
4
|
+
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
|
5
|
+
#
|
6
|
+
# To enable this hook, rename this file to "update".
|
7
|
+
#
|
8
|
+
# Config
|
9
|
+
# ------
|
10
|
+
# hooks.allowunannotated
|
11
|
+
# This boolean sets whether unannotated tags will be allowed into the
|
12
|
+
# repository. By default they won't be.
|
13
|
+
# hooks.allowdeletetag
|
14
|
+
# This boolean sets whether deleting tags will be allowed in the
|
15
|
+
# repository. By default they won't be.
|
16
|
+
# hooks.allowmodifytag
|
17
|
+
# This boolean sets whether a tag may be modified after creation. By default
|
18
|
+
# it won't be.
|
19
|
+
# hooks.allowdeletebranch
|
20
|
+
# This boolean sets whether deleting branches will be allowed in the
|
21
|
+
# repository. By default they won't be.
|
22
|
+
# hooks.denycreatebranch
|
23
|
+
# This boolean sets whether remotely creating branches will be denied
|
24
|
+
# in the repository. By default this is allowed.
|
25
|
+
#
|
26
|
+
|
27
|
+
# --- Command line
|
28
|
+
refname="$1"
|
29
|
+
oldrev="$2"
|
30
|
+
newrev="$3"
|
31
|
+
|
32
|
+
# --- Safety check
|
33
|
+
if [ -z "$GIT_DIR" ]; then
|
34
|
+
echo "Don't run this script from the command line." >&2
|
35
|
+
echo " (if you want, you could supply GIT_DIR then run" >&2
|
36
|
+
echo " $0 <ref> <oldrev> <newrev>)" >&2
|
37
|
+
exit 1
|
38
|
+
fi
|
39
|
+
|
40
|
+
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
|
41
|
+
echo "Usage: $0 <ref> <oldrev> <newrev>" >&2
|
42
|
+
exit 1
|
43
|
+
fi
|
44
|
+
|
45
|
+
# --- Config
|
46
|
+
allowunannotated=$(git config --bool hooks.allowunannotated)
|
47
|
+
allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
|
48
|
+
denycreatebranch=$(git config --bool hooks.denycreatebranch)
|
49
|
+
allowdeletetag=$(git config --bool hooks.allowdeletetag)
|
50
|
+
allowmodifytag=$(git config --bool hooks.allowmodifytag)
|
51
|
+
|
52
|
+
# check for no description
|
53
|
+
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
|
54
|
+
case "$projectdesc" in
|
55
|
+
"Unnamed repository"* | "")
|
56
|
+
echo "*** Project description file hasn't been set" >&2
|
57
|
+
exit 1
|
58
|
+
;;
|
59
|
+
esac
|
60
|
+
|
61
|
+
# --- Check types
|
62
|
+
# if $newrev is 0000...0000, it's a commit to delete a ref.
|
63
|
+
zero="0000000000000000000000000000000000000000"
|
64
|
+
if [ "$newrev" = "$zero" ]; then
|
65
|
+
newrev_type=delete
|
66
|
+
else
|
67
|
+
newrev_type=$(git cat-file -t $newrev)
|
68
|
+
fi
|
69
|
+
|
70
|
+
case "$refname","$newrev_type" in
|
71
|
+
refs/tags/*,commit)
|
72
|
+
# un-annotated tag
|
73
|
+
short_refname=${refname##refs/tags/}
|
74
|
+
if [ "$allowunannotated" != "true" ]; then
|
75
|
+
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
|
76
|
+
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
|
77
|
+
exit 1
|
78
|
+
fi
|
79
|
+
;;
|
80
|
+
refs/tags/*,delete)
|
81
|
+
# delete tag
|
82
|
+
if [ "$allowdeletetag" != "true" ]; then
|
83
|
+
echo "*** Deleting a tag is not allowed in this repository" >&2
|
84
|
+
exit 1
|
85
|
+
fi
|
86
|
+
;;
|
87
|
+
refs/tags/*,tag)
|
88
|
+
# annotated tag
|
89
|
+
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
|
90
|
+
then
|
91
|
+
echo "*** Tag '$refname' already exists." >&2
|
92
|
+
echo "*** Modifying a tag is not allowed in this repository." >&2
|
93
|
+
exit 1
|
94
|
+
fi
|
95
|
+
;;
|
96
|
+
refs/heads/*,commit)
|
97
|
+
# branch
|
98
|
+
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
|
99
|
+
echo "*** Creating a branch is not allowed in this repository" >&2
|
100
|
+
exit 1
|
101
|
+
fi
|
102
|
+
;;
|
103
|
+
refs/heads/*,delete)
|
104
|
+
# delete branch
|
105
|
+
if [ "$allowdeletebranch" != "true" ]; then
|
106
|
+
echo "*** Deleting a branch is not allowed in this repository" >&2
|
107
|
+
exit 1
|
108
|
+
fi
|
109
|
+
;;
|
110
|
+
refs/remotes/*,commit)
|
111
|
+
# tracking branch
|
112
|
+
;;
|
113
|
+
refs/remotes/*,delete)
|
114
|
+
# delete tracking branch
|
115
|
+
if [ "$allowdeletebranch" != "true" ]; then
|
116
|
+
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
|
117
|
+
exit 1
|
118
|
+
fi
|
119
|
+
;;
|
120
|
+
*)
|
121
|
+
# Anything else (is there anything else?)
|
122
|
+
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
|
123
|
+
exit 1
|
124
|
+
;;
|
125
|
+
esac
|
126
|
+
|
127
|
+
# --- Finished
|
128
|
+
exit 0
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
0000000000000000000000000000000000000000 02060592b31c9e12ffe1b282addf9537c5ef8e1f Anton Vasin <magnumsmail@gmail.com> 1354518787 +0400 commit (initial): Add some lyrics
|
@@ -0,0 +1 @@
|
|
1
|
+
0000000000000000000000000000000000000000 02060592b31c9e12ffe1b282addf9537c5ef8e1f Anton Vasin <magnumsmail@gmail.com> 1354518787 +0400 commit (initial): Add some lyrics
|
@@ -0,0 +1 @@
|
|
1
|
+
02060592b31c9e12ffe1b282addf9537c5ef8e1f
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Down in Louisiana in that sunny clime,
|
2
|
+
They play a class of music that is super fine,
|
3
|
+
And it makes no difference if its rain or shine,
|
4
|
+
You can hear that that jazz band music playing all the time.
|
5
|
+
It sounds so peculiar cause the music's queer.
|
6
|
+
How its sweet vibration seem to fill the air.
|
7
|
+
Then to you the whole world seems to be in rhyme.
|
8
|
+
You want nothing else but blues-band music all the time.
|
9
|
+
|
10
|
+
Ev'ry one that's nigh
|
11
|
+
Never seems to sigh,
|
12
|
+
Hear them loudly cry:
|
13
|
+
Hey!
|
data/levels/stash.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
difficulty 2
|
2
|
+
description "You've made some changes and want to work on them later. You should save them, but don't commit them"
|
3
|
+
|
4
|
+
setup do
|
5
|
+
init_from_level
|
6
|
+
end
|
7
|
+
|
8
|
+
solution do
|
9
|
+
return false if `git stash list` !~ /stash@\{0\}/
|
10
|
+
return false if repo.status.changed.to_a.flatten.include? "lyrics.txt"
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
hint do
|
15
|
+
puts "It's like stashing. Try finding appropriate git command"
|
16
|
+
end
|
data/levels/status.rb
CHANGED
data/lib/githug/cli.rb
CHANGED
@@ -21,7 +21,7 @@ module Githug
|
|
21
21
|
def test(path)
|
22
22
|
UI.word_box("Githug")
|
23
23
|
make_directory
|
24
|
-
level = Level.load_from_file(path)
|
24
|
+
level = Level.load_from_file(path)
|
25
25
|
game = Game.new
|
26
26
|
game.test_level(level, options[:errors])
|
27
27
|
end
|
@@ -61,7 +61,7 @@ module Githug
|
|
61
61
|
|
62
62
|
|
63
63
|
def make_directory
|
64
|
-
if File.exists?("./git_hug")
|
64
|
+
if File.exists?("./git_hug")
|
65
65
|
UI.puts "Please change into the git_hug directory"
|
66
66
|
exit
|
67
67
|
end
|
data/lib/githug/game.rb
CHANGED
data/lib/githug/level.rb
CHANGED
@@ -4,17 +4,18 @@ module Githug
|
|
4
4
|
|
5
5
|
LEVELS = [nil, "init", "add", "commit", "config", "clone",
|
6
6
|
"clone_to_folder", "ignore", "status", "rm", "rm_cached",
|
7
|
-
"rename", "log", "tag", "commit_amend", "reset",
|
8
|
-
"checkout_file", "remote", "remote_url", "pull",
|
9
|
-
"push", "diff", "blame", "branch", "checkout",
|
10
|
-
"branch_at", "merge", "cherry-pick",
|
11
|
-
"
|
12
|
-
"
|
7
|
+
"stash", "rename", "log", "tag", "commit_amend", "reset",
|
8
|
+
"reset_soft", "checkout_file", "remote", "remote_url", "pull",
|
9
|
+
"remote_add", "push", "diff", "blame", "branch", "checkout",
|
10
|
+
"checkout_tag", "branch_at", "merge", "cherry-pick",
|
11
|
+
"rename_commit", "squash", "merge_squash", "reorder", "bisect",
|
12
|
+
"stage_lines", "find_old_branch", "revert", "restore",
|
13
|
+
"conflict", "contribute"]
|
13
14
|
|
14
15
|
attr_accessor :level_no, :level_path
|
15
|
-
|
16
|
+
|
16
17
|
class << self
|
17
|
-
|
18
|
+
|
18
19
|
def load(level_name)
|
19
20
|
path = "#{File.dirname(__FILE__)}/../../levels/#{level_name}.rb"
|
20
21
|
setup(path)
|
@@ -27,10 +28,11 @@ module Githug
|
|
27
28
|
|
28
29
|
def setup(path)
|
29
30
|
level_name = File.basename(path, File.extname(path))
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
level_path = path.chomp(File.extname(path))
|
32
|
+
level = self.new
|
33
|
+
|
33
34
|
return false unless File.exists?(path)
|
35
|
+
|
34
36
|
level.instance_eval(File.read(path))
|
35
37
|
level.level_no = LEVELS.index(level_name) || 1
|
36
38
|
level.level_path = level_path
|
@@ -57,7 +59,7 @@ module Githug
|
|
57
59
|
end
|
58
60
|
|
59
61
|
def setup(&block)
|
60
|
-
@setup = block
|
62
|
+
@setup = block
|
61
63
|
end
|
62
64
|
|
63
65
|
def hint(&hint)
|
data/lib/githug/profile.rb
CHANGED
data/lib/githug/repository.rb
CHANGED
@@ -2,7 +2,7 @@ module Githug
|
|
2
2
|
class Repository
|
3
3
|
|
4
4
|
attr_accessor :grit
|
5
|
-
|
5
|
+
|
6
6
|
def initialize(location = ".")
|
7
7
|
@grit = Grit::Repo.new(location)
|
8
8
|
rescue Grit::InvalidGitRepositoryError
|
@@ -13,7 +13,7 @@ module Githug
|
|
13
13
|
dont_delete = ["..", ".", ".profile.yml"]
|
14
14
|
if File.basename(Dir.pwd) == "git_hug"
|
15
15
|
Dir.entries(Dir.pwd).each do |file|
|
16
|
-
FileUtils.rm_rf(file) unless dont_delete.include?(file)
|
16
|
+
FileUtils.rm_rf(file) unless dont_delete.include?(file)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
create_gitignore
|
@@ -37,7 +37,7 @@ module Githug
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def method_missing(method, *args, &block)
|
40
|
-
if @grit && @grit.respond_to?(method)
|
40
|
+
if @grit && @grit.respond_to?(method)
|
41
41
|
return @grit.send(method, *args, &block)
|
42
42
|
end
|
43
43
|
super
|
data/lib/githug/ui.rb
CHANGED
@@ -5,7 +5,7 @@ module Githug
|
|
5
5
|
@@in_stream = STDIN
|
6
6
|
|
7
7
|
class << self
|
8
|
-
|
8
|
+
|
9
9
|
def out_stream=(out)
|
10
10
|
@@out_stream = out
|
11
11
|
end
|
@@ -26,26 +26,17 @@ module Githug
|
|
26
26
|
@@in_stream.gets
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
puts
|
31
|
-
|
32
|
-
|
33
|
-
def word_box(string)
|
34
|
-
space_length = (80/2) - ((string.length/2)+1)
|
35
|
-
line
|
36
|
-
print "*"
|
37
|
-
print " "*space_length
|
38
|
-
print string
|
39
|
-
print " "*space_length
|
40
|
-
puts "*"
|
41
|
-
line
|
29
|
+
def word_box(string,width=80,char='*')
|
30
|
+
puts char*width
|
31
|
+
puts "#{char}#{string.center(width-2)}#{char}"
|
32
|
+
puts char*width
|
42
33
|
end
|
43
34
|
|
44
35
|
def request(msg)
|
45
36
|
print("#{msg} ")
|
46
37
|
gets.chomp
|
47
38
|
end
|
48
|
-
|
39
|
+
|
49
40
|
def ask(msg)
|
50
41
|
request("#{msg} [yn] ") == 'y'
|
51
42
|
end
|
data/lib/githug/version.rb
CHANGED
data/spec/githug/cli_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require 'githug/cli'
|
3
3
|
|
4
4
|
describe Githug::CLI do
|
5
|
-
|
5
|
+
|
6
6
|
before(:each) do
|
7
7
|
game = mock.as_null_object
|
8
8
|
@cli = Githug::CLI.new
|
@@ -11,12 +11,12 @@ describe Githug::CLI do
|
|
11
11
|
|
12
12
|
it "should print the logo" do
|
13
13
|
Githug::UI.should_receive(:word_box).with("Githug")
|
14
|
-
@cli.stub(:make_directory)
|
14
|
+
@cli.stub(:make_directory)
|
15
15
|
@cli.play
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should create a directory if one does not exist" do
|
19
|
-
Githug::UI.stub(:ask).and_return(true)
|
19
|
+
Githug::UI.stub(:ask).and_return(true)
|
20
20
|
Dir.should_receive(:mkdir).with("./git_hug")
|
21
21
|
Dir.should_receive(:chdir).with("git_hug")
|
22
22
|
@cli.make_directory
|
@@ -25,16 +25,16 @@ describe Githug::CLI do
|
|
25
25
|
it "should not make a directory if you are in the game directory" do
|
26
26
|
Dir.stub(:pwd).and_return("/home/git_hug")
|
27
27
|
Githug::UI.should_not_receive(:ask)
|
28
|
-
@cli.make_directory
|
28
|
+
@cli.make_directory
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should exit if the user selects no" do
|
32
|
-
Githug::UI.stub(:ask).and_return(false)
|
32
|
+
Githug::UI.stub(:ask).and_return(false)
|
33
33
|
lambda {@cli.make_directory}.should raise_error(SystemExit)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should prompt to change into the directory if it exists" do
|
37
|
-
File.stub(:exists?).and_return(true)
|
37
|
+
File.stub(:exists?).and_return(true)
|
38
38
|
Githug::UI.should_receive(:puts).with("Please change into the git_hug directory")
|
39
39
|
lambda {@cli.make_directory}.should raise_error(SystemExit)
|
40
40
|
end
|
@@ -44,7 +44,7 @@ describe Githug::CLI do
|
|
44
44
|
level = mock
|
45
45
|
game = mock
|
46
46
|
@cli.stub(:make_directory)
|
47
|
-
Githug::Level.should_receive(:load_from_file).with("/foo/bar/test/level.rb").and_return(level)
|
47
|
+
Githug::Level.should_receive(:load_from_file).with("/foo/bar/test/level.rb").and_return(level)
|
48
48
|
Githug::Game.stub(:new).and_return(game)
|
49
49
|
game.should_receive(:test_level).with(level, anything)
|
50
50
|
@cli.test("/foo/bar/test/level.rb")
|
@@ -67,8 +67,8 @@ describe Githug::CLI do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
describe "reset" do
|
70
|
-
|
71
|
-
|
70
|
+
|
71
|
+
|
72
72
|
it "should reset the current level" do
|
73
73
|
@level.should_receive(:setup_level)
|
74
74
|
@level.should_receive(:full_description)
|
@@ -92,8 +92,8 @@ describe Githug::CLI do
|
|
92
92
|
Githug::UI.should_receive(:puts).with("resetting level")
|
93
93
|
@cli.reset("/foo/bar/level.rb")
|
94
94
|
end
|
95
|
-
end
|
95
|
+
end
|
96
96
|
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
end
|
data/spec/githug/game_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Githug::Game do
|
4
|
-
|
4
|
+
|
5
5
|
before(:each) do
|
6
6
|
@profile = mock.as_null_object
|
7
7
|
Githug::Profile.stub(:new).and_return(@profile)
|
@@ -64,13 +64,13 @@ describe Githug::Game do
|
|
64
64
|
|
65
65
|
describe "test_level" do
|
66
66
|
it "Should output Valid solution if the solution is valid" do
|
67
|
-
@level.stub(:solve).and_return(true)
|
67
|
+
@level.stub(:solve).and_return(true)
|
68
68
|
Githug::UI.should_receive(:success).with("Valid solution")
|
69
69
|
@game.test_level(@level)
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
it "Should output Invalid solution if the solution is invalid" do
|
73
|
-
@level.stub(:solve).and_return(false)
|
73
|
+
@level.stub(:solve).and_return(false)
|
74
74
|
Githug::UI.should_receive(:error).with("Invalid solution")
|
75
75
|
@game.test_level(@level)
|
76
76
|
end
|
@@ -88,9 +88,9 @@ describe Githug::Game do
|
|
88
88
|
end
|
89
89
|
|
90
90
|
it "should call setup_level for the next level" do
|
91
|
-
@level.should_receive(:setup_level)
|
91
|
+
@level.should_receive(:setup_level)
|
92
92
|
@profile.stub(:level=)
|
93
93
|
@game.level_bump
|
94
94
|
end
|
95
|
-
|
95
|
+
|
96
96
|
end
|
data/spec/githug/level_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require 'grit'
|
3
3
|
|
4
4
|
describe Githug::Level do
|
5
|
-
|
5
|
+
|
6
6
|
before(:each) do
|
7
7
|
@file = <<-eof
|
8
8
|
difficulty 1
|
@@ -26,7 +26,7 @@ end
|
|
26
26
|
File.stub(:read).and_return(@file)
|
27
27
|
@level = Githug::Level.load("init")
|
28
28
|
@repo = mock
|
29
|
-
@repo.stub(:reset)
|
29
|
+
@repo.stub(:reset)
|
30
30
|
Githug::Repository.stub(:new).and_return(@repo)
|
31
31
|
Githug::UI.stub(:puts)
|
32
32
|
Githug::UI.stub(:print)
|
@@ -38,7 +38,7 @@ end
|
|
38
38
|
|
39
39
|
|
40
40
|
describe "load" do
|
41
|
-
|
41
|
+
|
42
42
|
it "should load the level" do
|
43
43
|
File.stub(:dirname).and_return("")
|
44
44
|
File.should_receive(:read).with('/../../levels/init.rb').and_return(@file)
|
@@ -80,13 +80,13 @@ end
|
|
80
80
|
|
81
81
|
|
82
82
|
describe "solve" do
|
83
|
-
|
83
|
+
|
84
84
|
it "should solve the problem" do
|
85
85
|
@level.solve.should eql(false)
|
86
86
|
end
|
87
87
|
|
88
88
|
it "should return true if the requirements have been met" do
|
89
|
-
Grit::Repo.stub(:new).and_return(true)
|
89
|
+
Grit::Repo.stub(:new).and_return(true)
|
90
90
|
@level.solve.should eql(true)
|
91
91
|
end
|
92
92
|
|
@@ -94,9 +94,9 @@ end
|
|
94
94
|
|
95
95
|
describe "test" do
|
96
96
|
it "should call solve" do
|
97
|
-
@level.instance_variable_get("@solution").should_receive(:call)
|
97
|
+
@level.instance_variable_get("@solution").should_receive(:call)
|
98
98
|
@level.test
|
99
|
-
end
|
99
|
+
end
|
100
100
|
end
|
101
101
|
|
102
102
|
|
@@ -115,7 +115,7 @@ end
|
|
115
115
|
describe "setup" do
|
116
116
|
|
117
117
|
it "should call setup" do
|
118
|
-
@level.setup_level.should eql("test")
|
118
|
+
@level.setup_level.should eql("test")
|
119
119
|
end
|
120
120
|
|
121
121
|
it "should not call the setup if none exists" do
|
@@ -124,10 +124,10 @@ end
|
|
124
124
|
end
|
125
125
|
|
126
126
|
end
|
127
|
-
|
127
|
+
|
128
128
|
|
129
129
|
describe "repo" do
|
130
|
-
|
130
|
+
|
131
131
|
it "should initialize a repository when repo is called" do
|
132
132
|
@level.repo.should equal(@repo)
|
133
133
|
Githug::Repository.should_not_receive(:new)
|
@@ -135,14 +135,14 @@ end
|
|
135
135
|
end
|
136
136
|
|
137
137
|
it "should call reset on setup_level" do
|
138
|
-
@repo.should_receive(:reset)
|
138
|
+
@repo.should_receive(:reset)
|
139
139
|
@level.setup_level
|
140
140
|
end
|
141
141
|
|
142
142
|
end
|
143
143
|
|
144
144
|
describe "hint" do
|
145
|
-
|
145
|
+
|
146
146
|
before(:each) do
|
147
147
|
@profile = mock.as_null_object
|
148
148
|
Githug::Profile.stub(:load).and_return(@profile)
|
@@ -152,10 +152,10 @@ end
|
|
152
152
|
it "should return sequential hint if there are multiple" do
|
153
153
|
@level.should_receive(:puts).ordered.with("this is hint 1")
|
154
154
|
@level.show_hint
|
155
|
-
|
155
|
+
|
156
156
|
@level.should_receive(:puts).ordered.with("this is hint 2")
|
157
157
|
@level.show_hint
|
158
|
-
|
158
|
+
|
159
159
|
@level.should_receive(:puts).ordered.with("this is hint 1")
|
160
160
|
@level.show_hint
|
161
161
|
end
|
@@ -163,7 +163,7 @@ end
|
|
163
163
|
it "should display a hint if there are not multiple" do
|
164
164
|
@level.instance_variable_set("@hints", nil)
|
165
165
|
@level.should_receive(:puts).with("this is a hint")
|
166
|
-
@level.show_hint
|
166
|
+
@level.show_hint
|
167
167
|
end
|
168
168
|
|
169
169
|
it "should not call the hint if none exist" do
|
@@ -174,9 +174,9 @@ end
|
|
174
174
|
|
175
175
|
describe "init_from_level" do
|
176
176
|
it "should copy the files from the level folder" do
|
177
|
-
FileUtils.should_receive(:cp_r).with("#{@level.level_path}/.", ".")
|
177
|
+
FileUtils.should_receive(:cp_r).with("#{@level.level_path}/.", ".")
|
178
178
|
FileUtils.should_receive(:mv).with(".githug", ".git")
|
179
179
|
@level.init_from_level
|
180
|
-
end
|
180
|
+
end
|
181
181
|
end
|
182
182
|
end
|
data/spec/githug/profile_spec.rb
CHANGED
@@ -34,16 +34,16 @@ describe Githug::Profile do
|
|
34
34
|
describe "level_bump" do
|
35
35
|
before(:each) do
|
36
36
|
@profile = Githug::Profile.load
|
37
|
-
@levels = Githug::Level::LEVELS
|
37
|
+
@levels = Githug::Level::LEVELS
|
38
38
|
Githug::Level::LEVELS = ["init", "add", "rm", "rm_cached", "diff"]
|
39
39
|
@profile.level = "init"
|
40
40
|
@profile.should_receive(:save)
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
after(:each) do
|
44
44
|
Githug::Level::LEVELS = @levels
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
it "should bump the level" do
|
48
48
|
@profile.level_bump.should eql("add")
|
49
49
|
end
|
@@ -61,5 +61,5 @@ describe Githug::Profile do
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
|
64
|
+
|
65
65
|
end
|