Skip to content

Commit

Permalink
initial test files
Browse files Browse the repository at this point in the history
  • Loading branch information
hone committed Feb 4, 2010
1 parent e0d5bd0 commit 97dc355
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
17 changes: 17 additions & 0 deletions examples/example_helper.rb
@@ -0,0 +1,17 @@
require 'micronaut'
require 'heroku'
require 'heroku/command'
require 'restclient'
lib_path = File.expand_path(File.dirname(__FILE__) + "/../lib")
$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)

def not_in_editor?
!(ENV.has_key?('TM_MODE') || ENV.has_key?('EMACS') || ENV.has_key?('VIM'))
end

Micronaut.configure do |c|
c.filter_run :focused => true
c.alias_example_to :fit, :focused => true
c.color_enabled = not_in_editor?
c.mock_with :rr
end
54 changes: 54 additions & 0 deletions examples/lib/heroku_herocutter.rb
@@ -0,0 +1,54 @@
require File.expand_path(File.dirname(__FILE__) + "/../example_helper")

describe Heroku::Command::Plugins do
describe "on plugin load" do
before(:each) do
@directory = File.expand_path(File.dirname(__FILE__) + "/../../../")
@herocutter_plugin_name = File.basename(File.expand_path(File.dirname(__FILE__) + "/../../"))
@herocutter_plugin_path = "#{@directory}/#{@herocutter_plugin_name}"
stub(Heroku::Plugin).list { [@herocutter_plugin_name] }
stub(Heroku::Plugin).directory { @directory }
end

it "should load the plugin without errors" do
Heroku::Plugin.load!
$:.include?("#{@herocutter_plugin_path}/lib").should be_true
end

describe "on new plugin install" do
before(:each) do
@plugin_name = "new_plugin"
@error_response = <<JSON
{
"error": "No plugin of that name found."
}
JSON
@success_response = <<JSON
{
"plugin": {
"name": "herocutter",
"uri": "git://github.com/hone/heroku_herocutter.git",
"updated_at": "2010-01-28T07:10:30Z",
"id": 11,
"description": "Provides extra heroku plugin functionality to work with Herocutter",
"downloads_count": 1,
"created_at": "2010-01-28T07:07:55Z"
}
}
JSON
end

fit "should fetch the git uri" do
mock(RestClient).get(anything) { @success_response }
Heroku::Command.run("plugins:install", [@plugin_name])
end

describe "when the git fetch is successful" do
before(:each) do
stub(RestClient).get("#{Heroku::Command::Plugins::HEROCUTTER_URL}/api/v1/plugins/", :format => 'json') { @success_response }
end

end
end
end # load!
end

0 comments on commit 97dc355

Please sign in to comment.