spec/shelly/app_spec.rb in shelly-0.0.52 vs spec/shelly/app_spec.rb in shelly-0.0.53
- old
+ new
@@ -10,13 +10,32 @@
@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 production" do
+ File.open("Cloudfile", 'w') {|f| f.write("winnie-test:\n") }
+ Shelly::App.guess_code_name.should == "foo-staging"
+ 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 "#collaborations" do
it "should fetch app's users" do
@client.should_receive(:collaborations).with("foo-staging")
@@ -29,20 +48,28 @@
@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
@client.should_receive(:app_configs).with("foo-staging").and_return(config_response)
@app.configs.should == config_response
end
@@ -114,11 +141,11 @@
@app.databases = %w(postgresql mongodb)
@app.domains = %w(foo-staging.winniecloud.com foo.example.com)
FakeFS.deactivate!
expected = <<-config
foo-staging:
- ruby_version: 1.9.2 # 1.9.2 or ree
+ ruby_version: 1.9.2 # 1.9.2 or ree-1.8.7
environment: production # RAILS_ENV
monitoring_email: bob@example.com
domains:
- foo-staging.winniecloud.com
- foo.example.com
@@ -222,51 +249,27 @@
backup.filename.should == "backup.tar.gz"
end
end
describe "#create" do
- context "without providing domain" do
- it "should create the app on shelly cloud via API client" do
- @app.code_name = "fooo"
- attributes = {
- :code_name => "fooo",
- :domains => nil
- }
- @client.should_receive(:create_app).with(attributes).and_return("git_url" => "git@git.shellycloud.com:fooo.git",
- "domains" => %w(fooo.shellyapp.com))
- @app.create
- end
-
- it "should assign returned git_url, domains, ruby_version and environment" do
- @client.stub(:create_app).and_return("git_url" => "git@git.example.com:fooo.git",
- "domains" => ["fooo.shellyapp.com"], "ruby_version" => "1.9.2", "environment" => "production")
- @app.create
- @app.git_url.should == "git@git.example.com:fooo.git"
- @app.domains.should == ["fooo.shellyapp.com"]
- @app.ruby_version.should == "1.9.2"
- @app.environment.should == "production"
- end
+ it "should create the app on shelly cloud via API client" do
+ @app.code_name = "fooo"
+ attributes = {
+ :code_name => "fooo"
+ }
+ @client.should_receive(:create_app).with(attributes).and_return("git_url" => "git@git.shellycloud.com:fooo.git",
+ "domains" => %w(fooo.shellyapp.com))
+ @app.create
end
- context "with providing domain" do
- it "should create the app on shelly cloud via API client" do
- @app.code_name = "boo"
- @app.domains = ["boo.shellyapp.com", "boo.example.com"]
- attributes = {
- :code_name => "boo",
- :domains => %w(boo.shellyapp.com boo.example.com)
- }
- @client.should_receive(:create_app).with(attributes).and_return("git_url" => "git@git.shellycloud.com:fooo.git",
- "domains" => %w(boo.shellyapp.com boo.example.com))
- @app.create
- end
-
- it "should assign returned git_url and domain" do
- @client.stub(:create_app).and_return("git_url" => "git@git.example.com:fooo.git",
- "domains" => %w(boo.shellyapp.com boo.example.com))
- @app.create
- @app.domains.should == %w(boo.shellyapp.com boo.example.com)
- end
+ it "should assign returned git_url, domains, ruby_version and environment" do
+ @client.stub(:create_app).and_return("git_url" => "git@git.example.com:fooo.git",
+ "domains" => ["fooo.shellyapp.com"], "ruby_version" => "1.9.2", "environment" => "production")
+ @app.create
+ @app.git_url.should == "git@git.example.com:fooo.git"
+ @app.domains.should == ["fooo.shellyapp.com"]
+ @app.ruby_version.should == "1.9.2"
+ @app.environment.should == "production"
end
end
describe "#redeploy" do
it "should redeploy app via API" do