diff --git a/lib/facter/rabbitmq_nodename.rb b/lib/facter/rabbitmq_nodename.rb index 46fa45212..301e3c1e0 100644 --- a/lib/facter/rabbitmq_nodename.rb +++ b/lib/facter/rabbitmq_nodename.rb @@ -2,7 +2,7 @@ setcode do if Facter::Core::Execution.which('rabbitmqctl') rabbitmq_nodename = Facter::Core::Execution.execute('rabbitmqctl status 2>&1') - %r{^Status of node '?([\w\.]+@[\w\.\-]+)'? \.+$}.match(rabbitmq_nodename)[1] + %r{^Status of node '?([\w\.]+@[\w\.\-]+)'?}.match(rabbitmq_nodename)[1] end end end diff --git a/spec/unit/rabbitmq_nodename_spec.rb b/spec/unit/rabbitmq_nodename_spec.rb index 5b10bb23e..621d7ebfe 100644 --- a/spec/unit/rabbitmq_nodename_spec.rb +++ b/spec/unit/rabbitmq_nodename_spec.rb @@ -35,5 +35,16 @@ expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1') } end + + context 'without trailing points' do + before :each do + Facter::Core::Execution.stubs(:which).with('rabbitmqctl').returns(true) + Facter::Core::Execution.stubs(:execute).with('rabbitmqctl status 2>&1').returns('Status of node monty@rabbit-1') + end + it { + expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1') + } + end + end end