Sha256: d47f0a994fea04c022800d806a24575ad303e12cd3dc4534727bb613ecfc29fe
Contents?: true
Size: 1.4 KB
Versions: 4
Compression:
Stored size: 1.4 KB
Contents
Feature: block local expectations 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' describe "account DSL" do it "it succeeds when the block local receives the given call" do 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 I should see "1 example, 0 failures" Scenario: failing example Given a file named "account_failing_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 # opening_balance is not called here end end end """ When I run "rspec account_failing_spec.rb" Then I should see "1 example, 1 failure"
Version data entries
4 entries across 4 versions & 1 rubygems