File: bug_report_600_spec.rb

package info (click to toggle)
ruby-rspec-mocks 2.14.5-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 868 kB
  • ctags: 725
  • sloc: ruby: 8,227; makefile: 4
file content (22 lines) | stat: -rw-r--r-- 541 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require 'spec_helper'

module BugReport600
  describe "stubbing a class method" do
    class ExampleClass
      def self.method_that_uses_define_method
        define_method "defined_method" do |attributes|
          load_address(address, attributes)
        end
      end
    end

    it "works" do
      ExampleClass.should_receive(:define_method).with("defined_method")
      ExampleClass.method_that_uses_define_method
    end

    it "restores the original method" do
      ExampleClass.method_that_uses_define_method
    end
  end
end