Created
July 31, 2008 05:22
-
-
Save nikonoid/3412 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.dirname(__FILE__) + '/../spec_helper' | |
require File.dirname(__FILE__) + '/../../app/models/notifications' | |
class Notifications | |
def self.spec_new(method_name,*parameters) | |
n = self.allocate | |
n.__send__ :initialize_defaults, method_name | |
n.__send__(method_name, *parameters) | |
return n | |
end | |
def iv(name) | |
instance_variable_get("@#{name}") | |
end | |
end | |
describe ::Notifications do | |
describe "recruitment model" do | |
before(:each) do | |
#require 'ruby-debug' | |
@valid_param_hash = | |
{ | |
'firstname' => "fakeous", | |
'preferredname' => "fake", | |
'surname' => "user", | |
"recruitment" => "some BS stuff" | |
} | |
@from = '[email protected]' | |
end | |
it "should have valid attributes after induction_memo call" do | |
#TODO mock out Notifications lookup from the below n.should_receive(:lookup)... | |
@n = Notifications.spec_new(:induction_memo,@valid_param_hash) | |
@n.iv(:body)["recruitment"].should == @valid_param_hash | |
@n.iv(:recipients).should == @n.lookup('induction memo recipients') | |
@n.iv(:from).should == @from | |
end | |
it "should have valid attributes after notification_for_resourcing call" do | |
#TODO mock out Notifications lookup from the below n.should_receive(:lookup)... | |
@n = Notifications.spec_new(:notification_for_resourcing,@valid_param_hash) | |
@n.iv(:body)["recruitment"].should == @valid_param_hash | |
@n.iv(:recipients).should == @n.lookup('resourcing recipients') | |
@n.iv(:from).should == @from | |
end | |
it "should have valid attributes after notification_for_resourcing call" do | |
#TODO mock out Notifications lookup from the below n.should_receive(:lookup)... | |
@n = Notifications.spec_new(:notification_for_resourcing,@valid_param_hash) | |
@n.iv(:body)["recruitment"].should == @valid_param_hash | |
@n.iv(:recipients).should == @n.lookup('resourcing recipients') | |
@n.iv(:from).should == @from | |
end | |
end | |
describe "purchase model" do | |
before(:each) do | |
#require 'ruby-debug' | |
@valid_param_hash = | |
{ | |
'supplier' => "supplier X", | |
'price' => '10' | |
} | |
Notifications.stub!(:render_message).and_return(true) | |
end | |
it "should have a mail subject that contains supplier and price" do | |
@n = Notifications.spec_new(:purchase,@valid_param_hash) | |
@n.iv(:subject).should == /@valid_param_hash['supplier']/ | |
@n.iv(:subject).should == /@valid_param_hash['price']/ | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment