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

Problem Testing Constructor Exceptions #642

Closed
mdavis1982 opened this issue Feb 21, 2015 · 6 comments
Closed

Problem Testing Constructor Exceptions #642

mdavis1982 opened this issue Feb 21, 2015 · 6 comments

Comments

@mdavis1982
Copy link
Member

I've got a constructor that accepts two double parameters. It fires off the setting to two different methods and each has the potential to throw an exception. I can't get my specs to pass, no matter what I do.

The full code is here: https://gist.github.com/mdavis1982/50ea2507d3603fabed59

Removing either one of the two tests makes the other one pass.

@ciaranmcnulty
Copy link
Member

        if ($longitude < 180 || $longitude > 180) {
            throw new InvalidLongitudeException();
        }

Your only valid longitude is exactly 180..., you probably want to check for < -180

@mdavis1982
Copy link
Member Author

Gah! I'm an idiot! 😄

Thanks, @ciaranmcnulty!

@ciaranmcnulty
Copy link
Member

The tests were telling you what was happening ;-)

@mdavis1982
Copy link
Member Author

It's a bit weird that one of them still passed though... And removing either one made the other one pass

@ciaranmcnulty
Copy link
Member

What may be confusing the issue is that your first spec won't be failing; shouldHaveType doesn't actually cause instantiation

@mdavis1982
Copy link
Member Author

Yes... That, and the expected exception class type was truncated

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

No branches or pull requests

2 participants