require File.dirname(__FILE__) + '/../spec_helper' context "Scan of an empty repository" do setup do RemoteResources.stubs(:repository_list).returns(['']) PluginRepositoryScanner.scan_uri('http://www.mypluginrepo.com/svn/') end specify "should add no plugins to the database" do Plugin.count.should_equal 0 end end context "Scan of a repository with one plugin" do setup do RemoteResources.stubs(:repository_list).returns(%w(plugin_one)) Plugin.any_instance.stubs(:scan_root_for_versions).returns(true) Release.any_instance.stubs(:get_revision_number_from_repository).returns(true) PluginRepositoryScanner.scan_uri('http://www.mypluginrepo.com/svn/') end specify "should add one plugin to the database" do Plugin.count.should_equal 1 Plugin.find(:first).name.should_equal 'plugin_one' end end context "Scan of a repository with two plugins" do setup do RemoteResources.stubs(:repository_list).returns(['plugin_one', 'plugin_two']) Plugin.any_instance.stubs(:scan_root_for_versions).returns(true) Release.any_instance.stubs(:get_revision_number_from_repository).returns(true) PluginRepositoryScanner.scan_uri('http://www.mypluginrepo.com/svn/') end specify "should add one plugin to the database" do Plugin.count.should_equal 2 Plugin.find(:all).collect(&:name).should_equal ['plugin_one', 'plugin_two'] end end # again we need to find a way of making a stub return different subsequent values context "Scan of multiple repositories, one with one plugin, another with 3 plugins" do setup do RemoteResources.stubs(:repository_list).returns(%w(plugin_one)) Plugin.any_instance.stubs(:scan_root_for_versions).returns(true) Release.any_instance.stubs(:get_revision_number_from_repository).returns(true) PluginRepositoryScanner.scan_all(['http://www.mypluginrepo.com/svn/', 'http://www.mypluginrepo.com/more/']) end specify "should add four plugins to the database" do #Plugin.count.should_equal 4 #Plugin.find(:all).collect(&:name).should_equal ['plugin_one', 'great_plugin_again', 'another_plugin', 'super_plugin'] end end