spec/kpm/unit/plugins_manager_spec.rb in kpm-0.1.3 vs spec/kpm/unit/plugins_manager_spec.rb in kpm-0.1.4

- old
+ new

@@ -28,11 +28,12 @@ identifiers['foo']['plugin_name'].should == 'foo_name' end it 'creates a plugin identifier entry with coordinates' do # Verifies file gets created if does not exist - identifiers = @manager.add_plugin_identifier_key('bar', 'bar_name', 'type', ['group', 'artifact', 'packaging', nil, 'version']) + coordinate_map = {:group_id => 'group', :artifact_id => 'artifact', :packaging => 'packaging', :version => 'version'} + identifiers = @manager.add_plugin_identifier_key('bar', 'bar_name', 'type', coordinate_map) identifiers.size.should == 1 identifiers['bar']['plugin_name'].should == 'bar_name' identifiers['bar']['group_id'].should == 'group' identifiers['bar']['artifact_id'].should == 'artifact' identifiers['bar']['packaging'].should == 'packaging' @@ -96,19 +97,42 @@ identifiers['lol']['plugin_name'].should == 'lol_name' end it 'creates plugin identifiers and validate entry' do # Verifies file gets created if does not exist - identifiers = @manager.add_plugin_identifier_key('yoyo', 'yoyo_name', 'type', ['group', 'artifact', 'packaging', nil, 'version']) + coordinate_map = {:group_id => 'group', :artifact_id => 'artifact', :packaging => 'packaging', :version => 'version'} + + identifiers = @manager.add_plugin_identifier_key('yoyo', 'yoyo_name', 'type', coordinate_map) identifiers.size.should == 1 identifiers['yoyo']['plugin_name'].should == 'yoyo_name' - @manager.validate_plugin_identifier_key('yoyo', ['group', 'artifact', 'packaging', nil, 'version']).should == true + @manager.validate_plugin_identifier_key('yoyo', coordinate_map).should == true # Negative validation - @manager.validate_plugin_identifier_key('yoyo', ['group1', 'artifact', 'packaging', nil, 'version']).should == false + invalid_coordinate_map = {:group_id => 'group1', :artifact_id => 'artifact', :packaging => 'packaging', :version => 'version'} + + @manager.validate_plugin_identifier_key('yoyo', invalid_coordinate_map).should == false end + + it 'creates a plugin identifier entry with a new version' do + # Verifies file gets created if does not exist + + coordinate_map1 = {:group_id => 'group', :artifact_id => 'artifact', :packaging => 'packaging', :version => 'version1'} + + identifiers = @manager.add_plugin_identifier_key('bar', 'bar_name', 'type', coordinate_map1) + identifiers.size.should == 1 + identifiers['bar']['plugin_name'].should == 'bar_name' + identifiers['bar']['version'].should == 'version1' + + coordinate_map2 = {:group_id => 'group', :artifact_id => 'artifact', :packaging => 'packaging', :version => 'version2'} + + identifiers = @manager.add_plugin_identifier_key('bar', 'bar_name', 'type', coordinate_map2) + identifiers.size.should == 1 + identifiers['bar']['plugin_name'].should == 'bar_name' + identifiers['bar']['version'].should == 'version2' + + end it 'sets a path as active' do @manager.set_active(@plugin_dir.join('1.0.0')) File.exists?(@plugin_dir.join('SET_DEFAULT')).should be_true File.readlink(@plugin_dir.join('SET_DEFAULT')).should == @plugin_dir.join('1.0.0').to_s