aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/gems/rspec-1.3.1/features/mocks
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2011-02-24 15:10:14 +0000
committerLouise Crow <louise.crow@gmail.com>2011-02-24 15:10:14 +0000
commit08a64f9e3139851fd65c7ba6969ee590b4afea6a (patch)
tree20c77e796002dfa95b2af3ba00ebd2f691c02fc7 /vendor/gems/rspec-1.3.1/features/mocks
parent3757bb52c0aa86b779b00428d7ebe35b30cea1ee (diff)
Adding rspec gem.
Diffstat (limited to 'vendor/gems/rspec-1.3.1/features/mocks')
-rw-r--r--vendor/gems/rspec-1.3.1/features/mocks/block_local_expectations.feature62
-rw-r--r--vendor/gems/rspec-1.3.1/features/mocks/mix_stubs_and_mocks.feature22
-rw-r--r--vendor/gems/rspec-1.3.1/features/mocks/stub_implementation.feature26
3 files changed, 110 insertions, 0 deletions
diff --git a/vendor/gems/rspec-1.3.1/features/mocks/block_local_expectations.feature b/vendor/gems/rspec-1.3.1/features/mocks/block_local_expectations.feature
new file mode 100644
index 000000000..f0155d429
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/features/mocks/block_local_expectations.feature
@@ -0,0 +1,62 @@
+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_dsl.rb" with:
+ """
+ require 'spec_helper'
+ require 'account'
+
+ describe "account DSL" do
+ it " .... " 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 "spec account_dsl.rb"
+ Then the stdout should include "1 example, 0 failures"
+
+ Scenario: failing example
+
+ Given a file named "account_dsl.rb" with:
+ """
+ require 'spec_helper'
+ require 'account'
+
+ describe "account DSL" do
+ it " .... " 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 "spec account_dsl.rb"
+ Then the stdout should include "1 example, 1 failure"
diff --git a/vendor/gems/rspec-1.3.1/features/mocks/mix_stubs_and_mocks.feature b/vendor/gems/rspec-1.3.1/features/mocks/mix_stubs_and_mocks.feature
new file mode 100644
index 000000000..deaf84ecf
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/features/mocks/mix_stubs_and_mocks.feature
@@ -0,0 +1,22 @@
+Feature: stub and mock together
+
+ As an RSpec user
+ I want to use stubs and mocks together
+
+ Scenario: stub in before
+ Given a file named "stub_and_mocks_spec.rb" with:
+ """
+ describe "a stub in before" do
+ before(:each) do
+ @messenger = mock('messenger').as_null_object
+ end
+
+ it "a" do
+ @messenger.should_receive(:foo).with('first')
+ @messenger.foo('second')
+ @messenger.foo('third')
+ end
+ end
+ """
+ When I run "spec stub_and_mocks_spec.rb --format nested"
+ Then the stdout should include "received :foo with unexpected arguments\n expected: (\"first\")\n got: ([\"second\"], [\"third\"])"
diff --git a/vendor/gems/rspec-1.3.1/features/mocks/stub_implementation.feature b/vendor/gems/rspec-1.3.1/features/mocks/stub_implementation.feature
new file mode 100644
index 000000000..269de4742
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/features/mocks/stub_implementation.feature
@@ -0,0 +1,26 @@
+Feature: stub implementation
+
+ As an rspec user, I want to stub a complete implementation, not just a
+ return value.
+
+ Scenario: stub implementation
+ Given a file named "stub_implementation.rb" with:
+ """
+ describe "a stubbed implementation" do
+ it "works" do
+ object = Object.new
+ object.stub(:foo) do |arg|
+ if arg == :this
+ "got this"
+ elsif arg == :that
+ "got that"
+ end
+ end
+
+ object.foo(:this).should == "got this"
+ object.foo(:that).should == "got that"
+ end
+ end
+ """
+ When I run "spec stub_implementation.rb"
+ Then the stdout should include "1 example, 0 failures"