Skip to content
Browse files

started working on push tests, yaml error test

  • Loading branch information...
1 parent 89bdd03 commit c0af6ccd4d8ab6e0e27ac301618c7b75c9e5bf19 @hone hone committed Mar 9, 2010
Showing with 50 additions and 0 deletions.
  1. +1 −0 init.rb
  2. +49 −0 spec/lib/heroku_herocutter_spec.rb
View
1 init.rb
@@ -22,5 +22,6 @@
rescue LoadError
raise 'restclient gem is missing. Please install restclient: gem install restclient'
end
+require 'yaml'
require File.dirname(__FILE__) + '/lib/heroku_herocutter'
require File.dirname(__FILE__) + '/lib/help'
View
49 spec/lib/heroku_herocutter_spec.rb
@@ -1,4 +1,5 @@
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
+require 'yaml'
describe Heroku::Command::Plugins do
describe "on plugin load" do
@@ -92,5 +93,53 @@ def install_command
end
end # install
+
+ describe "on plugin push" do
+ def push_command(uri = nil, name = nil)
+ Heroku::Command.run("plugins:push", [uri, name])
+ end
+
+ before(:each) do
+ @uri = "git://github.com/hone/heroku_herocutter.git"
+ end
+
+ describe "YAML loads successfully" do
+ before(:each) do
+ @sandbox = @herocutter_plugin_path + "/spec/tmp"
+ if File.exist?(@sandbox)
+ FileUtils.rm_rf(@sandbox)
+ end
+ FileUtils.mkdir_p(@sandbox)
+
+ @config_file = @sandbox + "/herocutter"
+ File.open(@config_file, 'w') do |file|
+ YAML.dump({'api_key' => '4f104e7891b31d4ac004677c9dfd0ac5'}, file)
+ end
+
+ stub.instance_of(Heroku::Command::Plugins).herocutter_file { @config_file }
+ end
+
+ after(:each) do
+ FileUtils.rm_rf(@sandbox)
+ end
+
+ it "should display the plugin pushed and the uri" do
+ mock.instance_of(Heroku::Command::Plugin).display("pushed plugin with uri: #{@uri}")
+
+ push_command(@uri)
+ end
+ end
+
+ describe "YAML load error" do
+ before(:each) do
+ stub(YAML).load_file { raise Errno::ENOENT }
+ end
+
+ it "should display error" do
+ mock.instance_of(Heroku::Command::Plugins).error(anything)
+ push_command(@uri)
+ end
+ end
+ end
end # load!
end

0 comments on commit c0af6cc

Please sign in to comment.
Something went wrong with that request. Please try again.