File: configuration_test.rb

package info (click to toggle)
ruby-mocha 0.11.3-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,300 kB
  • sloc: ruby: 9,935; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 1,391 bytes parent folder | download
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
require File.expand_path('../../test_helper', __FILE__)
require "mocha/configuration"

class ConfigurationTest < Test::Unit::TestCase
  def test_allow_temporarily_changes_config_when_given_block
    Mocha::Configuration.warn_when(:stubbing_method_unnecessarily)
    yielded = false
    Mocha::Configuration.allow(:stubbing_method_unnecessarily) do
      yielded = true
      assert Mocha::Configuration.allow?(:stubbing_method_unnecessarily)
    end
    assert yielded
    assert Mocha::Configuration.warn_when?(:stubbing_method_unnecessarily)
  end

  def test_prevent_temporarily_changes_config_when_given_block
    Mocha::Configuration.allow(:stubbing_method_unnecessarily)
    yielded = false
    Mocha::Configuration.prevent(:stubbing_method_unnecessarily) do
      yielded = true
      assert Mocha::Configuration.prevent?(:stubbing_method_unnecessarily)
    end
    assert yielded
    assert Mocha::Configuration.allow?(:stubbing_method_unnecessarily)
  end

  def test_warn_when_temporarily_changes_config_when_given_block
    Mocha::Configuration.allow(:stubbing_method_unnecessarily)
    yielded = false
    Mocha::Configuration.warn_when(:stubbing_method_unnecessarily) do
      yielded = true
      assert Mocha::Configuration.warn_when?(:stubbing_method_unnecessarily)
    end
    assert yielded
    assert Mocha::Configuration.allow?(:stubbing_method_unnecessarily)
  end
end