aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/oscar/auth.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-07-04 18:25:22 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2010-07-04 18:25:22 +0100
commit00540d40be63b4db537a661d1a17c49a1790f79c (patch)
tree76946c70ed70f79eea2fda75057554905b0089d1 /protocols/oscar/auth.c
parent8eb0b76410b42490028448d22a26647faba6b916 (diff)
Ready for BitlBee 1.2.8.1.2.8
Diffstat (limited to 'protocols/oscar/auth.c')
0 files changed, 0 insertions, 0 deletions
/0.18.0.8'>hotfix/0.18.0.8 Unnamed repository; edit this file 'description' to name the repository.MimesBrønn
aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/plugins/rspec/examples/pure/stubbing_example.rb
blob: 31354aec6ad778ad1a584ec5815f174bba4e7dd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
require File.dirname(__FILE__) + '/spec_helper'

describe "A consumer of a stub" do
  it "should be able to stub methods on any Object" do
    obj = Object.new
    obj.stub!(:foobar).and_return {:return_value}
    obj.foobar.should equal(:return_value)
  end
end

class StubbableClass
  def self.find id
    return :original_return
  end
end

describe "A stubbed method on a class" do
  it "should return the stubbed value" do
    StubbableClass.stub!(:find).and_return(:stub_return)
    StubbableClass.find(1).should equal(:stub_return)
  end
  
  it "should revert to the original method after each spec" do
    StubbableClass.find(1).should equal(:original_return)
  end

  it "can stub! and mock the same message" do
    StubbableClass.stub!(:msg).and_return(:stub_value)
    StubbableClass.should_receive(:msg).with(:arg).and_return(:mock_value)

    StubbableClass.msg.should equal(:stub_value)
    StubbableClass.msg(:other_arg).should equal(:stub_value)
    StubbableClass.msg(:arg).should equal(:mock_value)
    StubbableClass.msg(:another_arg).should equal(:stub_value)
    StubbableClass.msg(:yet_another_arg).should equal(:stub_value)
    StubbableClass.msg.should equal(:stub_value)
  end
end

describe "A mock" do
  it "can stub!" do
    mock = mock("stubbing mock")
    mock.stub!(:msg).and_return(:value)
    (1..10).each {mock.msg.should equal(:value)}
  end
  
  it "can stub! and mock" do
    mock = mock("stubbing mock")
    mock.stub!(:stub_message).and_return(:stub_value)
    mock.should_receive(:mock_message).once.and_return(:mock_value)
    (1..10).each {mock.stub_message.should equal(:stub_value)}
    mock.mock_message.should equal(:mock_value)
    (1..10).each {mock.stub_message.should equal(:stub_value)}
  end
  
  it "can stub! and mock the same message" do
    mock = mock("stubbing mock")
    mock.stub!(:msg).and_return(:stub_value)
    mock.should_receive(:msg).with(:arg).and_return(:mock_value)
    mock.msg.should equal(:stub_value)
    mock.msg(:other_arg).should equal(:stub_value)
    mock.msg(:arg).should equal(:mock_value)
    mock.msg(:another_arg).should equal(:stub_value)
    mock.msg(:yet_another_arg).should equal(:stub_value)
    mock.msg.should equal(:stub_value)
  end
end