spec/shelly/cli/main_spec.rb in shelly-0.1.24 vs spec/shelly/cli/main_spec.rb in shelly-0.1.25
- old
+ new
@@ -613,11 +613,13 @@
end
# this tests multiple_clouds method used in majority of tasks
context "multiple clouds in Cloudfile" do
before do
- File.open("Cloudfile", 'w') {|f| f.write("foo-staging:\nfoo-production:\n") }
+ Shelly::App.unstub(:new)
+ File.open("Cloudfile", 'w') {|f|
+ f.write("foo-staging:\nfoo-production:\n") }
end
it "should show information to start specific cloud and exit" do
$stdout.should_receive(:puts).with(red "You have multiple clouds in Cloudfile.")
$stdout.should_receive(:puts).with("Select cloud using `shelly start --cloud foo-production`")
@@ -707,11 +709,11 @@
FileUtils.mkdir_p("/projects/foo")
Dir.chdir("/projects/foo")
File.open("Cloudfile", 'w') {|f| f.write("foo-production:\n") }
Shelly::User.stub(:new).and_return(@user)
@client.stub(:apps).and_return([{"code_name" => "foo-production"}, {"code_name" => "foo-staging"}])
- @app = Shelly::App.new
+ @app = Shelly::App.new("foo-production")
Shelly::App.stub(:new).and_return(@app)
end
it "should ensure user has logged in" do
hooks(@main, :stop).should include(:logged_in?)
@@ -940,11 +942,11 @@
describe "#delete" do
before do
Shelly::App.stub(:inside_git_repository?).and_return(true)
@user = Shelly::User.new
- @app = Shelly::App.new
+ @app = Shelly::App.new('foo-staging')
@client.stub(:token).and_return("abc")
@app.stub(:delete)
Shelly::User.stub(:new).and_return(@user)
Shelly::App.stub(:new).and_return(@app)
end
@@ -1273,11 +1275,11 @@
describe "#check" do
before do
Shelly::App.stub(:inside_git_repository?).and_return(true)
Bundler::Definition.stub_chain(:build, :specs, :map) \
- .and_return(["thin"])
+ .and_return(["thin", "pg", "delayed_job", "whenever"])
Shelly::StructureValidator.any_instance.stub(:repo_paths) \
.and_return(["config.ru", "Gemfile", "Gemfile.lock"])
end
it "should ensure user is in git repository" do
@@ -1339,9 +1341,65 @@
context "when config.ru doesn't exist" do
it "should show that config.ru is neccessary" do
Shelly::StructureValidator.any_instance.stub(:repo_paths).and_return([])
$stdout.should_receive(:puts).with(" #{red("✗")} File config.ru is missing")
invoke(@main, :check)
+ end
+ end
+
+ context "cloudfile" do
+ before do
+ cloud = mock(:code_name => "foo-staging", :databases => ["postgresql"],
+ :whenever? => true, :delayed_job? => true, :to_s => "foo-staging")
+ cloudfile = mock(:clouds => [cloud])
+
+ Shelly::Cloudfile.stub(:new).and_return(cloudfile)
+ end
+
+ context "whenever is enabled" do
+ it "should show that necessary gem doesn't exist" do
+ Bundler::Definition.stub_chain(:build, :specs, :map).and_return([])
+ $stdout.should_receive(:puts).with(" #{red("✗")} Gem 'whenever' is missing in the Gemfile for 'foo-staging' cloud")
+ invoke(@main, :check)
+ end
+
+ it "should show that necessary gem exists" do
+ $stdout.should_receive(:puts).with(" #{green("✓")} Gem 'whenever' is present for 'foo-staging' cloud")
+ invoke(@main, :check)
+ end
+ end
+
+ context "delayed_job is enabled" do
+ it "should show that necessary gem doesn't exist" do
+ Bundler::Definition.stub_chain(:build, :specs, :map).and_return([])
+ $stdout.should_receive(:puts).with(" #{red("✗")} Gem 'delayed_job' is missing in the Gemfile for 'foo-staging' cloud")
+ invoke(@main, :check)
+ end
+
+ it "should show that necessary gem exists" do
+ $stdout.should_receive(:puts).with(" #{green("✓")} Gem 'delayed_job' is present for 'foo-staging' cloud")
+ invoke(@main, :check)
+ end
+ end
+
+ context "postgresql is enabled" do
+ it "should show that necessary gem doesn't exist" do
+ Bundler::Definition.stub_chain(:build, :specs, :map).and_return([])
+ $stdout.should_receive(:puts).with(" #{red("✗")} Postgresql driver is missing in the Gemfile for 'foo-staging' cloud,\n we recommend adding 'pg' gem to Gemfile")
+ invoke(@main, :check)
+ end
+
+ it "should show that necessary gem exists - postgres" do
+ Bundler::Definition.stub_chain(:build, :specs, :map).and_return(["postgres"])
+ $stdout.should_receive(:puts).with(" #{green("✓")} Postgresql driver is present for 'foo-staging' cloud")
+ invoke(@main, :check)
+ end
+
+ it "should show that necessary gem exists - pg" do
+ Bundler::Definition.stub_chain(:build, :specs, :map).and_return(["pg"])
+ $stdout.should_receive(:puts).with(" #{green("✓")} Postgresql driver is present for 'foo-staging' cloud")
+ invoke(@main, :check)
+ end
end
end
context "when mysql gem exists" do
it "should show that mysql gem is not supported by Shelly Cloud" do