Sha256: b55d5a8c6f58a051515c392a24b8c629f4ba37d5819d23e9e9de41047cb68b9c

Contents?: true

Size: 1.1 KB

Versions: 194

Compression:

Stored size: 1.1 KB

Contents

require "spec_helper"

describe "a double declaration with a block handed to:" do
  describe "should_receive" do
    it "returns the value of executing the block" do
      obj = Object.new
      obj.should_receive(:foo) { 'bar' }
      obj.foo.should eq('bar')
    end
  end

  describe "stub" do
    it "returns the value of executing the block" do
      obj = Object.new
      obj.stub(:foo) { 'bar' }
      obj.foo.should eq('bar')
    end
  end

  describe "with" do
    it "returns the value of executing the block" do
      obj = Object.new
      obj.stub(:foo).with('baz') { 'bar' }
      obj.foo('baz').should eq('bar')
    end
  end

  %w[once twice any_number_of_times ordered and_return].each do |method|
    describe method do
      it "returns the value of executing the block" do
        obj = Object.new
        obj.stub(:foo).send(method) { 'bar' }
        obj.foo.should eq('bar')
      end
    end
  end

  describe "times" do
    it "returns the value of executing the block" do
      obj = Object.new
      obj.stub(:foo).at_least(1).times { 'bar' }
      obj.foo('baz').should eq('bar')
    end
  end
end

Version data entries

194 entries across 140 versions & 13 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/block_return_value_spec.rb
classiccms-0.7.5 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/block_return_value_spec.rb
classiccms-0.7.4 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/block_return_value_spec.rb
classiccms-0.7.4 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/block_return_value_spec.rb
classiccms-0.7.3 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/block_return_value_spec.rb
classiccms-0.7.3 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/block_return_value_spec.rb
classiccms-0.7.2 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/block_return_value_spec.rb
classiccms-0.7.2 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/block_return_value_spec.rb
classiccms-0.7.1 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/block_return_value_spec.rb
classiccms-0.7.1 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/block_return_value_spec.rb
classiccms-0.7.0 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/block_return_value_spec.rb
classiccms-0.7.0 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/block_return_value_spec.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.10.1/spec/rspec/mocks/block_return_value_spec.rb
classiccms-0.6.9 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/block_return_value_spec.rb
classiccms-0.6.9 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/block_return_value_spec.rb
classiccms-0.6.8 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/block_return_value_spec.rb
classiccms-0.6.8 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/block_return_value_spec.rb
classiccms-0.6.7 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/block_return_value_spec.rb
classiccms-0.6.7 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/block_return_value_spec.rb
classiccms-0.6.6 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/block_return_value_spec.rb