similar to: Newbie: lambda do...end.should change(Model, :count).by(1). Doesn''t work

Displaying 20 results from an estimated 5000 matches similar to: "Newbie: lambda do...end.should change(Model, :count).by(1). Doesn''t work"

2008 Jan 27
8
Textmate RSpec Bundle ''it'' snippet
It seems to me that the RSpec bundle''s ''it'' snippet is in need of some love. By default, a newly inserted spec passes. This seems odd as it is misleading. It also makes it harder find what specs still need to be completed if you return to an RSpec module after a break. I propose that the ''it'' snippet is changed to the following: it
2008 May 29
7
how to write spec for infinite loop?
Hi, I''ve got trouble when describe infinite loop. code snippet: def start_loop while true data = self.server.handle_client if data self.manager.dispatch(data) end end end without the loop, it is easy to test the logic. but how can I describe it to tell the developer ( me :-) ) that there should be an infinite loop inside. thanks. Regards, Peng
2008 Mar 08
10
rspec groups?
One of the things I really liked about TestNG was the grouping feature. Are there any plans for rSpec to incorporate that? Is there any way to emulate that functionality in rspec? Will.
2006 Nov 07
7
should_redirect_to in advance - feels unnatural
I can understand that it''s easier for rspec to set up a mock in advance of the controller call. But it makes it difficult to do something like: context "The HarkController, given Louie the logged-in user" do setup do post :login, :username => ''louie'', :password => ''atest'' end specify "should redirect Louie to the home
2007 May 30
4
Using mocks
I''ve just started doing TDD/BDD and like the idea of mocks. So I set out to use them. The doc pages seem great, I setup the mock and then it just works. Here is what I am trying to do: Myuser is a non-rails model of user attributes. We are going to be mocking the connection to the ldap server. The user class has a login method that connects to the ldap server and if successful,
2007 May 24
9
Mocking, changing method interfaces and integration tests
Suppose we have a method ''foo'' which internally uses another method ''bar''. Being good BDDers we mock out the ''bar'' method. After all, we only want to spec the ''foo'' method - actually running the ''bar'' method means slower, less maintainable and brittler specs. That''s why we <3 mocking,
2007 Oct 08
6
stub actions that depend on the parameter
Hi, I''m pretty new to all related to bdd and rspec and I have the following question. Is it possible to stub actions that return different objects depending on the parameteres they were called with? Something like this: MyClass.stub!(:method).with(1).and_return(@mock_object_1) MyClass.stub!(:method).with(2).and_return(@mock_object_2) I know I could use
2007 Oct 17
15
Any tips on teaching BDD with RSpec?
Hi I hope this is not OT. I''m training my replacement at work to do BDD Rails development. He''s done a CS/maths degree but has no professional programming experience, so he''s never NOT done a project without BDD. In a way I am jealous of his unspoilt situation :) I''ve gone about things this way: * first teach him some Ruby (he did mainly Java at
2007 Aug 24
26
testing behaviour or testing code?
hypothetical question for all you BDD experts: I want to make sure that a :list action always returns widgets in alphabetical order. There''s at least 2 ways of doing this: it "should fetch items in alphabetical order" do Widget.should_receive(:find).with(:order => "name ASC") get :list end it "should fetch items in alphabetical order" do [:red,
2008 Jan 11
13
Role of stories vs specs, revisited
A couple months ago I asked how stories and specs might impact each other. [1] If you look at Dan North''s example of what''s in a story [2], and you imagine using the spec framework to drive the design, you can probably imagine a significant bit of overlap in the two. Is that a bad thing? I''m not sure. It has made me a bit uncomfortable though, and I''ve
2008 Jun 03
9
Build rspec-rails as a gem?
I can''t figure out how to build rspec-rails as a gem when just cloned from github... there isn''t any .gemspec file or rake task that does this. Any help? -- Posted via http://www.ruby-forum.com/.
2011 Mar 03
1
Does RSpec interfere with Pathname#dirname or Pathname#realpath ?
Hi, I starting a new project, and have run into behavior I cannot replicate in irb, (i.e. outside of using rspec) when the directory? returns true, so I thought I''d ask here, in case any one has seen this badhavior. ruby-1.9.2-p136 rspec (2.5.0) rspec-core (2.5.1) rspec-expectations (2.5.0) rspec-mocks (2.5.0) When I try to run this spec: require Pathname(__FILE__).ascend { |d|
2007 Dec 21
4
I need some guidance
I''m building an http communicator class for a web service API wrapper and I''m trying to go through the BDD process in doing so. I''m having a bit of a struggle figuring out how to set up the tests in relation to isolating things appropriately as well as testing behavior vs testing implementation. Specifically, I''m trying to set up a post method on my
2007 Oct 19
27
Assumption tests
Hi all, I''ve been thinking about the whole validator/relationship speccing issue, and I came up with a suggestion, which I''d love to get some feedback on. The full article is available at http://www.inter-sections.net/ 2007/10/19/what-to-test-and-specify-and-where-to-do-it/ , with the relevant bit being about halfway down, but here''s the gist of it: 1.
2007 Aug 31
48
Deprecating the mocking framework?
I saw in one of Dave C.''s comments to a ticket that "our current plan is to deprecate the mocking framework." I hadn''t heard anything about that, but then again I haven''t paid super close attention to the list. Are we planning on dumping the mock framework in favor of using Mocha (or any other framework one might want to plug in?). Pat
2007 Mar 24
15
State Based vs. Behaviour Based Spec/Testing
I''ve notice that a project like Rubinius has both a spec & a test directory. Rspec has only a spec directory. Obviously I support BDD, but isn''t there also a place for state based/verification testing? I sometimes sense that I *do* want to practice Test Driven Development. That is, I want some assurance that my production code will run as intended. But I also
2007 Oct 04
16
Spec/Test Speed
Just wanted to pick some smart people about this topic: What are you guys doing to increase the speed of your specs? I''m a big fan of autotest, but right now my current project has 438 specs (for rails). Most of them are in the model, and for all of them we are hitting the database (they are more functional specs than unit-tests). The whole suite takes 112 seconds (meaning the
2007 Feb 07
1
advice on a spec''ing best practice
i am in the process of converting the tests in two projects that i am working on (one rails, one ruby) to rspec. i felt like i was doing ok applying BDD and using rspec properly until i read a comment in another topic on the list from David (subject "long jumping out of code in specs"). In there it was said: --- Testing privates is a no-no, but testing that a public method on the same
2007 Jul 06
5
Outside-In with RSpec on Rails
I just read ''Mocks Aren''t Stubs'' and was intrigued by the notion of ''outside-in'' TDD. As a Rails developer, I''m curious if others are employing this method when developing Rails applications using RSpec. Is it common practice (or even practical) to drive the development of a Rails app by starting with view specs, then controller specs, then
2008 Jun 11
3
help with test design
I''m having trouble figuring out how to drive the design of a class. I''m hoping I can get a hint or two from the more experienced BDDers on this list. I''m writing an adapter class that sits between a 3rd party library and my business logic. I would like to extract some information from objects available from the 3rd party lib and covert them into ruby objects.