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
UserMailer.should_receive(:deliver_signup_no
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
t
one_data = Net::HTTP.post_form(URI.parse(country_site), {'country' =>
"american"})
two_data = Net::HTTP.post_form(URI.parse(visit_site), {'country' =>
"english"})
I have a code similar like above code in my application, so how to mock
a a object like above? if only post_from once, I just need to s
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 afte
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
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 #...@b.calculae_v
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 $10
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 == BigDecimal('1.0
David Chelimsky wrote:
> I'm having a hard time understanding what you're trying to do here. Can
> you please post the full before and after code and spec listing in a
> gist or pastie?
>
> http://gist.github.com
> http://pastie.org
the before just mock a user. and user request to withdraw mone
David Chelimsky wrote:
> By "before and after" I meant what the code looked like before you made
> the change you want to make, and what it looked like after the change.
sorry I misunderstood your word.
def process!
#transaction block
bankbook = self.bankbooks.build
bankbook = user.
> In your original post you said you were getting two bankbook items after
> the change. Do you want one or two? And where is the 2nd one coming
> from?
I always want one . after change the code I got two. and the original
test doesn't fail.
def process!
#transaction block
bank.withdraw
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
= flash_messages
- @user = User.find(1)
- if current_user == @user
%new_forum= link_to 'new forum', new_forum_path
- @forum.each do |f|
.group
= link_to f.name, forum_path(f)
- if current_user == @user
= link_to 'edit', edit_forum_path(f)
= link_to 'destroy', forum_path(f),
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/.
__
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 v
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-us
forums.feature
=
Feature: Tasks
In order to keep track of tasks
People should be able to
Create a list of tasks
Scenario: List Tasks
When I go to the homepage
=
forums_steps.rb
=
When /^I go to the homepage$/ do
visit "/forums"
end
=
when I run rake features.
==
Scenario: List Tasks# f
Scenario: List Tasks
Then I should have 3 forums
-
Then /^I should have ([0-9]+) forums$/ do |counts|
Forum.count.should == counts.to_i
end
When I go to the homepage #
features/step_definitions/webrat_steps.rb:10
Then I should have 3 forums #
features/step_definitions
Zhenning Guan wrote:
> David Chelimsky wrote:
>> On Tue, May 19, 2009 at 10:09 AM, Zhenning Guan
>> wrote:
>>> features/step_definitions/webrat_steps.rb:10
>>>
>>> 1 scenario (1 failed)
>>> 2 steps (1 failed, 1 passed)
>>>
>>&
David Chelimsky wrote:
> On Tue, May 19, 2009 at 10:09 AM, Zhenning Guan
> wrote:
>> features/step_definitions/webrat_steps.rb:10
>>
>> 1 scenario (1 failed)
>> 2 steps (1 failed, 1 passed)
>>
>> ===
>> Forum.count == counts.to_i does fine
>
&
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 path
@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
rspec
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
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
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 = o
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'
# expected :awesome wit
26 matches
Mail list logo