Re: [rspec-users] Test configuration information

2013-01-23 Thread J. B. Rainsberger
On Wed, Jan 23, 2013 at 2:54 PM, Jim Coble wrote: > One of my tests needs to be provided with a particular directory path. > While I can code this path as a literal directly in the test spec, it seems > to me it might be better to have it in a configuration file somewhere so > that I have one pl

Re: [rspec-users] Augmenting a previous 'let' value

2012-12-21 Thread J. B. Rainsberger
If you declare :hsh in two peer context (neither inside the other), then your shared group does the right thing: it demands the existence of :hsh and blows up when it doesn't exist. Better design, no? On Fri, Dec 21, 2012 at 9:24 AM, Arne Brasseur wrote: > I find myself wanting to do something

Re: [rspec-users] Drawing the line between controller and integration tests

2012-09-11 Thread J. B. Rainsberger
On Mon, Sep 10, 2012 at 5:51 PM, Fearless Fool wrote: > I'm trying to understand what belongs -- and what doesn't belong -- in > controller tests and in integration tests. > > As a common example, assume I have a list of named widgets. Somewhere > in my code, I want to verify that > > widget

Re: [rspec-users] How do I specify that a class does not receive any message

2012-08-22 Thread J. B. Rainsberger
On Wed, Aug 22, 2012 at 11:36 AM, David Chelimsky wrote: > On Wed, Aug 22, 2012 at 9:16 AM, J. B. Rainsberger wrote: > > On Wed, Aug 22, 2012 at 10:07 AM, David Chelimsky > > wrote: > >> > >> On Wed, Aug 22, 2012 at 7:52 AM, J. B. Rainsberger > wrote: >

Re: [rspec-users] How do I specify that a class does not receive any message

2012-08-22 Thread J. B. Rainsberger
On Wed, Aug 22, 2012 at 10:07 AM, David Chelimsky wrote: > On Wed, Aug 22, 2012 at 7:52 AM, J. B. Rainsberger wrote: > > On Tue, Aug 21, 2012 at 11:37 PM, Bas Vodde wrote: > >> > >> > >> JB is right. > >> > >> Sometimes, for clarity, it is u

Re: [rspec-users] How do I specify that a class does not receive any message

2012-08-22 Thread J. B. Rainsberger
On Tue, Aug 21, 2012 at 11:37 PM, Bas Vodde wrote: > > JB is right. > > Sometimes, for clarity, it is useful to add should_not, but for > functionality it is usually not needed. > I know JMock has never() for this people. Should RSpec-mocks have something like object.should_receive(:nothing). --

Re: [rspec-users] How do I specify that a class does not receive any message

2012-08-21 Thread J. B. Rainsberger
On Tue, Aug 21, 2012 at 5:02 PM, Andrew Premdas wrote: > I want to write > > it "should ..." do > Client.should_not_receive(any_message) > # do something here that might do Client.xxx > end > I might be wrong, but if you use a mock object and set no expectations on it, it will expect no mess

Re: [rspec-users] A recently observed anti pattern: commented out tests

2012-07-27 Thread J. B. Rainsberger
On Mon, Jul 23, 2012 at 10:54 PM, David Chelimsky wrote: > I'd say, let's encourage people to use 'pending' correctly. WDYT? +1. -- J. B. (Joe) Rainsberger :: http://www.jbrains.ca :: http://blog.thecodewhisperer.com Author, JUnit Recipes Free Your Mind to Do Great Work :: http://www.freeyourmi

Re: [rspec-users] Testing Signin for Admin_Employee

2012-02-25 Thread J. B. Rainsberger
On Thu, Feb 23, 2012 at 22:45, Justin Ko wrote: > Hello, what you want is "shared examples/context": > https://gist.github.com/1894922 I commented there, too. -- J. B. (Joe) Rainsberger :: http://www.jbrains.ca :: http://blog.thecodewhisperer.com Author, JUnit Recipes Free Your Mind to Do Great

Re: [rspec-users] Specing scopes that use includes()

2011-07-13 Thread J. B. Rainsberger
On Tue, Jul 12, 2011 at 16:03, Derek Prior wrote: > I'm a newcomer to the list. Appologies if this has been discussed before, > but all I could find with regards to specing scopes relates to those that > filter records or apply sorting. What's the best way to spec a scope that > uses the includes

Re: [rspec-users] stubbing /mocking ldap within a method

2011-06-21 Thread J. B. Rainsberger
n => @encryption) ldap.search(:filter => filter) end end Now it's easy to check: describe Collaborator do context "when searching" do it "should pass the proper surname to the TermRepository" do termRepository = mock("a TermRepository")

Re: [rspec-users] Stub an AR Model Instance Method

2011-06-19 Thread J. B. Rainsberger
On Sat, Jun 18, 2011 at 21:10, Karl wrote: > Found my problem... mostly due to my misunderstanding of mocks. Joe's > suggestion above led me down the right path. This worked: > > @account = mock_model(Account) > @account.stub!(:next_serial_number).and_return(43, nil) > Widget.any_instance.stub(:a

Re: [rspec-users] Stub an AR Model Instance Method

2011-06-11 Thread J. B. Rainsberger
On Thu, Jun 9, 2011 at 14:33, Karl wrote: > Obviously, I'm missing something very simple, can someone please > explain how to stub an instance of an AR model method. > > This does not work: > @widget = Widget.first # Widget has an instance method called > 'next_seriel_number' > @widget.stub(:next_

Re: [rspec-users] Overriding Kernel#inspect just for tests

2011-04-11 Thread J. B. Rainsberger
On Fri, Apr 8, 2011 at 02:52, Stefan Kanev wrote: > Occasionally, I write specs that verify the order in which some ActiveRecord > objects are returned. For example, in a toy project I do: > > Reply.stub :per_page => 2 > topic.replies_on_page(1).should == [second, first] > > The spec out quickly

Re: [rspec-users] specing a model to make sure it implements act_as_authentic

2010-12-07 Thread J. B. Rainsberger
On Wed, Dec 8, 2010 at 02:46, ssmithstone wrote: Is it possible to spec that a model should acts_as_authentic which is > from the authlogic gem? > > I'm using rspec-1.3.x > Whenever I don't know how to spec something -- or whether to spec something -- I ask, "If the thing I'm worried about failed

Re: [rspec-users] DateTime.now.utc in fixtures

2010-10-12 Thread J. B. Rainsberger
Russell Quinn wrote: I have the following in my fixtures: publish_date:<%= DateTime.now.utc - 1.day %> But 'DateTime.now.utc' always evaluates to my system time. Does anyone have any ideas? You might not like it, but what about fixing the date? -- J. B. Rainsberger :: http:

Re: [rspec-users] [Rails] rails view helpers, BDD, and what to mock

2010-09-19 Thread J. B. Rainsberger
On Fri, Sep 17, 2010 at 16:48, Doug E. wrote: > I'm trying to understand BDD and proper testing technique. I'm testing > a rails view helper method that checks user roles to see if a link > should be shown. I'm using rails 2.3.8 and rspec version 1.3.0. My > helper looks like this: > > # welcom

Re: [rspec-users] Re-using Rspec Matchers

2010-09-08 Thread J. B. Rainsberger
On Wed, Sep 8, 2010 at 14:42, Brian Kaney wrote: > Is it good practice to call matchers from within matchers?   Kinda like this > pattern: > >  See: http://gist.github.com/570467 David Chelimsky taught me not to invoke #should in a matcher, but rather just answer a boolean, so I expect that, ra

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

2010-09-03 Thread J. B. Rainsberger
On Fri, Aug 27, 2010 at 02:43, Zhenning Guan wrote: > 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? I prefer two specs, because you are checking two unrelated things: bank account balance and transaction reco

Re: [rspec-users] Factories vs. stubs/mocks

2010-09-03 Thread J. B. Rainsberger
On Mon, Aug 30, 2010 at 14:09, Rob Biedenharn > And THAT is the problem with using mocks (or stubs) for this.  You run the > very real risk of specifying the implementation details in the structure of > the spec/test.  There is a problem when you've limited the refactoring that > can be done withou

Re: [rspec-users] RSpec and Factory Girl: Destroying an object

2010-05-14 Thread J. B. Rainsberger
t time, I mock #destroy; and finally, if I want to check that my code reacts appropriately after destroying an object, then I stub #destroy. To understand some of the underlying principles, I humbly recommend this: http://jbrains.ca/integrated_tests_are_a_scam (The articles are in order

Re: [rspec-users] survey: roles in controller specs

2010-05-11 Thread J. B. Rainsberger
d, for which I write a spec. All my authorization specs are of the form " is not permitted to do " and I organize them by action. -- J. B. Rainsberger :: http://www.jbrains.ca :: http://www.thecodewhisperer.com ___ rspec-users mailing list rspec-use

Re: [rspec-users] Good practices on spec'ing views?

2010-05-07 Thread J. B. Rainsberger
the form I expect to submit. I imagine writing more of the latter kind of spec will encourage me to avoid complex form submissions. I treat view specs like any other specs: when I have a tough time writing the spec, then I rethink my design choices. -- J. B. Rainsberger :: http://www.jbrai

Re: [rspec-users] Mock Global method

2010-03-24 Thread J. B. Rainsberger
used me problems, at which point I'd separate the behavior of deciding what to print from deciding where to print it. I find formatting messages much easier to check, in general, than displaying them. Have fun. -- J. B. Rainsberger :: http://www.jbrains.ca :: http:/

Re: [rspec-users] Best practices to managing RSpec code for very large projects?

2010-02-04 Thread J. B. Rainsberger
On Thu, Feb 4, 2010 at 09:40, David Chelimsky wrote: > On Thu, Feb 4, 2010 at 8:09 AM, J. B. Rainsberger > wrote: >> On Thu, Feb 4, 2010 at 00:12, David Mitchell wrote: >> >>> What is the 'best practice' way to structure RSpec code and documentation >>

Re: [rspec-users] Passing parameters to Rspec scripts

2010-02-04 Thread J. B. Rainsberger
On Thu, Feb 4, 2010 at 12:35, Levi Conley wrote: > Thanks for the response. That's an interesting approach.  I will try > that and see how far I can get with it. > > If my ruby chops were a little better, I suspect I could find a more > elegant solution.  Any other ideas out there? It sounds lik

Re: [rspec-users] Best practices to managing RSpec code for very large projects?

2010-02-04 Thread J. B. Rainsberger
On Thu, Feb 4, 2010 at 00:12, David Mitchell wrote: > What is the 'best practice' way to structure RSpec code and documentation > when testing a very large project, where the RSpec code base has to be > maintained and extended over a long period? I don't mean to be glib, but my blink reaction is

Re: [rspec-users] When to use Factories, Mock Models, Mocks & Stubs

2010-02-03 Thread J. B. Rainsberger
2010/2/3 Nicolás Sanguinetti : > On Wed, Feb 3, 2010 at 2:07 PM,   wrote: >> I absolutely love the idea of encapsulated the daisy chained calls >> (c_u.comp.project) into a controller methods so all i gotta do is stub that >> out. > > Oooh, I hate that one :) > > You're adding lots of small methods

Re: [rspec-users] When to use Factories, Mock Models, Mocks & Stubs

2010-02-03 Thread J. B. Rainsberger
On Tue, Feb 2, 2010 at 19:00, Frank Lakatos wrote: > Hi guys, been following for about 3 weeks, first question - This might help a little: http://bit.ly/ONpXE To bring things back to Rails, I use mock_model whenever I want to design controller behavior without relying on the underlying model be

Re: [rspec-users] Specting controller post

2010-02-02 Thread J. B. Rainsberger
On Tue, Feb 2, 2010 at 09:18, J. B. Rainsberger wrote: > On Tue, Feb 2, 2010 at 07:26, Stephen Smithstone > wrote: > >> cheers for the response , seem that attributes is missing from hash on my >> system > > You'll find #attributes on ActiveRecord::Base, and

Re: [rspec-users] Specting controller post

2010-02-02 Thread J. B. Rainsberger
On Tue, Feb 2, 2010 at 07:26, Stephen Smithstone wrote: > cheers for the response , seem that attributes is missing from hash on my > system You'll find #attributes on ActiveRecord::Base, and not Hash. Try this: it "should create new client" do // creates me a hash of generated values usin

Re: [rspec-users] Specting controller post

2010-02-02 Thread J. B. Rainsberger
On Tue, Feb 2, 2010 at 04:24, Stephen Smithstone wrote: > A bit stuck here being new to ruby and rspec Welcome. I hope you like the experience. Good news: we've seen what you've done a thousand times and so it's quite easy to explain. > it "should create new client" do >     // creates me a has

Re: [rspec-users] GET a path in a controller spec

2010-02-01 Thread J. B. Rainsberger
On Sun, Jan 31, 2010 at 17:02, Nick Hoffman wrote: > One of my controller actions sends a redirect if the request URI begins > with /foods/search > >  34  def search >  35    return redirect_to "/#{params[:name]}" if > request.request_uri.match /^\/foods\/search/ > > Unfortunately, I can't figure

Re: [rspec-users] [BDD] View specs and cucumber -- duplication of effort?

2009-11-01 Thread J. B. Rainsberger
On Wed, Oct 28, 2009 at 20:46, nruth wrote: > I'm going to put the cat amongst the pigeons here in the hope of some > clarity falling out of the sky on me. > My question is this: In a world with Cucumber what is the value of > view specs? http://blog.thecodewhisperer.com/post/207813060/two-kinds

Re: [rspec-users] spec-ing private methods?

2009-10-15 Thread J. B. Rainsberger
On Wed, Oct 14, 2009 at 15:36, Joaquin Rivera Padron wrote: > hello there, > how do you tipically spec private methods? The thing is Ï have something > like this: > > def some_method >    complex_method + other_complex_methods > end > > private > def complex_method... > def other_complex_methods .

Re: [rspec-users] Expectation test: error says it's different, but it's printed the same way

2009-09-16 Thread J. B. Rainsberger
On 2009-09-16, at 08:08 , David Chelimsky wrote: On Wed, Sep 16, 2009 at 3:34 AM, Ramon Tayag wrote: I put an expectation test, but it complains two things are different when it prints it out in the error in the exact same way: http://pastie.org/618481 Printing is printing. Time is _not_ t