Add new methods to MessageVerifier

This commit adds two boolean methods to `ActiveSupport::MessageVerifier`: `#verified`, to return `false` on invalid messages, and `#valid_message?`, a convenience boolean method to check the validity of a message's format.

**`#verified` method**
The first commit adds a `#verified` method to return false when an error occurs decoding the message; it continues to return the message on success. (The behavior of `#verify` remains unchanged.) Previously it was not possible to attempt to decode a message without possibly encountering an exception.

*Example*

```ruby
@verifier = ActiveSupport::MessageVerifier.new("c0mplexs3cret")
@data = @verifier.generate("a very important message")
@verifier.verified(@data) # => "a very important message"
@verifier.verify(@data) # => "a very important message"
@verifier.verified("foo") # => false
@verifier.verify("foo") # => ActiveSupport::MessageVerifier::InvalidSignature
```

**`#valid_message?` method**
Sometimes it may be beneficial to verify the format of the message without performing the decoding. The second commit adds a `#valid_message?` boolean method which performs this validation. It has the added benefit of cleaning up a conditional in the `#verified` method. I also took some liberty restructuring the tests in this commit.

*Example*

```ruby
@verifier = ActiveSupport::MessageVerifier.new("c0mplexs3cret")
@data = @verifier.generate("a very important message") # => "BAhJIh1hIHZlcnkgaW1wb3J0YW50IG1lc3NhZ2UGOgZFVA==--4cf27b268ccb74307099b03d2b023f68b9e9763c"
@data.valid_message?(@data) # => true
@data.valid_message?("foo") # => false
@data.valid_message?("foo--bar") # => false
first, second = @data.split("--")
@data.valid_message?("#{first.reverse}--#{second.reverse}") # => false
@data.valid_message?("#{first}--#{second.reverse}") # => false
@data.valid_message?("#{first.reverse}--#{second}") # => false
@data.valid_message?("#{second}--#{first}") # => false
@data.valid_message?("#{first}--#{first}") # => false
```
It was already changed. :)

On Tue Dec 02 2014 at 9:32:27 AM Logan Leger <notifications@github.com>
wrote:

> In activesupport/lib/active_support/message_verifier.rb:
>
> >            raise
> >          end
> >        else
> > -        raise InvalidSignature
> > +        false
>
> Sorry, I wasn't aware of that guideline. (Are those guidelines written
> down anywhere? Perhaps I just missed it.) I prefer the explicit false,
> but if it's the guideline, I'm happy to change it, since it makes no
> practical difference. Would you like me to open another PR with that change?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/rails/rails/pull/17727/files#r21170473>.
>