acrmp/chefspec — pull request #102 by russellcardullo (2013-02-14 03:26:44+00:00)
Title: Avoid matching substrings of resource actions

Hello!

This pull request addresses a bug in the way the define_resource_matchers method matches resource actions. In `lib/chefspec/matchers/shared.rb` line 22: https://github.com/acrmp/chefspec/blob/0825cf467a5c79d70428347451df0b7793fe6524/lib/chefspec/matchers/shared.rb#L22

resource.action.to_s.include? action.to_s

This ends up matching any action that is a substring of the resource actions.

For instance given a service resource with the restart action:

service 'foo' do
action :restart
end

This spec would unexpectedly pass:

it { should start_service 'foo' }

This behavior would also end up asserting incorrectly for other resource matchers we could write where one action is a substring of another (i.e. user actions lock vs unlock and mount actions mount vs umount).

In order to test my changes, I included a seperate cucumber scenario for the service restart case using a should_not start matcher. But I'm feeling it's a bit of an indirect way to test. I'd welcome any feedback on how to improve that.

BTW I'm excited to see all the recent activity on the project in the past few weeks. Will you be releasing an updated gem version?