Re: [rspec-users] Adding stubs for an included argument

2010-01-06 Thread Edvard Majakari
Woohoo! I was aware of the block construct, but didn't know it worked with stub! as well (with should_receive, I had to use at_least... and it broke the system, making it unusable). Thanks! ___ rspec-users mailing list rspec-users@rubyforge.org http://ru

[rspec-users] Adding stubs for an included argument

2010-01-05 Thread Edvard Majakari
Hi, My scenario is as follows, and so far I have not found the clean way to implement the following. In a method I have a method called allowed_for?(*args) used as follows: ... if o.allowed_for?(:foo, :bar) #case a elsif o.allowed_for(:quux, :bif) #case b elsif o.allowed_for(:baz) #case c

Re: [rspec-users] how to write spec for infinite loop?

2008-05-29 Thread Edvard Majakari
On Thu, May 29, 2008 at 9:25 AM, zuo peng <[EMAIL PROTECTED]> wrote: > Hi, > > I've got trouble when describe infinite loop. > > code snippet: > > def start_loop >while true Not a reply to your specific question, but hopefully even better. I stumbled into similar situation a while ago, when

Re: [rspec-users] Newbie: lambda do...end.should change(Model, :count).by(1). Doesn't work

2008-05-10 Thread Edvard Majakari
Hi, >def do_verb(params = @params) > post :create, :album => params >end > >it "should change the Albums count by 1 after POST" do > lambda do >@album.should_receive(:save).and_return(true) >do_verb > end.should change(Album, :count).by(1) >end You e

Re: [rspec-users] before_validation callbacks bypassed when stubbing :valid?

2008-04-16 Thread Edvard Majakari
On Wed, Apr 16, 2008 at 2:54 PM, Ashley Moran <[EMAIL PROTECTED]> wrote: > Or equally, you could have a Factory class that knows how to create > valid objects. This can be handy for generating test data, and > separates it from the class under test. (Some metaprogramming would > let you defi

Re: [rspec-users] before_validation callbacks bypassed when stubbing :valid?

2008-04-16 Thread Edvard Majakari
On Wed, Apr 16, 2008 at 1:05 AM, Zubin Henner <[EMAIL PROTECTED]> wrote: > I'm testing an ActiveRecord model using rspec and mocha, and found that > if I stub out the :valid? method, all before_validation callbacks are > also skipped! Naturally, as it is AR's valid method which triggers those ca

Re: [rspec-users] Inspect STDERR in a story

2008-04-14 Thread Edvard Majakari
On Sat, Apr 12, 2008 at 4:17 PM, Ashley Moran <[EMAIL PROTECTED]> wrote: > Yeah! Don't know why I didn't think of just sending stderr to a log > file myself... ..because you're likely smart enough to avoid using file as a temporary variable whenever possible :) First off, using the method sim

Re: [rspec-users] Inspect STDERR in a story

2008-04-12 Thread Edvard Majakari
On Sat, Apr 12, 2008 at 11:54 AM, Ashley Moran <[EMAIL PROTECTED]> wrote: > Hi > > I have a story step that looks like this: > >When /(the user|then) runs "migrate (.*)"/ do |_, args| > cd project_dir do >@output = `#{migrate} #{args}` > end >@output_lines = @output.s

Re: [rspec-users] rspec groups?

2008-03-20 Thread Edvard Majakari
On Wed, Mar 19, 2008 at 1:12 AM, Ashley Moran <[EMAIL PROTECTED]> wrote: > > sufficient to me, but of course, YNMDFTOM. > Please put me out of my misery and explain the acronym :D My bad. My favorite hobby is to invent new acronyms on the fly, of which the one concerned is an example. It is sh

Re: [rspec-users] rspec groups?

2008-03-10 Thread Edvard Majakari
> The idea is that you can specify that certain tests exist in groups, > and can be run as a set. You can define groups and groups of groups, > and so you can run a set of functional tests or all the tests dealing > with a specific feature without running through the entire thing. > It's kind

Re: [rspec-users] Test data problem (in general and with acts_as_tree)

2008-02-26 Thread Edvard Majakari
> Yeah but then I get to say RTFM. Right now, TFM doesn't exist :( rant << EOF Indeed. People see much trouble in writing documentation so that they don't have to answer the same questions ad nauseam. It would be nice if we appreciated their efforts and check the documentation first. EOF -- "

Re: [rspec-users] Test data problem (in general and with acts_as_tree)

2008-02-26 Thread Edvard Majakari
> My problems seem to be arising from the fact that when i run the test, the > objects i created last time are still in the database. Shouldn't they be > cleared out automatically? This in turn is preventing me from saving root I don't know RSpec that well, but I'd guess before(:all) is run only

Re: [rspec-users] Autotest with TDD "test-first" problem

2008-02-25 Thread Edvard Majakari
On Sat, Feb 23, 2008 at 10:39 PM, Joe Van Dyk <[EMAIL PROTECTED]> wrote: > For example, one test runner could repeatedly run (or once a minute, > or whatever) the entire test suite. And one test runner could run the > related tests for the file you change. > > Perhaps two autotest instances,

Re: [rspec-users] can't get (r)spec to work in non-rails project

2008-02-18 Thread Edvard Majakari
> I would think just have the spec_helper.rb file for the specs try to load > config/rspec.rb or something along those lines. Similar to how rspec for > rails just loads the rails env. It would then be up to the user to do the > necessary loading in that file. There's really no way to know what cra

Re: [rspec-users] How to mock an association

2008-02-11 Thread Edvard Majakari
> Obvious 'rails mocking associations' seemed to work for me, unless I ...make that '...Googling for ...'. Duh. -- "One day, when he was naughty, Mr Bunnsy looked over the hedge into Farmer Fred's field and it was full of fresh green lettuces. Mr Bunnsy, however, was not full of lettuces. This d

Re: [rspec-users] How to mock an association

2008-02-11 Thread Edvard Majakari
On Feb 11, 2008 1:43 PM, Wes Shaddix <[EMAIL PROTECTED]> wrote: > I've got a "group" model that has a user_id attribute and a > validates_existence_of :user and validates_presence_of :user_id > validations. What method(s) do I need to stub on the User mock to > intercept those validation calls? My

Re: [rspec-users] outside-in BDD vs writing examples up front

2008-02-07 Thread Edvard Majakari
This is a short reply, but thinking about it a bit deeper, I have to agree with Dan. What especially caught my attention was this piece: > If you start with a narrow, end-to-end piece of functionality and drill into > it from the outside, right through until you have it working, you will find > th

Re: [rspec-users] Textmate RSpec Bundle 'it' snippet

2008-01-29 Thread Edvard Majakari
> Not if you fill it out...and the BDD way is to write one example at a > time, not a complete spec beforehand. I've done it this way too (being lazy), but is it really good thing? Often I get more insight on how an interface should look like, if I think even superficially what kinds of services a