Update yard docs to use expect syntax #223

Merged
merged 2 commits into from Mar 16, 2013

Projects

None yet

2 participants

Contributor

No description provided.

@myronmarston myronmarston commented on an outdated diff Mar 15, 2013
lib/rspec/matchers.rb
@@ -679,17 +687,12 @@ def yield_successive_args(*args)
#
# @note This is also available using the `=~` operator with `should`,
# but `=~` is not supported with `expect`.
- # @note There is no should_not version of array.should =~ other_array
+ # @note There is no expect(..).not_to version of expect(array).not_to match_array(other_array)
myronmarston
myronmarston Mar 15, 2013 Owner

This sentence is a bit awkward to read. Can it be rephrased, maybe like this?

This matcher only supports positive expectations. expect(..).not_to match_array(other_array) is not supported.
@myronmarston myronmarston commented on an outdated diff Mar 15, 2013
lib/rspec/matchers.rb
#
# RSpec will also create custom matchers for predicates like `has_key?`. To
# use this feature, just state that the object should have_key(:key) and RSpec will
# call has_key?(:key) on the target. For example:
#
- # {:a => "A"}.should have_key(:a) # => {:a => "A"}.has_key?(:a) | passes
- # {:a => "A"}.should have_key(:b) # => {:a => "A"}.has_key?(:b) | fails
+ # expect({:a => "A"}).to have_key(:a) # => {:a => "A"}.has_key?(:a) | passes
+ # expect({:a => "A"}).to have_key(:b) # => {:a => "A"}.has_key?(:b) | fails
myronmarston
myronmarston Mar 15, 2013 Owner

Using the curly braces here adds to the syntactical noiseness of the example. What do you think about using this instead?

expect(:a => "A").to have_key(:a)
expect(:a => "A").to have_key(:b)
Owner

Looks great....I left a couple small comments.

@gautamkpai gautamkpai commented on the diff Mar 15, 2013
lib/rspec/matchers.rb
@@ -679,17 +687,12 @@ def yield_successive_args(*args)
#
# @note This is also available using the `=~` operator with `should`,
# but `=~` is not supported with `expect`.
gautamkpai
gautamkpai Mar 15, 2013 Contributor

What about the above? Is this note still needed?

Since everything in this document talks about expect. It feels very abrupt and out of place be mentioning support for should here.

What's your take on this?

myronmarston
myronmarston Mar 15, 2013 Owner

I think it's useful to keep since there's plenty of code out in the wild that uses should =~ array. It'll be helpful for folks who come hunting for what that does.

Contributor

@myronmarston Could you please help me with the next step? With those two little changes,

Should I make a new commit and push it here? Or Should I amend the earlier commit? Or Commit and then squash them together? Or any other way?

Owner

Do whatever you're most comfortable with.

@myronmarston myronmarston merged commit 1a2de54 into rspec:master Mar 16, 2013

1 check passed

default The Travis build passed
Details
Owner

Thanks!

@gautamkpai gautamkpai deleted the gautamkpai:update_docs branch Mar 17, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment