README.md in salesforce_id-1.2.0 vs README.md in salesforce_id-1.3.0

- old
+ new

@@ -88,9 +88,74 @@ # Special feature, for even shorter ID creation SalesforceId("003G000001SUbc4") == SalesforceId.id("003G000001SUbc4") # => true ``` +### Test utilities + +#### SalesforceId::Random + +A useful utility class to generate random salesforce IDs + +```ruby +# Generate a valid case-sensitive salesforce id +SalesforceId::Random.sensitive # => 003G000001SUbc4 + +# Generate a valid case-insensitive salesforce id +SalesforceId::Random.insensitive # => 003G000001SUbc4IAD + +# Generate an **invalid** case-sensitive salesforce id +SalesforceId::Random.invalid_sensitive # => 003G0-0001SUbc4 + +# Generate a **invalid** case-insensitive salesforce id where the first 15 +# characters are invalid, not the checksum part +SalesforceId::Random.insensitive # => 003-000001SUbc4IAD + +# Generate a **invalid** case-insensitive salesforce id where only the checksum +# part (last 3 characters) is invalid +SalesforceId::Random.insensitive # => 003G000001SUbc4I9D + +# Generate a valid SalesforceId::Safe salesforce id +SalesforceId::Random.safe # => #<SalesforceId::Safe:0x007f86f2294c50 @value="003G000001SUbc4IAD"> + +# Shorter version to perform `SalesforceId::Random.safe` +SalesforceId.random # => #<SalesforceId::Safe:0x007f86f2294c50 @value="003G000001SUbc4IAD"> +``` + +#### RSpec matchers + +Include `SalesforceId::RSpec` in your tests to get a bunch of salesforce id +matchers + +```ruby +RSpec.describe SalesforceId("003G000001SUbc4") do + include ::SalesforceId::RSpec + + it "is a sensitive salesforce id" do + expect(subject.to_sensitive).to be_sensitive_salesforce_id # => true + end + + it "is an insensitive salesforce id" do + expect(subject.to_insensitive).to be_insensitive_salesforce_id # => true + end + + it "is a salesforce id" do + is_expected.to be_salesforce_id # => true + end + + it "is a salesforce id in safe format (case-sensitive + checksum)" do + is_expected.to be_safe_salesforce_id # => true + end + +end +``` + +These tests will pass. Matchers will work with any object that can be converted +into a string with `to_s`, including `SalesforceId::Safe`. + +One note on `be_safe_salesforce_id` matcher, it will consider safe **even +strings** if they are of the correct format (case sensitive + checksum) + ## Documentation Methods are documented in [salesforce_id_ext.h](https://github.com/Fire-Dragon-DoL/salesforce_id/blob/master/ext/salesforce_id/salesforce_id_ext.h), this file is the only public API of the gem, everything else must be considered private.