spec/shelly/app_spec.rb in shelly-0.0.48 vs spec/shelly/app_spec.rb in shelly-0.0.49.pre
- old
+ new
@@ -10,13 +10,27 @@
@app = Shelly::App.new
@app.code_name = "foo-staging"
end
describe ".guess_code_name" do
- it "should return name of current working directory" do
- Shelly::App.guess_code_name.should == "foo"
+ context "no Cloudfile" do
+ it "should return name of current working directory" do
+ Shelly::App.guess_code_name.should == "foo-staging"
+ end
end
+
+ context "with Cloudfile" do
+ it "should return production" do
+ File.open("Cloudfile", 'w') {|f| f.write("foo-staging:\n") }
+ Shelly::App.guess_code_name.should == "foo-production"
+ end
+
+ it "should return productionNUMBER" do
+ File.open("Cloudfile", 'w') {|f| f.write("foo-staging:\nfoo-production:\n") }
+ Shelly::App.guess_code_name.should == "foo-production1"
+ end
+ end
end
describe "#users" do
it "should fetch app's users" do
@client.should_receive(:app_users).with("foo-staging")
@@ -29,16 +43,24 @@
@app.stub(:git_url).and_return("git@git.shellycloud.com:foo-staging.git")
@app.stub(:system)
end
it "should try to remove existing git remote" do
- @app.should_receive(:system).with("git remote rm production > /dev/null 2>&1")
+ @app.should_receive(:system).with("git remote rm foo-staging > /dev/null 2>&1")
@app.add_git_remote
end
it "should add git remote with proper name and git repository" do
- @app.should_receive(:system).with("git remote add production git@git.shellycloud.com:foo-staging.git")
+ @app.should_receive(:system).with("git remote add foo-staging git@git.shellycloud.com:foo-staging.git")
@app.add_git_remote
+ end
+ end
+
+ describe "git_remote_exist" do
+ it "should return true if git remote exist" do
+ io = mock(:read => "origin\nfoo-staging")
+ IO.should_receive(:popen).with("git remote").and_return(io)
+ @app.git_remote_exist?.should be_true
end
end
describe "#configs" do
it "should get configs from client" do