spec/shelly/app_spec.rb in shelly-0.0.16 vs spec/shelly/app_spec.rb in shelly-0.0.17

- old
+ new

@@ -6,11 +6,10 @@ FileUtils.mkdir_p("/projects/foo") Dir.chdir("/projects/foo") @client = mock(:api_url => "https://api.example.com", :shellyapp_url => "http://shellyapp.example.com") Shelly::Client.stub(:new).and_return(@client) @app = Shelly::App.new - @app.purpose = "staging" @app.code_name = "foo-staging" end describe "being initialized" do it "should have default ruby_version: MRI-1.9.2" do @@ -40,16 +39,16 @@ @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 staging &> /dev/null") + @app.should_receive(:system).with("git remote rm production &> /dev/null") @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 staging git@git.shellycloud.com:foo-staging.git") + @app.should_receive(:system).with("git remote add production git@git.shellycloud.com:foo-staging.git") @app.add_git_remote end end describe "#generate_cloudfile" do @@ -120,27 +119,54 @@ @app.open_billing_page end end describe "#create" do - it "should create the app on shelly cloud via API client" do - @app.purpose = "dev" - @app.code_name = "fooo" - attributes = { - :code_name => "fooo", - :name => "fooo", - :environment => "production", - :ruby_version => "MRI-1.9.2", - :domain_name => "fooo.shellycloud.com" - } - @client.should_receive(:create_app).with(attributes).and_return("git_url" => "git@git.shellycloud.com:fooo.git") - @app.create + 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", + :name => "fooo", + :environment => "production", + :ruby_version => "MRI-1.9.2", + :domain_name => nil + } + @client.should_receive(:create_app).with(attributes).and_return("git_url" => "git@git.shellycloud.com:fooo.git", + "domain_name" => "fooo.shellyapp.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", + "domain_name" => "fooo.shellyapp.com") + @app.create + @app.git_url.should == "git@git.example.com:fooo.git" + @app.domains.should == ["fooo.shellyapp.com"] + end end - it "should assign returned git_url" do - @client.stub(:create_app).and_return("git_url" => "git@git.example.com:fooo.git") - @app.create - @app.git_url.should == "git@git.example.com:fooo.git" + 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", + :name => "boo", + :environment => "production", + :ruby_version => "MRI-1.9.2", + :domain_name => ["boo.shellyapp.com", "boo.example.com"] + } + @client.should_receive(:create_app).with(attributes).and_return("git_url" => "git@git.shellycloud.com:fooo.git", + "domain_name" => "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", + "domain_name" => "boo.shellyapp.com boo.example.com") + @app.create + @app.domains.should == ["boo.shellyapp.com", "boo.example.com"] + end end end end -