On 30.9.2009, at 14.37, Mithun Perera wrote:
thanks Matt
Any other tutorial because i go through it. but no idea.
cheers,
http://lmgtfy.com/?q=rspec+introduction+tutorial
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
.
There's probably a lot of optimization left to do with the specs but I
find the dispatch helpers pretty cool for building more specialized
methods such as do_post.
I hope the merb folks will keep us outside-(s)inners in mind and not
scrap the API.
Cheers,
//jarkko
--
Jarkko Laine
http
://rapidstraining.fi/ ;-)
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
smime.p7s
Description: S/MIME cryptographic signature
___
rspec-users mailing list
rspec-users@rubyforge.org
environment:
ActionController::Base.default_url_options.update :host =
'mysite.com'
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
___
rspec-users mailing list
rspec-users
=
development_url.com }
Not sure if it works the same way with ActionController, though. You
can of course set the request host by hand in a setup method:
@request.host = host
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
of the TDD cycle here. It
generally happens between every layer after the specs pass.
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
___
rspec-users mailing list
rspec-users
beyond the point here...
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
that (especially if/when they mock the models) it won't trip the
scaffolding specs per se.
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
smime.p7s
Description: S/MIME cryptographic signature
/mailman/listinfo/rspec-users
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
smime.p7s
Description: S/MIME cryptographic signature
___
rspec-users mailing list
rspec-users@rubyforge.org
http
://www.patchspace.co.uk/
http://aviewfromafar.net/
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
?
I'm just using the one that comes with ZenTest. No need for anything
else, just run 'autotest' in the root of your Rails app.
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
smime.p7s
Description: S/MIME cryptographic
test that @comment.author.should be(@user) because you
have stubbed author= and it doesn't really do anything. So you just
have to rely on that it works (like you should since it's Rails code
which you shouldn't really be testing).
//jarkko
--
Jarkko Laine
http://jlaine.net
http
do
it should show all the current entries for the user do
get :index
assigns[:entries].should == @entries
end
I don't see you logging in a user anywhere.
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
smime.p7s
PROTECTED]://rubyforge.org/mailman/listinfo/rspec-users
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http
.. That's why
you consider controller.send(current_user=,..) a bit hacky right?
Yes. Just create a given that goes through the normal logging process.
You can parameterize it so that you can reuse it with different roles.
//jarkko
--
Jarkko Laine
http://jlaine.net
http
/listinfo/rspec-users
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
smime.p7s
Description: S/MIME cryptographic signature
___
rspec-users mailing list
rspec-users@rubyforge.org
http
correctly tests the behaviour, whereas the latter checks the
actual implementation, which in this case is superfluous. I hardly
ever use should_receive with a setter method such as author=, but it
might just be me.
Cheers,
//jarkko
--- Jarkko Laine [EMAIL PROTECTED] ha scritto
ApplicationHelper do
describe keycase do
describe when no dots do
before(:each) do
@value = IBM
end
it should convert to lowercase do
keycase(@value).should == Ibm
end
end
end
end
And so on.
//jarkko
--
Jarkko Laine
http://jlaine.net
http://odesign.fi
.
//jarkko
--
Jarkko Laine
http://jlaine.net
http://odesign.fi
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
terminal for normal specs.
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
smime.p7s
Description: S/MIME cryptographic signature
___
rspec-users mailing list
rspec-users
On 21.2.2008, at 4.14, Scott Taylor wrote:
On Feb 20, 2008, at 1:52 AM, Jarkko Laine wrote:
On 20.2.2008, at 6.55, Scott Taylor wrote:
That said, now that autotest runs via drb, it's vastly (like 50%)
slower than without it,
That's the idea.
Isn't the idea that specs run faster through
: [Barney Hops doesn't have the required competency (MBA) to
teach this class, Barney Hops doesn't have the required competency
(MBA) to teach this class]
Mock 'Enrollment' expected :on_waiting_list? with (any args) twice,
but received it 3 times
//jarkko
--
Jarkko Laine
http://jlaine.net
http
.
Cheers,
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
smime.p7s
Description: S/MIME cryptographic signature
___
rspec-users mailing list
rspec-users@rubyforge.org
http
drb at all since it runs the same whether or not the
spec_server is running. Yeah, I know that was the reason for the patch.
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
smime.p7s
Description: S/MIME cryptographic
:-)
Cheers,
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
smime.p7s
Description: S/MIME cryptographic signature
___
rspec-users mailing list
rspec-users@rubyforge.org
http
some of
the early posts about stories).
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
smime.p7s
Description: S/MIME cryptographic signature
___
rspec-users mailing list
rspec
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
smime.p7s
Description: S/MIME cryptographic signature
On 13.2.2008, at 21.09, Brad Carson [EMAIL PROTECTED] wrote:
Pat Maddox wrote:
Try
Event.stub!(:find).and_raise(RecordNotFound)
To my credit, I did try that (though ActiveRecord::RecordNotFound, of
course) but then I get:
EventsController attempt to show non-existing event
- should
-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
___
rspec-users mailing list
rspec-users
@creating_user.should change(User, :count).by(1)
end
end
Thanks for any pointers or clarifications!
Same thing, just this time the function is first stored in an instance
variable.
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
that the route is working, it would imho
belong to the controller specs, not to the stories.
Cheers,
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
___
rspec-users mailing list
rspec-users
Often I also stub the errors method there because it's called pretty
often in controllers and views.
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
___
rspec-users mailing list
(and it doesn't and shouldn't):
You can do it like this:
@coupon = mock_model(Coupon, :user= = nil, :user =
@current_user, :save = true)
Note both :user= and :user.
In your pastie you only have :user
Cheers,
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http
On Jan 11, 2008, at 5:54 PM, Ben Mabey [EMAIL PROTECTED] wrote:
David Chelimsky wrote:
In TDD there is a rule of thumb that says don't stub a method in the
same class as the method you're testing. The risk is that as the real
implementation of by_input_sets!() changes over time, it has
like it should be an instance method
anymore.
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman
speccing the controller behaviour here, not business logic.
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
___
rspec-users mailing list
rspec-users@rubyforge.org
http
broken spec is fixed, and the code works as expected. Tada!
No need to stub String#split anywhere.
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
___
rspec-users mailing list
:index
end
It is then the responsibility of the articles association to scope the
results. In the controller specs you just trust that it works.
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
On 3.12.2007, at 21.05, Nathan Sutton wrote:
Department.stub!(:find_by_code).with(75).and_return(3)
You can't use with() with stub! (only with should_receive), so just
leave it away:
Department.stub!(:find_by_code).and_return(3)
//jarkko
--
Jarkko Laine
http://jlaine.net
http
On 4.12.2007, at 8.40, Fischer, Daniel wrote:
Sorry for so many messages, I hope I don't get in trouble for this.
Maybe IRC would be better if there was a RSpec one.
#rspec @freenode
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http
On 20.11.2007, at 10.08, Nathan Sutton wrote:
Didn't have time tonight, stand-by for something tomorrow.
Done: http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/132-
plain-text-stories-should-support-given-and-given
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http
?
Cheers,
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
than just the one, you
start finding patterns there and you can easily refactor the stubbing
into spec helpers so that you only need a line or two to create a
comprehensive mock model in your specs.
HTH,
//jarkko
P.S. in Ruby true and false are normally written in lower case.
--
Jarkko Laine
/5645/
tickets/132-plain-text-stories-should-support-given-and-given).
However, multiline parameters aren't supported in plain text story
steps yet, either.
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
)
contract_line_item_path (and _url) expects two parameters, contract
and line item (or their ids). The errors the routing code outputs are
often pretty cryptic.
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
On 13.11.2007, at 19.21, David Chelimsky wrote:
On Nov 13, 2007 10:52 AM, Jarkko Laine [EMAIL PROTECTED] wrote:
Is there something currently going on on the rspec trunk that causes
a massive slowdown when running rake spec and autotest (without
spec_server)? I updated to the latest trunk
thing is that if I run the rake spec tasks
separately (controllers, models, views, helpers), they still take
about 20 seconds in total: http://pastie.caboo.se/117362
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
])
controller.send :current_user=, user
end
Then you can just say this in the specs:
login_as(@user_mock_object)
and the controller will behave accordingly (assuming you use
restful_authentication/acts_as_authenticated).
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http
,
:name = name,
:description = Everything from the latest gossip to the coolest
youtube videos.)
forum
end
How do I stop the incrementing?
--
--
Jarkko Laine
http://jlaine.net
http://odesign.fi
___
rspec-users mailing list
rspec-users
On 13.9.2007, at 23.29, aslak hellesoy wrote:
On 9/13/07, Jarkko Laine [EMAIL PROTECTED] wrote:
I've come across rather strange behaviour when trying to raise an
exception in a stubbed method.
I'm speccing the behaviour of a Rails create action, where I'm using
save! to catch failed saves
-to-end stuff. Even
on an app running on Rails 1.2, the rspec trunk installed flawlessly
with some minimal changes to the existing spec code. From what I
learned, Story Runner is already highly usable even though it's not
officially out.
//jarkko
--
Jarkko Laine
http://jlaine.net
http
to identify the controller. I think the former way is now considered
best practice.
If you want to test routes, do it separately. IIRC generating an
rspec_scaffold will create you examples of how to do that.
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http
shouldn't assume any args.
Moreover, both cases work fine in the real app, so it seems to me
something funky is happening when stubbing the method.
Anyone else stumbled upon anything similar?
Cheers,
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http
On 13.9.2007, at 19.52, sinclair bain wrote:
Hi!
Have you considered mocking / stubbing to test in isolation if that
is appropriate ?
Right, my example was also assuming that you are using mocks for users.
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http
55 matches
Mail list logo