Skip to content

Commit

Permalink
Fix . is not allowed for job/node/view name
Browse files Browse the repository at this point in the history
  • Loading branch information
cynipe committed Jul 15, 2014
1 parent b8b971d commit 032ab5f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--require spec_helper
9 changes: 9 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,17 @@ GEM
method_source (~> 0.8.1)
slop (~> 3.4)
rake (10.3.2)
rspec (3.0.0)
rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0)
rspec-mocks (~> 3.0.0)
rspec-core (3.0.2)
rspec-support (~> 3.0.0)
rspec-expectations (3.0.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.0.0)
rspec-mocks (3.0.2)
rspec-support (~> 3.0.0)
rspec-support (3.0.2)
slop (3.5.0)
tapp (1.4.0)
Expand All @@ -77,4 +85,5 @@ DEPENDENCIES
jenkins-capistrano!
pry
rake
rspec
tapp
1 change: 1 addition & 0 deletions jenkins-capistrano.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'pry'
gem.add_development_dependency 'tapp'
gem.add_development_dependency 'aruba'
gem.add_development_dependency 'rspec'
end
3 changes: 2 additions & 1 deletion lib/jenkins-capistrano/configurator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def configure_views(config_files)

private
def name_for(file_path)
file_path.basename.to_s.split('.').first
file_path = file_path.basename('.erb') if file_path.extname == '.erb'
file_path.basename('.xml').to_s
end

def config_xml_for(file)
Expand Down
24 changes: 24 additions & 0 deletions spec/jenkins-capistrano/configurator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'spec_helper'
require 'jenkins-capistrano/configurator'

describe Jenkins::Capistrano::Configurator do
subject do
described_class.new(server_url: 'http://example.org')
end

describe '.name_for' do

[
{ file: 'name.xml' , expected: 'name' },
{ file: 'name.erb' , expected: 'name' },
{ file: 'name.xml.erb' , expected: 'name' },
{ file: 'n.a.m.e.xml' , expected: 'n.a.m.e' },
{ file: 'name.erb.xml' , expected: 'name.erb' }
].each do |param|
it "returns `#{param[:expected]}` when `#{param[:file]}` specified" do
file = Pathname.new(param[:file])
expect(subject.send(:name_for, file)).to eql param[:expected]
end
end
end
end
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require 'pry'

RSpec.configure do |config|
end

0 comments on commit 032ab5f

Please sign in to comment.