[rspec-devel] [ rspec-Feature Requests-10539 ] Add class_type constraint for mocks

noreply at rubyforge.org noreply at rubyforge.org
Wed May 2 23:51:58 EDT 2007


Feature Requests item #10539, was opened at 2007-05-02 19:30
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=10539&group_id=797

Category: mock module
Group: None
Status: Open
Priority: 3
Submitted By: Brian Takita (btakita)
Assigned to: Nobody (None)
Summary: Add class_type constraint for mocks

Initial Comment:
I know that we are all supposed to think Duck Typing :), but sometimes its more convenient and useful to have a constraint on a Class type.

Maybe we can add a class_type method to be used in addition to the duck_type method.



----------------------------------------------------------------------

>Comment By: Brian Takita (btakita)
Date: 2007-05-02 20:51

Message:
Sorry, here is an example.

it "sets Expectations differ when differ_class is set" do
  @options.differ_class = Spec::Expectations::Differs::Default
 
Spec::Expectations.should_receive(:differ=).with(:anything).and_return
do |arg|
    arg.class.should == Spec::Expectations::Differs::Default
  end
  @options.create_behaviour_runner
end

It would be nice to say:
Spec::Expectations.should_receive(:differ=).with(class_type(Spec::Expectations::Differs::Default))

Saying duck_type would be ambigious in this situation.

----------------------------------------------------------------------

Comment By: David Chelimsky (dchelimsky)
Date: 2007-05-02 20:16

Message:
Would this do what you are looking for?

http://rubyforge.org/tracker/index.php?func=detail&aid=5064&group_id=797&atid=3152

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=10539&group_id=797


More information about the rspec-devel mailing list