[rspec-users] variable strange change

2010-09-15 Thread Zhenning Guan
class User has_many :mads def mad Mad.find_by_user_id(id) end end class God belongs_to :mad belongs_to :user belongs_to :sender, :class_name = User, :foreign_key = sender_id def strange_change! God.transaction do puts mad.nil?#the first time put is false if

[rspec-users] how to wrtie this test?(test true but change when refactor)

2010-09-04 Thread Zhenning Guan
def process! #transaction block bankbook = self.bankbooks.build bankbook = user.bank.bankbooks.build bankbook.withdraw #end end it should process the withdrawal request do #something here omit withdrawal.process! @ning.bankbooks.last.price.should ==

[rspec-users] there should be one test or two?

2010-08-26 Thread Zhenning Guan
in real world, when user deposit money into their bank, bank have money and can check deposit record. so what would it be in rspec? it 'should be deposit $10' user.bank.deposit(10) user.bank.deposit.saving.should == 10 end about test , should be deposit $10 is clear? maybe 'should deposit

[rspec-users] should_receive break the method chain?

2010-07-29 Thread Zhenning Guan
class A def process @b.calculate end end it 'should change b calculate value' do @b.should_receive(:calculate) @a.process @b.calculae_value.should == 'after_calculae' end it will fail, if I comment out #...@b.should_receive(:calculate), the test pass, or if comment out

[rspec-users] [rails] shoud I test validate_presentence_of series?

2010-07-21 Thread Zhenning Guan
Suppose I have a model Forum, have some attributes, title, content, tag.so I do it in Forum model. validates_presence_of :title validates_presence_of :tag validates_presence_of :content. when I added validateds_presence_of, rails will restrict the attribute not be empty, when save record. so

Re: [rspec-users] [rails] shoud I test validate_presentence_of series?

2010-07-21 Thread Zhenning Guan
thank you all. :) -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] how to test a observer model?

2009-11-26 Thread Zhenning Guan
Matt Wynne wrote: You can do something like this to sense the value passed to the user object: Obviously the precise specifications of the key are up to you and your stakeholders, but that should show you how you can test it. cheers, Matt http://mattwynne.net +447974 430184 thank you.

[rspec-users] how to test a observer model?

2009-11-25 Thread Zhenning Guan
I have a user_observer, code like this: def after_create(user) UserMailer.deliver_signup_notification(user) user.random_key = random_key_method user.save end before do @user = mock_model(User) @user_observer = UserObserver.instance end

[rspec-users] why should_receive doesn't work, but stub does.

2009-07-14 Thread Zhenning Guan
before(:each) do @myinstance = GetHtml.new end it should be a Hyricot do hy = open('test.html') {|f| Hpricot f} @myinstance.should_receive(:find_html).with(file:///test_url).and_return(hy) end ++ it should be a Hyricot do hy =

[rspec-users] why should_receive failure?

2009-07-14 Thread Zhenning Guan
class PeepCode def awesome awesome end end describe PeepCode do it should fuck do PeepCode.new.should_receive(:awesome).and_return(awesome) end end - Spec::Mocks::MockExpectationError in 'PeepCode should fuck' #PeepCode:0xb7aa3bbc

[rspec-users] what does :save = true mean in mock_model ?

2009-06-27 Thread Zhenning Guan
@weather = mock_model(Weather, :id = 1) @forecast = mock_model(Forecast, :weather = @weather, :save = true) what's the different between with :save = true or without it? -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list

Re: [rspec-users] what does :save = true mean in mock_model ?

2009-06-27 Thread Zhenning Guan
David Chelimsky wrote: clear, thank you David -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] what does :save = true mean in mock_model ?

2009-06-27 Thread Zhenning Guan
one more question. Forecast.stub!(:new).and_return(@forecast) Forecast.should_receive(:new).with(anything()).and_return(@forecast) what's the different between stub! and should_receive ? -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing

[rspec-users] how to deal with redirect_to on cucumber?

2009-05-20 Thread Zhenning Guan
I have a controller name forums and a action like this: def show redirect_to forum_topics_path(:forum_id = params[:id]) end my scenario is (not completed) == Scenario: User input data correct When I run to the forum 1 -- When /^I run to the (.*)$/ do |topic_lists| visit

[rspec-users] what is the context?

2009-03-29 Thread Zhenning Guan
describe MovieList do context when first created do it should be empty do movie_list = MovieList.new movie_list.should be_empty end end end what is the context work for? -- Posted via http://www.ruby-forum.com/. ___ rspec-users

[rspec-users] what's the different between ([...@weather]) and (@weather)?

2009-03-26 Thread Zhenning Guan
before do @weather = mock_model(Weather) Weather.stub!(:find).and_return([...@weather]) end I saw this code on peepcode, but I'm a little confused the and_return([...@weather]). mostly, we just and_return(@weather), don't we? so, what is the meaning of and_return([...@weather]) ? -- Posted

[rspec-users] what's the meaning of to_param?

2009-03-19 Thread Zhenning Guan
usually, I just use this way. = @weather = mock_model(Weather) = but recently I saw this. so what's the :to_param and :save options meaning? == @weather = mock_model(Weather, :to_param = 1, :save = true) == -- Posted via http://www.ruby-forum.com/.