Hi,
I am completely puzzled with the following situation. I stub an object
to avoid complex data setup, which normal implementation of
#last_statement requires. Stub works fine when I check it before
calling #charge!, but doesn't work inside #charge! call. Any ideas
anybody?
I am using bundler08 gem. My Gemfile and requires are pasted below.
class Account
def last_statement
nil # for simplicity
end
def charge!
if last_statement # stub doesn't work here
# should get here when running tests
CreditCardPayment.create!
end
end
end
class AccountTest < Test::Unit::TestCase
context "Account" do
setup do
@account = Factory(:good_trading_member).account
end
should "charge credit card when due" do
@account.stubs(:last_statement => true)
assert_not_nil @account.last_statement # stub works here
assert_difference "CreditCardPayment.count", 1 do
account.charge!
end
end
end
end
Gemfile:
clear_sources
source '
http://gemcutter.org'
source '
http://gems.github.com'
gem "rails", "2.0.2"
gem "mysql"
gem "image_science", "1.2.0"
gem "mime-types", "1.16"
gem "nokogiri", "1.3.3"
gem "prawn", "0.6.3"
gem "prawn-core", "0.6.3"
gem "prawn-format", "0.2.3"
gem "prawn-layout", "0.3.2"
gem "prawn-security", "0.1.1"
gem "RubyInline", "3.8.2"
gem "dictionary", "1.0.0"
gem "RedCloth", "3.0.4"
only :test do
gem "thoughtbot-shoulda", "2.10.2"
gem "factory_girl", "1.2.3"
gem "mocha", "0.9.8"
end
test_helper.rb begins with:
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/
environment")
require 'test_help'
require 'shoulda'
require 'mocha'
require 'factory_girl'; Factory.find_definitions
--
You received this message because you are subscribed to the Google Groups "mocha-developer" group.
To post to this group, send email to
mocha-d...@googlegroups.com.
To unsubscribe from this group, send email to
mocha-develop...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/mocha-developer?hl=en.