Sha256: 45c3e280104183b8b1a0f0e9fdb99abcb420f1df3552c3dc3e311766258b0b58

Contents?: true

Size: 1.5 KB

Versions: 27

Compression:

Stored size: 1.5 KB

Contents

Feature: block local expectations

  Background:
    Given a file named "lib/account.rb" with:
      """
      class Account
        def self.create
          yield new
        end

        def opening_balance(amount, currency)
        end
      end
      """

  Scenario: passing example
    Given a file named "spec/account_spec.rb" with:
      """
      require 'account'

      describe "account DSL" do
        it "it succeeds when the block local receives the given call" do
          account = double("Account")
          Account.should_receive(:create).and_yield(account) do |account|
            account.should_receive(:opening_balance).with(100, :USD)
          end
          Account.create do |account|
            account.opening_balance 100, :USD
          end
        end
      end
      """
    When I run "rspec ./spec/account_spec.rb"
    Then the output should contain "1 example, 0 failures"
    
  Scenario: failing example
    
    Given a file named "spec/account_spec.rb" with:
      """
      require 'account'

      describe "account DSL" do
        it "fails when the block local does not receive the expected call" do
          Account.should_receive(:create).and_yield do |account|
            account.should_receive(:opening_balance).with(100, :USD)
          end
          Account.create do |account|
            # opening_balance is not called here
          end
        end
      end
      """

    When I run "rspec ./spec/account_spec.rb"
    Then the output should contain "1 example, 1 failure"

Version data entries

27 entries across 27 versions & 4 rubygems

Version Path
messagebus_ruby_api-0.4.7 spec/ruby/1.9.1/gems/rspec-mocks-2.5.0/features/message_expectations/block_local_expectations.feature.pending
messagebus_ruby_api-0.4.4 spec/ruby/1.9.1/gems/rspec-mocks-2.5.0/features/message_expectations/block_local_expectations.feature.pending
rspec-mocks-2.5.0 features/message_expectations/block_local_expectations.feature.pending
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/features/message_expectations/block_local_expectations.feature.pending
rspec-mocks-2.4.0 features/message_expectations/block_local_expectations.feature.pending
vim-jar-0.1.2 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/features/message_expectations/block_local_expectations.feature.pending
vim-jar-0.1.1 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/features/message_expectations/block_local_expectations.feature.pending
vim-jar-0.1.0 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/features/message_expectations/block_local_expectations.feature.pending
rspec-mocks-2.3.0 features/message_expectations/block_local_expectations.feature.pending
vim-jar-0.0.3 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/features/message_expectations/block_local_expectations.feature.pending
vim-jar-0.0.2 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/features/message_expectations/block_local_expectations.feature.pending
vim-jar-0.0.1 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/features/message_expectations/block_local_expectations.feature.pending
rspec-mocks-2.2.0 features/message_expectations/block_local_expectations.feature.pending
rspec-mocks-2.1.0 features/message_expectations/block_local_expectations.feature.pending
rspec-mocks-2.0.1 features/message_expectations/block_local_expectations.feature.pending
gemrage-1.0.0 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/features/message_expectations/block_local_expectations.feature.pending
gemrage-0.4.1 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/features/message_expectations/block_local_expectations.feature.pending
gemrage-0.4.0 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/features/message_expectations/block_local_expectations.feature.pending
gemrage-0.3.2 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/features/message_expectations/block_local_expectations.feature.pending
gemrage-0.3.1 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/features/message_expectations/block_local_expectations.feature.pending