Sha256: af6c1af3a018999b39b3ddfbe924f84ff6218e40f674c1512fb181398037c001
Contents?: true
Size: 1.42 KB
Versions: 14
Compression:
Stored size: 1.42 KB
Contents
require 'spec_helper' describe Fakes do it "should be able to create a new fake" do fake.class.should == Fakes::Fake end it "should be able to create a new fake and specify return values for methods" do item = fake :hello => 'World', :age => 33 item.hello.should == 'World' item.age.should == 33 end context "when specifying a fake for a class" do let(:swaps){fake} before (:each) do Fakes::ClassSwaps.stub(:instance).and_return(swaps) end before (:each) do @result = fake_class Dir end it "should register a new fake with the class swaps" do swaps.received(:add_fake_for).called_with(Dir,arg_match.not_nil).should_not be_nil end it "should return the newly created fake" do @result.should_not be_nil end end context "when faking a class and specifying return values" do before (:each) do fake_class Dir,:exist? => true end after (:each) do reset_fake_classes end it "should replace the class with the fake return to return the values specified" do Dir.exist?('hello').should be_true end end context "resetting fake classes" do let(:swaps){fake} before (:each) do Fakes::ClassSwaps.stub(:instance).and_return(swaps) end before (:each) do reset_fake_classes end it "should be able to reset all of the fake classes" do swaps.received(:reset) end end end
Version data entries
14 entries across 14 versions & 1 rubygems