spec/gitscrub/level_spec.rb in gitscrub-0.0.5 vs spec/gitscrub/level_spec.rb in gitscrub-0.0.6

- old
+ new

@@ -11,17 +11,23 @@ "test" end solution do Grit::Repo.new("gitscrub/notadir") end + +hint do + puts "this is a hint" +end eof File.stub(:exists?).and_return(true) File.stub(:read).and_return(@file) @level = Gitscrub::Level.load(1) @repo = mock @repo.stub(:reset) Gitscrub::Repository.stub(:new).and_return(@repo) + Gitscrub::UI.stub(:puts) + Gitscrub::UI.stub(:print) end it "should mixin UI" do Gitscrub::Level.ancestors.should include(Gitscrub::UI) end @@ -96,9 +102,29 @@ it "should call reset on setup_level" do @repo.should_receive(:reset) @level.setup_level end + end + + describe "hint" do + it "should display a hint" do + @level.should_receive(:puts).with("this is a hint") + @level.show_hint + end + + it "should not call the hint if none exist" do + @level.instance_variable_set("@hint", nil) + lambda {@level.show_hint}.should_not raise_error(NoMethodError) + end + end + + describe "init_from_level" do + it "should copy the files from the level folder" do + FileUtils.should_receive(:cp_r).with("#{@level.level_path}/.", ".") + FileUtils.should_receive(:mv).with(".gitscrub", ".git") + @level.init_from_level + end end end