Hi, I've run into a bit of a snag...
I have a method like this class Thing def bar I18n.t("waka.waka", { :fozzy => "bear" }) end end And I was trying to make a test that did: describe "#bar" do it "translates like a mo fo" do I18n.stubs(:t).with("waka.waka", { :fozzy => "bear" }).returns "hooray!" subject.bar.should == "hooray!" end end However running this test gives me: Mocha::ExpectationError: unexpected invocation: I18n.t(:user_subject, {:scope => [:devise, :mailer, :confirmation_instructions], :default => [:subject, 'Confirmation instructions']} ... Which is obviously because when I stub the t method, I am killing any previous behavior.......... So, I am quite confused what to do here. If I try to just be more generic and do: describe "#bar" do it "translates like a mo fo" do I18n.stubs(:t).returns "hooray!" subject.bar.should == "hooray!" end end Then I get a whole different weird error: Failure/Error: let(:notification) { new_notification(:notifiable => create_offer, :action => "made") } ArgumentError: wrong number of arguments (4 for 5) ... But I don't want to be generic like that anyway--- So I am wondering what can I do to solve this? Does any one know of a way to temporarily add an entry into my en.yml locale dynamically? In other words, so that instead of stubbing I could just do something like: I18n.t("waka")[:waka] = "hooray!" and then in code can still access I18n.t("waka.waka").. But that doesn't work, and I am not sure how to pull that off... Any help would be greatly appreciated. Patrick J. Collins http://collinatorstudios.com _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users