Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better error handling: raise Chanko::ActiveIf::NoConditionFound for undefined conditions #35

Merged
merged 2 commits into from
Dec 6, 2013

Conversation

gfx
Copy link
Contributor

@gfx gfx commented Dec 5, 2013

The active_if runner raises NoMethodError for nil:NilClass if a specified condition is not defined, but it is not clear.

This patches fixes it to raise Chanko::ActiveIf::NoConditionFound to clarify what happens.

@hotchpotch @r7kamura Can you review this p-r please?

when a specified condition is not defined, instead of raising
method missing error for nil
should be_nil
rescue Chanko::ActiveIf::NoConditionFound => e
e.message.should =~ /this_is_not_a_condition/
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use expect { ... }.to raise_error helper?
https://www.relishapp.com/rspec/rspec-expectations/v/3-0/docs/built-in-matchers/raise-error-matcher

expect { subject }.to raise_error(..., /.../)

@r7kamura
Copy link
Contributor

r7kamura commented Dec 6, 2013

I just nitpicked, but otherwise looks Great 👍

r7kamura added a commit that referenced this pull request Dec 6, 2013
better error handling: raise Chanko::ActiveIf::NoConditionFound for undefined conditions
@r7kamura r7kamura merged commit 18cf236 into cookpad:master Dec 6, 2013
@gfx gfx deleted the raise_no_condition_found_error branch December 6, 2013 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants