spec/hubbard_spec.rb in hubbard-0.0.16 vs spec/hubbard_spec.rb in hubbard-0.0.18

- old
+ new

@@ -1,9 +1,9 @@ require 'spec_helper' require 'fileutils' -describe "Hubble" do +describe "Hubbard" do before(:each) do reset_file_system end after(:all) do @@ -12,71 +12,76 @@ it "should pass exitstatus along from SystemCallError" do pending "Not sure how to make sure that hubbard is passing back the proper exit codes from SystemCallErrors. Doing so would introduce complexity or add something that shouldn't be callable." end - it "should create project" do - hub("kipper", "create-project foo foo-desc") + it "should create project and set project description" do + hub("kipper", "create-project foo") + hub("kipper", "set-description foo foo-desc") projects = list_projects('kipper') projects.should == ["foo"] end it "should set project description" do - hub("kipper", "create-project foo old-desc") - hub("kipper", "set-description foo new-desc") + hub("kipper", "create-project foo") + hub("kipper", "set-description foo 'Test description contains a space.'") project = hub("kipper", "list-projects").split("\n")[0].split - project[2].should == "new-desc" + project_name = project.shift # throw away unused arg. + visibility = project.shift # throw away unused arg. + description = project.join(' ') + description.should == "Test description contains a space." end it "should set project visibility" do - hub("kipper", "create-project foo foo-desc") + create_project("kipper", "foo", "foo-desc") hub("kipper", "set-visibility foo private") project = hub("kipper", "list-projects").split("\n")[0].split project[1].should == "private" end it "should rename project" do - hub("kipper", "create-project foo foo-desc") + create_project("kipper", "foo", "foo-desc") hub("kipper", "rename-project foo bar") project = hub("kipper", "list-projects").split("\n")[0].split project[0].should == "bar" end it "should not allow multiple projects with same name" do - hub("kipper", "create-project foo foo-desc") + create_project("kipper", "foo", "foo-desc") lambda { hub("kipper", "create-project foo") }.should raise_error end it "should delete project" do - hub("kipper", "create-project foo foo-desc") + create_project("kipper", "foo", "foo-desc") hub("kipper", "delete-project foo") projects = hub("kipper", "list-projects").split("\n") projects.should == [] end it "should default to public project" do - hub("kipper", "create-project foo foo-desc") + create_project("kipper", "foo", "foo-desc") # Other users can see... projects = list_projects("tiger") projects.should == ["foo"] # But not delete lambda { hub("tiger", "delete-project foo") }.should raise_error end it "should support private project" do - hub("kipper", "create-project foo foo-desc --private") + hub("kipper", "create-project foo --private") + hub("kipper", "set-description foo new-desc") # Other users can't see projects = hub("tiger", "list-projects").split("\n") projects.should == [] end it "should create repositories" do - hub("kipper", "create-project foo foo-desc") + create_project("kipper", "foo", "foo-desc") hub("kipper", "create-repository foo bar") repositories = hub("kipper", "list-repositories foo").split("\n") repositories.length.should == 1 name,url = repositories[0].split @@ -84,11 +89,11 @@ url.should == "#{ENV['USER']}@#{HUB_HOST}:foo/bar.git" end describe "when admin creates a project" do before(:each) do - hub("admin", "create-project foo foo-desc") + create_project("admin", "foo", "foo-desc") end it "should not raise error on missing permissions file for non-admin listing permissions" do lambda { hub("kipper", "list-permissions foo") }.should_not raise_error(Errno::ENOENT) end @@ -109,62 +114,63 @@ yield end end it "should allow git push" do - hub("kipper", "create-project foo foo-desc") + create_project("kipper", "foo", "foo-desc") hub("kipper", "create-repository foo bar") with_test_project do git("kipper", "push #{ENV['USER']}@#{HUB_HOST}:foo/bar.git master") end end it "should move repository" do - hub("kipper", "create-project foo foo-desc") - hub("kipper", "create-project new-foo foo-desc") + create_project("kipper", "foo", "foo-desc") + create_project("kipper", "new-foo", "foo-desc") hub("kipper", "create-repository foo bar") with_test_project do git("kipper", "push #{ENV['USER']}@#{HUB_HOST}:foo/bar.git master") hub("kipper", "move-repository foo bar new-foo baz") git("kipper", "push #{ENV['USER']}@#{HUB_HOST}:new-foo/baz.git master") end end it "should allow git push with write permissions" do - hub("kipper", "create-project foo foo-desc") + create_project("kipper", "foo", "foo-desc") hub("kipper", "add-permission foo tiger write") hub("kipper", "create-repository foo bar") with_test_project do git("tiger", "push #{ENV['USER']}@#{HUB_HOST}:foo/bar.git master") end end it "should not allow git push with read permissions" do - hub("kipper", "create-project foo foo-desc") + create_project("kipper", "foo", "foo-desc") hub("kipper", "add-permission foo tiger read") hub("kipper", "create-repository foo bar") with_test_project do lambda { git("tiger", "push #{ENV['USER']}@#{HUB_HOST}:foo/bar.git master") }.should raise_error end end it "should allow git pull" do - hub("kipper", "create-project foo foo-desc") + create_project("kipper", "foo", "foo-desc") hub("kipper", "create-repository foo bar") with_test_project do git("kipper", "push #{ENV['USER']}@#{HUB_HOST}:foo/bar.git master") git("kipper", "pull #{ENV['USER']}@#{HUB_HOST}:foo/bar.git master") end end it "should not allow git pull with no permissions" do - hub("kipper", "create-project foo foo-desc --private") + hub("kipper", "create-project foo --private") + hub("kipper", "set-description foo foo-desc") hub("kipper", "create-repository foo bar") with_test_project do git("kipper", "push #{ENV['USER']}@#{HUB_HOST}:foo/bar.git master") lambda { git("tiger", "pull #{ENV['USER']}@#{HUB_HOST}:foo/bar.git master") }.should raise_error @@ -180,46 +186,46 @@ git("tiger", "pull #{ENV['USER']}@#{HUB_HOST}:foo/bar.git master") end end it "should fork repository in same project" do - hub("kipper", "create-project foo foo-desc") + create_project("kipper", "foo", "foo-desc") hub("kipper", "create-repository foo bar") with_test_project do git("kipper", "push #{ENV['USER']}@#{HUB_HOST}:foo/bar.git master") hub("kipper", "fork-repository foo bar foo bar2") git("kipper", "pull #{ENV['USER']}@#{HUB_HOST}:foo/bar2.git master") end end it "should fork repository in different project" do - hub("kipper", "create-project foo foo-desc") - hub("kipper", "create-project foo2 foo2-desc") + create_project("kipper", "foo", "foo-desc") + create_project("kipper", "foo2", "foo2-desc") hub("kipper", "create-repository foo bar") with_test_project do git("kipper", "push #{ENV['USER']}@#{HUB_HOST}:foo/bar.git master") hub("kipper", "fork-repository foo bar foo2 bar2") git("kipper", "pull #{ENV['USER']}@#{HUB_HOST}:foo2/bar2.git master") end end it "should track projects related by forking" do - hub("kipper", "create-project foo foo-desc") + create_project("kipper", "foo", "foo-desc") hub("kipper", "create-repository foo bar") with_test_project do git("kipper", "push #{ENV['USER']}@#{HUB_HOST}:foo/bar.git master") hub("kipper", "fork-repository foo bar foo bar2") hub("kipper", "list-forks foo bar").should == "foo/bar\nfoo/bar2\n" end end it "should require read access to fork repository" do - hub("kipper", "create-project foo foo-desc") - hub("kipper", "create-project foo2 foo-desc") + create_project("kipper", "foo", "foo-desc") + create_project("kipper", "foo2", "foo2-desc") hub("kipper", "create-repository foo bar") with_test_project do git("kipper", "push #{ENV['USER']}@#{HUB_HOST}:foo/bar.git master") lambda { hub("tiger", "fork-repository foo bar foo2 bar2") }.should raise_error @@ -232,11 +238,11 @@ hub("kipper", "add-permission foo2 tiger admin") end end it "should remove permission" do - hub("kipper", "create-project foo foo-desc") + create_project("kipper", "foo", "foo-desc") hub("kipper", "create-repository foo bar") hub("kipper", "add-permission foo tiger read") hub("kipper", "remove-permission foo tiger") with_test_project do @@ -259,10 +265,11 @@ hub("kipper", "add-key laptop", "ssh-rsa yabbadabba fdsa") lambda { hub("kipper", "list-users") }.should raise_error end it "should allow admin to run-as another user" do - hub("admin", "run-as kipper create-project foo foo-desc") + hub("admin", "run-as kipper create-project foo") + hub("admin", "run-as kipper set-description foo foo-desc") projects = list_projects("kipper") projects.should == ["foo"] end end