diff --git a/lib/inspec/objects/test.rb b/lib/inspec/objects/test.rb index cee792f5e..a00d67911 100644 --- a/lib/inspec/objects/test.rb +++ b/lib/inspec/objects/test.rb @@ -48,13 +48,12 @@ module Inspec if @qualifier.length > 1 last = @qualifier[-1] - unless last.is_a?(Array) && last[0].to_s.empty? - if last.length == 1 && last[0] !~ /^to_.$/ && !last[0].include?('[') - # this will go in its() - xres = last[0] - else - res += '.' + ruby_qualifier(last) - end + last_call = last.is_a?(Array) ? last[0].to_s : '' + if last.length == 1 && last_call !~ /^to_.$/ && !last_call.include?('[') && !last_call.empty? + # this will go in its() + xres = last_call + else + res += '.' + ruby_qualifier(last) end end diff --git a/test/unit/objects_test.rb b/test/unit/objects_test.rb index fb82c39cf..4eb6725d6 100644 --- a/test/unit/objects_test.rb +++ b/test/unit/objects_test.rb @@ -50,6 +50,15 @@ end describe resource.hello(\"world\") do it { should } end +".strip + end + + it 'constructs a simple resource+argument with method calls' do + obj.qualifier = [['resource'], [:world]] + obj.to_ruby.must_equal " +describe resource do + its(\"world\") { should } +end ".strip end end