mlins (owner)

Revisions

gist: 2165 Download_button fork
public
Public Clone URL: git://gist.github.com/2165.git
Embed All Files: show embed
main.rb #
1
2
3
4
5
6
7
8
9
class Main
 
  def self.run
    b = Blah.new
    b.start
    b.stop
  end
  
end
main_spec.rb #
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
require 'spec_helper.rb'
require 'main'
 
describe "main" do
  
  before do
    @blah = flexmock(:start => true, :stop => true)
    Blah = flexmock(:new => @blah)
  end
  
  it "should start blah" do
    @blah.should_receive(:start).and_return(true)
    Main.run
  end
  
  it "should start blah" do
    @blah.should_receive(:stop).and_return(true)
    Main.run
  end
  
  after do
    Object.send(:remove_const, :Blah)
  end
  
end
spec_helper.rb #
1
2
3
4
5
6
7
8
9
10
11
begin
  require 'spec'
rescue LoadError
  require 'rubygems'
  gem 'rspec'
  require 'spec'
end
 
Spec::Runner.configure do |config|
  config.mock_with :flexmock
end