mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-06-06 05:25:29 +00:00
git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@2 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
ROOT_PATH = File.expand_path(File.dirname(__FILE__) + "/../")
|
||||
|
||||
# Setup our load path:
|
||||
[
|
||||
'lib',
|
||||
].each do |dir|
|
||||
$LOAD_PATH.unshift(File.join(ROOT_PATH, dir))
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
class CMock
|
||||
attr_accessor :mocks_path, :includes, :interface_parser
|
||||
|
||||
def initialize(mocks_path='mocks', includes=[], interface_parser=nil)
|
||||
@mocks_path = mocks_path
|
||||
@includes = includes
|
||||
@interface_parser = interface_parser
|
||||
end
|
||||
|
||||
def generate(module_header)
|
||||
@interface_parser.extract_interface(module_header)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
$here = File.dirname(__FILE__)
|
||||
|
||||
require 'rake'
|
||||
require 'rake/clean'
|
||||
require 'rake/testtask'
|
||||
|
||||
task :default do
|
||||
sh 'spec test'
|
||||
end
|
||||
@@ -0,0 +1,41 @@
|
||||
$here = File.dirname(__FILE__)
|
||||
require "#{$here}/../config/environment"
|
||||
require 'cmock'
|
||||
|
||||
describe CMock do
|
||||
|
||||
before(:each) do
|
||||
@interface_parser = mock('InterfaceParser')
|
||||
@cmock = CMock.new('mocks', [], @interface_parser)
|
||||
end
|
||||
|
||||
it "should default mocks path to 'mocks'" do
|
||||
@cmock.mocks_path.should == 'mocks'
|
||||
end
|
||||
|
||||
it "should allow mocks path to be specified in constructor" do
|
||||
@cmock = CMock.new('yoohoo')
|
||||
@cmock.mocks_path.should == 'yoohoo'
|
||||
end
|
||||
|
||||
it "should default includes to empty array" do
|
||||
@cmock.includes.should == []
|
||||
end
|
||||
|
||||
it "should allow includes to be specified in constructor" do
|
||||
includes = ['fun', 'stuff']
|
||||
@cmock = CMock.new('blah', includes)
|
||||
@cmock.includes.should == includes
|
||||
end
|
||||
|
||||
it "should generate a mock module" do
|
||||
@cmock.should respond_to(:generate)
|
||||
end
|
||||
|
||||
it "should delegate to parser to extract interface" do
|
||||
module_header = 'my_module.h'
|
||||
@interface_parser.should_receive(:extract_interface).with(module_header)
|
||||
@cmock.generate(module_header)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user