lib/rspec/its.rb in rspec-its-1.0.0.pre vs lib/rspec/its.rb in rspec-its-1.0.0
- old
+ new
@@ -56,10 +56,19 @@
# # You can still access to its regular methods this way:
# its(:keys) { should include(:max_users) }
# its(:count) { should eq(2) }
# end
#
+ # With an implicit subject, `is_expected` can be used as an alternative
+ # to `should` (e.g. for one-liner use)
+ #
+ # @example
+ #
+ # describe Array do
+ # its(:size) { is_expected.to eq(0) }
+ # end
+ #
# Note that this method does not modify `subject` in any way, so if you
# refer to `subject` in `let` or `before` blocks, you're still
# referring to the outer subject.
#
# @example
@@ -78,9 +87,13 @@
attribute_chain = attribute.to_s.split('.')
attribute_chain.inject(subject) do |inner_subject, attr|
inner_subject.send(attr)
end
end
+ end
+
+ def is_expected
+ expect(__its_subject)
end
def should(matcher=nil, message=nil)
RSpec::Expectations::PositiveExpectationHandler.handle_matcher(__its_subject, matcher, message)
end