Sha256: 01199d36fd47ba675a92ac6661e31bad4d6d618177084b9aec024e1ee4718bbc

Contents?: true

Size: 1.76 KB

Versions: 4

Compression:

Stored size: 1.76 KB

Contents

Feature: block local expectations

  In order to set message expectations on ...
  As an RSpec user
  I want to configure the evaluation context

  Background:
    Given a file named "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 "account_passing_spec.rb" with:
      """
      require 'account'

      Rspec.configure do |config|
        config.mock_framework = :rspec
      end

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

      Rspec.configure do |config|
        config.mock_framework = :rspec
      end

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

    When I run "rspec account_failing_spec.rb"
    Then the stdout should match "1 example, 1 failure"

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rspec-core-2.0.0.a9 features/mocks/block_local_expectations.feature
rspec-core-2.0.0.a8 features/mocks/block_local_expectations.feature
rspec-core-2.0.0.a7 features/mocks/block_local_expectations.feature
rspec-core-2.0.0.a6 features/mocks/block_local_expectations.feature