Sha256: 3c62b447151e896384cf5ac131e77cef230cca081f3ff380f76b42fb440bb941

Contents?: true

Size: 1.48 KB

Versions: 40

Compression:

Stored size: 1.48 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

40 entries across 40 versions & 8 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/features/message_expectations/block_local_expectations.feature.pending
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/features/message_expectations/block_local_expectations.feature.pending
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/features/message_expectations/block_local_expectations.feature.pending
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/message_expectations/block_local_expectations.feature.pending
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/message_expectations/block_local_expectations.feature.pending
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/message_expectations/block_local_expectations.feature.pending
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/message_expectations/block_local_expectations.feature.pending
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/message_expectations/block_local_expectations.feature.pending
rspec-mocks-2.99.4 features/message_expectations/block_local_expectations.feature.pending
vagrant-cloudstack-1.1.0 vendor/bundle/gems/rspec-mocks-2.14.6/features/message_expectations/block_local_expectations.feature.pending
rspec-mocks-2.99.3 features/message_expectations/block_local_expectations.feature.pending
rspec-mocks-2.99.2 features/message_expectations/block_local_expectations.feature.pending
dxruby_rp5-0.0.4 spec/vendor/rspec-mocks-2.14.4/features/message_expectations/block_local_expectations.feature.pending
rspec-mocks-2.99.1 features/message_expectations/block_local_expectations.feature.pending
rspec-mocks-2.99.0 features/message_expectations/block_local_expectations.feature.pending
rspec-mocks-2.99.0.rc1 features/message_expectations/block_local_expectations.feature.pending
rspec-mocks-2.14.6 features/message_expectations/block_local_expectations.feature.pending
rspec-mocks-3.0.0.beta2 features/message_expectations/block_local_expectations.feature.pending
rspec-mocks-2.99.0.beta2 features/message_expectations/block_local_expectations.feature.pending
rspec-mocks-2.14.5 features/message_expectations/block_local_expectations.feature.pending