Re: [rspec-users] rspec causing validates_presence_of to validate twice?

2007-10-17 Thread David Chelimsky
On 10/17/07, Steve <[EMAIL PROTECTED]> wrote:
> On Wed, 17 Oct 2007 21:31:19 -0500, David Chelimsky wrote:
> >
> > This all may be true but I can't help you diagnose the problem without
> > looking at the code. If you'd kindly pastie the spec and model, I'll
> > be glad to look at them. Otherwise I'm just guessing and that's not
> > working out to well so far.
>
> Rather than burden you with it in its uber-long glory, I started trying to
> rebuild the file piecemeal until failure. What I found is that this
> behavior was causing it to fail:
>
> it 'should only allow access to the username, first_name, last_name, and 
> email address fields' do
>   #User.should_receive(:attr_accessible).with(:username, :first_name, 
> :last_name, :email_address)
>   #load "#{RAILS_ROOT}/app/models/user.rb"
> end
>
> You may recall that from a post I made a few days ago. It seems like a
> "duh" moment now. Of course the "load" statement re-evals the class,
> and just adds to the existing version that Ruby knows about. How would you
> get around this though? Can you?

You'd have to make sure that every declaration in the file is stubbed.
Probably the best way would be to do this:

describe User, "declarations" do
  before(:each) do
User.stub!(:attr_accessible)
User.stub!(:validates_presence_of)
  end

  it "should assign attrs accessible" do
User.should_receive(:attr_accessible).with(:username, :first_name,
:last_name, :etc)
load "#{RAILS_ROOT}/app/models/user.rb"
  end

  it "should validate presence of password" do
User.should_receive(:attr_accessible).with(:username, :first_name,
:last_name, :etc)
load "#{RAILS_ROOT}/app/models/user.rb"
  end
end

Kind of hideous, but it should work.
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] rspec causing validates_presence_of to validate twice?

2007-10-17 Thread Steve
On Wed, 17 Oct 2007 21:31:19 -0500, David Chelimsky wrote:
> 
> This all may be true but I can't help you diagnose the problem without
> looking at the code. If you'd kindly pastie the spec and model, I'll
> be glad to look at them. Otherwise I'm just guessing and that's not
> working out to well so far.

Rather than burden you with it in its uber-long glory, I started trying to
rebuild the file piecemeal until failure. What I found is that this
behavior was causing it to fail:

it 'should only allow access to the username, first_name, last_name, and email 
address fields' do
  #User.should_receive(:attr_accessible).with(:username, :first_name, 
:last_name, :email_address)
  #load "#{RAILS_ROOT}/app/models/user.rb"
end

You may recall that from a post I made a few days ago. It seems like a
"duh" moment now. Of course the "load" statement re-evals the class,
and just adds to the existing version that Ruby knows about. How would you
get around this though? Can you?

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] Any tips on teaching BDD with RSpec?

2007-10-17 Thread Ed Howland
On 10/17/07, Ashley Moran <[EMAIL PROTECTED]> wrote:
> > I only wish my mentor had forced me to learn test first, back in the
> > day. But that was before all you geniuses where on the scene to set us
> > straight!
>
> I feel spoilt too, I was lucky to stumble on RSpec (and more
> importantly, rspec-users) so soon after I started learning unit
> testing.  And Jim is a lucky guy too, having someone like me around
> to tirelessly relay the replies of experts to him.
>

I agree, I have learned tons from this group, too. I missed out on
Rails Edge this year, but some of our St Louis Ruby guys got meet
David. I'd like to thank all of them for their hard work on RSpec.

Ed
-
Ed Howland
http://greenprogrammer.blogspot.com
"The information transmitted is intended only for the person or entity
to which it is addressed and may contain proprietary, confidential
and/or legally privileged material. Any review, retransmission,
dissemination or other use of, or taking of any action in reliance
upon, this information by persons or entities other than the intended
recipient is prohibited. If you received this in error, please contact
the sender and delete the material from all computers."
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] Scenarios Plugin Pre-Announcement

2007-10-17 Thread John Long
I just updated the README. It gives a better overview of the Scenarios
plugin now:

http://faithfulcode.rubyforge.org/svn/plugins/trunk/scenarios/README

--
John Long
http://wiseheartdesign.com
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] rspec causing validates_presence_of to validate twice?

2007-10-17 Thread David Chelimsky
On 10/17/07, Steve <[EMAIL PROTECTED]> wrote:
> Also I really don't think I'm leaking state. I have before(:each) statements 
> in my "describes" that
> basically create new instances of the object as required for that
> behavior. So they are fresh each time, correct? Further, even though rails
> clears the errors collection when valid? is called, I called
> @user.errors.clear before attempting the validations that are failing with
> the double message just to be sure, and it's still happening. Again, these
> problems don't happen in script/console at all, but it is validating
> correctly.

This all may be true but I can't help you diagnose the problem without
looking at the code. If you'd kindly pastie the spec and model, I'll
be glad to look at them. Otherwise I'm just guessing and that's not
working out to well so far.
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] rspec causing validates_presence_of to validate twice?

2007-10-17 Thread Steve
On Wed, 17 Oct 2007 19:30:57 -0500, David Chelimsky wrote:

>> Removing --reverse makes "rake spec" fail like the other two methods
>> now.
> 
> That's what I suspected would happen.
> 
> The reason they were failing differently was that rake was running them
> in the opposite order. Removing --reverse made it so they run in the
> same order.
> 
> So now, the problem is that your specs are leaking state. I'd need to
> see the entire file to help you figure out why. If you feel like posting
> it, please pastie it and write back.

I take that back, "rake spec" causes similar failure, in that those double
validation messages appear, but it also adds two failures that weren't
there before.

1)
'User should have a case-insensitive unique username' FAILED expected
valid? to return false, got true ./spec/helpers/../spec_helper.rb:49:in
`check_unique' ./spec/models/user_spec.rb:101:in `check_user_unique'
./spec/models/user_spec.rb:28:

2)
'User should have a case-insensitive unique email address' FAILED expected
valid? to return false, got true ./spec/helpers/../spec_helper.rb:49:in
`check_unique' ./spec/models/user_spec.rb:101:in `check_user_unique'
./spec/models/user_spec.rb:40:

If I run "script/spec spec" those don't appear, and I just have the double
validation message errors.

Also I really don't think I'm leaking state. I have before(:each) statements in 
my "describes" that
basically create new instances of the object as required for that
behavior. So they are fresh each time, correct? Further, even though rails
clears the errors collection when valid? is called, I called
@user.errors.clear before attempting the validations that are failing with
the double message just to be sure, and it's still happening. Again, these
problems don't happen in script/console at all, but it is validating
correctly.

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


[rspec-users] Scenarios Plugin Pre-Announcement

2007-10-17 Thread John Long
On 10/17/07, Scott Taylor <[EMAIL PROTECTED]> wrote:
> I haven't had the chance to really play with your plugin.  How is it
> different than fixture scenarios (from err.the.blog)?

I haven't actually used err.the.blog's plugin, though ours certainly
draws heavily upon it for inspiration.

>From what I can tell both plugins provide the following:

1. Code based data population
2. Grouping of data population methods through "scenarios"
3. Dependencies between scenarios so that you can declare that one
scenario requires another to be loaded first

One key difference between the two plugins is that err.the.blog's
approach depends on your models being in place and creates new records
using your models. This means that your scenario data must run through
validations before it can be inserted into the database. This can be
slow. Our approach encourages you to inject data straight into the
database in much the same way that fixtures do it. We believe this is
a better approach.

One thing that our approach adds over err.the.blog's is the idea of
Scenario helpers. To use scenario helpers you declare them inside a
Scenario:

class PeopleScenario < Scenario::Base
  def load
create_person :name => "John"
  end

  helpers do
def create_person(attributes={})
  create_record :person, attributes[:name].downcase.intern, attributes
end
def login_as(person)
  # insert person into session
end
  end
end

Helper methods declared inside the helpers block are mixed into the
scenario (so you can access them in the load method) and into the
Rspec behavior:

describe "Projects screen" do
  scenario :people

  it "should show active projects" do
login_as(people(:john))
# verify that the correct projects are showing
  end
end

For more examples I'd highly encourage you to look through the specs:

http://faithfulcode.rubyforge.org/svn/plugins/trunk/scenarios/spec/scenarios_spec.rb


--
John Long
http://wiseheartdesign.com
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] rspec causing validates_presence_of to validate twice?

2007-10-17 Thread David Chelimsky
On 10/17/07, Steve <[EMAIL PROTECTED]> wrote:
> On Wed, 17 Oct 2007 18:01:11 -0500, David Chelimsky wrote:
>
> > One more thing to try. Open up spec/spec.opts and remove the line that
> > says "--reverse" if it's there. Then run "rake spec" again and see
> > what happens.
> >
> > Thanks,
> > David
>
> Removing --reverse makes "rake spec" fail like the other two methods now.

That's what I suspected would happen.

The reason they were failing differently was that rake was running
them in the opposite order. Removing --reverse made it so they run in
the same order.

So now, the problem is that your specs are leaking state. I'd need to
see the entire file to help you figure out why. If you feel like
posting it, please pastie it and write back.
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] rspec causing validates_presence_of to validate twice?

2007-10-17 Thread Steve
On Wed, 17 Oct 2007 18:01:11 -0500, David Chelimsky wrote:

> One more thing to try. Open up spec/spec.opts and remove the line that
> says "--reverse" if it's there. Then run "rake spec" again and see
> what happens.
> 
> Thanks,
> David

Removing --reverse makes "rake spec" fail like the other two methods now.
Which one is the *correct* failure?

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] rspec causing validates_presence_of to validate twice?

2007-10-17 Thread David Chelimsky
On 10/17/07, Steve <[EMAIL PROTECTED]> wrote:
> On Wed, 17 Oct 2007 16:40:11 -0500, David Chelimsky wrote:
> >
> > Would you please try running it like this:
> >
> > script/spec spec -b
> >
> > and this
> >
> > script/spec spec/models/user_spec.rb -b
> >
> > and let us know if it's still happening?
>
> script/spec spec -b changes things. It doesn't give that duplication of
> validations for password presence, but does it on two other tests(which
> pass using rake spec:models):
>
> 1)
> 'User with a new password should check that the password is 6-15 characters 
> long' FAILED
> expected: "is too short (minimum is 6 characters)",
>  got: ["is too short (minimum is 6 characters)", "is too short (minimum 
> is 6 characters)"] (using ==)
> /trunk/vendor/plugins/rspec/lib/spec/expectations.rb:52:in `fail_with'
> /trunk/vendor/plugins/rspec/lib/spec/matchers/operator_matcher.rb:46:in 
> `fail_with_message'
> /trunk/vendor/plugins/rspec/lib/spec/matchers/operator_matcher.rb:56:in 
> `__delegate_method_missing_to_target'
> /trunk/vendor/plugins/rspec/lib/spec/matchers/operator_matcher.rb:12:in `=='
> /trunk/spec/models/user_spec.rb:138:
> /trunk/vendor/plugins/rspec/lib/spec/dsl/example_module.rb:171:in 
> `instance_eval'
> /trunk/vendor/plugins/rspec/lib/spec/dsl/example_module.rb:171:in 
> `run_example'
> /trunk/vendor/plugins/rspec/lib/spec/dsl/example_runner.rb:65:in `run_example'
> /trunk/vendor/plugins/rspec/lib/spec/dsl/example_runner.rb:26:in `run'
> /usr/lib/ruby/1.8/timeout.rb:48:in `timeout'
> /trunk/vendor/plugins/rspec/lib/spec/dsl/example_runner.rb:24:in `run'
> /trunk/vendor/plugins/rspec/lib/spec/dsl/example_suite.rb:26:in `rspec_run'
> /trunk/vendor/plugins/rspec/lib/spec/dsl/example_suite.rb:22:in `each'
> /trunk/vendor/plugins/rspec/lib/spec/dsl/example_suite.rb:22:in `rspec_run'
> /trunk/vendor/plugins/rspec/lib/spec/test/unit/example_suite.rb:7:in `run'
> /trunk/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:12:in `run'
> /trunk/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:11:in `each'
> /trunk/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:11:in `run'
> /trunk/vendor/plugins/rspec/lib/spec/runner/options.rb:71:in `run_examples'
> /trunk/vendor/plugins/rspec/lib/spec/runner/command_line.rb:22:in `run'
> script/spec:4:
>
> 2)
> 'User with a new password should check for confirmation of the new password' 
> FAILED
> expected: "doesn't match confirmation",
>  got: ["doesn't match confirmation", "doesn't match confirmation"] (using 
> ==)
> /trunk/vendor/plugins/rspec/lib/spec/expectations.rb:52:in `fail_with'
> /trunk/vendor/plugins/rspec/lib/spec/matchers/operator_matcher.rb:46:in 
> `fail_with_message'
> /trunk/vendor/plugins/rspec/lib/spec/matchers/operator_matcher.rb:56:in 
> `__delegate_method_missing_to_target'
> /trunk/vendor/plugins/rspec/lib/spec/matchers/operator_matcher.rb:12:in `=='
> /trunk/spec/models/user_spec.rb:154:
> /trunk/vendor/plugins/rspec/lib/spec/dsl/example_module.rb:171:in 
> `instance_eval'
> /trunk/vendor/plugins/rspec/lib/spec/dsl/example_module.rb:171:in 
> `run_example'
> /trunk/vendor/plugins/rspec/lib/spec/dsl/example_runner.rb:65:in `run_example'
> /trunk/vendor/plugins/rspec/lib/spec/dsl/example_runner.rb:26:in `run'
> /usr/lib/ruby/1.8/timeout.rb:48:in `timeout'
> /trunk/vendor/plugins/rspec/lib/spec/dsl/example_runner.rb:24:in `run'
> /trunk/vendor/plugins/rspec/lib/spec/dsl/example_suite.rb:26:in `rspec_run'
> /trunk/vendor/plugins/rspec/lib/spec/dsl/example_suite.rb:22:in `each'
> /trunk/vendor/plugins/rspec/lib/spec/dsl/example_suite.rb:22:in `rspec_run'
> /trunk/vendor/plugins/rspec/lib/spec/test/unit/example_suite.rb:7:in `run'
> /trunk/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:12:in `run'
> /trunk/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:11:in `each'
> /trunk/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:11:in `run'
> /trunk/vendor/plugins/rspec/lib/spec/runner/options.rb:71:in `run_examples'
> /trunk/vendor/plugins/rspec/lib/spec/runner/command_line.rb:22:in `run'
> script/spec:4:
>
> script/spec spec/models/user_spec.rb -b yields the same as above.

One more thing to try. Open up spec/spec.opts and remove the line that
says "--reverse" if it's there. Then run "rake spec" again and see
what happens.

Thanks,
David
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] rspec causing validates_presence_of to validate twice?

2007-10-17 Thread Steve
On Wed, 17 Oct 2007 16:40:11 -0500, David Chelimsky wrote:
> 
> Would you please try running it like this:
> 
> script/spec spec -b
> 
> and this
> 
> script/spec spec/models/user_spec.rb -b
> 
> and let us know if it's still happening?

script/spec spec -b changes things. It doesn't give that duplication of
validations for password presence, but does it on two other tests(which
pass using rake spec:models):

1)
'User with a new password should check that the password is 6-15 characters 
long' FAILED
expected: "is too short (minimum is 6 characters)",
 got: ["is too short (minimum is 6 characters)", "is too short (minimum is 
6 characters)"] (using ==)
/trunk/vendor/plugins/rspec/lib/spec/expectations.rb:52:in `fail_with'
/trunk/vendor/plugins/rspec/lib/spec/matchers/operator_matcher.rb:46:in 
`fail_with_message'
/trunk/vendor/plugins/rspec/lib/spec/matchers/operator_matcher.rb:56:in 
`__delegate_method_missing_to_target'
/trunk/vendor/plugins/rspec/lib/spec/matchers/operator_matcher.rb:12:in `=='
/trunk/spec/models/user_spec.rb:138:
/trunk/vendor/plugins/rspec/lib/spec/dsl/example_module.rb:171:in 
`instance_eval'
/trunk/vendor/plugins/rspec/lib/spec/dsl/example_module.rb:171:in `run_example'
/trunk/vendor/plugins/rspec/lib/spec/dsl/example_runner.rb:65:in `run_example'
/trunk/vendor/plugins/rspec/lib/spec/dsl/example_runner.rb:26:in `run'
/usr/lib/ruby/1.8/timeout.rb:48:in `timeout'
/trunk/vendor/plugins/rspec/lib/spec/dsl/example_runner.rb:24:in `run'
/trunk/vendor/plugins/rspec/lib/spec/dsl/example_suite.rb:26:in `rspec_run'
/trunk/vendor/plugins/rspec/lib/spec/dsl/example_suite.rb:22:in `each'
/trunk/vendor/plugins/rspec/lib/spec/dsl/example_suite.rb:22:in `rspec_run'
/trunk/vendor/plugins/rspec/lib/spec/test/unit/example_suite.rb:7:in `run'
/trunk/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:12:in `run'
/trunk/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:11:in `each'
/trunk/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:11:in `run'
/trunk/vendor/plugins/rspec/lib/spec/runner/options.rb:71:in `run_examples'
/trunk/vendor/plugins/rspec/lib/spec/runner/command_line.rb:22:in `run'
script/spec:4:

2)
'User with a new password should check for confirmation of the new password' 
FAILED
expected: "doesn't match confirmation",
 got: ["doesn't match confirmation", "doesn't match confirmation"] (using 
==)
/trunk/vendor/plugins/rspec/lib/spec/expectations.rb:52:in `fail_with'
/trunk/vendor/plugins/rspec/lib/spec/matchers/operator_matcher.rb:46:in 
`fail_with_message'
/trunk/vendor/plugins/rspec/lib/spec/matchers/operator_matcher.rb:56:in 
`__delegate_method_missing_to_target'
/trunk/vendor/plugins/rspec/lib/spec/matchers/operator_matcher.rb:12:in `=='
/trunk/spec/models/user_spec.rb:154:
/trunk/vendor/plugins/rspec/lib/spec/dsl/example_module.rb:171:in 
`instance_eval'
/trunk/vendor/plugins/rspec/lib/spec/dsl/example_module.rb:171:in `run_example'
/trunk/vendor/plugins/rspec/lib/spec/dsl/example_runner.rb:65:in `run_example'
/trunk/vendor/plugins/rspec/lib/spec/dsl/example_runner.rb:26:in `run'
/usr/lib/ruby/1.8/timeout.rb:48:in `timeout'
/trunk/vendor/plugins/rspec/lib/spec/dsl/example_runner.rb:24:in `run'
/trunk/vendor/plugins/rspec/lib/spec/dsl/example_suite.rb:26:in `rspec_run'
/trunk/vendor/plugins/rspec/lib/spec/dsl/example_suite.rb:22:in `each'
/trunk/vendor/plugins/rspec/lib/spec/dsl/example_suite.rb:22:in `rspec_run'
/trunk/vendor/plugins/rspec/lib/spec/test/unit/example_suite.rb:7:in `run'
/trunk/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:12:in `run'
/trunk/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:11:in `each'
/trunk/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:11:in `run'
/trunk/vendor/plugins/rspec/lib/spec/runner/options.rb:71:in `run_examples'
/trunk/vendor/plugins/rspec/lib/spec/runner/command_line.rb:22:in `run'
script/spec:4:

script/spec spec/models/user_spec.rb -b yields the same as above.

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] rspec causing validates_presence_of to validate twice?

2007-10-17 Thread David Chelimsky
On 10/17/07, Steve <[EMAIL PROTECTED]> wrote:
> I'm running through rake(rake spec:models to be exact). The error is:
>
> 'User should be invalid without a password when creating' FAILED
> expected: "can't be blank",
>  got: ["can't be blank", "can't be blank"] (using ==)
> ./spec/models/user_spec.rb:64:
>
> So there isn't an actual ruby error, it's just the errors collection not
> matching.

Would you please try running it like this:

script/spec spec -b

and this

script/spec spec/models/user_spec.rb -b

and let us know if it's still happening?
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] rspec causing validates_presence_of to validate twice?

2007-10-17 Thread Steve
On Wed, 17 Oct 2007 16:17:53 -0500, David Chelimsky wrote:
> Thanks for trying. Sorry it's still a problem.
> 
> How are you running the specs (rake? spec command? textmate?) and what
> precisely is the error that you get? Please include a stack trace (not
> just one line)
> 
> Thanks,
> David

I'm running through rake(rake spec:models to be exact). The error is:

'User should be invalid without a password when creating' FAILED
expected: "can't be blank",
 got: ["can't be blank", "can't be blank"] (using ==)
./spec/models/user_spec.rb:64:

So there isn't an actual ruby error, it's just the errors collection not
matching.

This is the output from rake with the --trace option

/trunk/vendor/plugins/rspec/lib/spec/rake/spectask.rb:173:in `define'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:823:in `verbose'
/trunk/vendor/plugins/rspec/lib/spec/rake/spectask.rb:142:in `define'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke'
/usr/lib/ruby/1.8/thread.rb:135:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in 
`standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in 
`standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7
/usr/bin/rake:16:in `load'
/usr/bin/rake:16

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] rspec causing validates_presence_of to validate twice?

2007-10-17 Thread David Chelimsky
On 10/17/07, Steve <[EMAIL PROTECTED]> wrote:
> On Wed, 17 Oct 2007 15:41:19 -0500, David Chelimsky wrote:
>
> > Please update to the latest rspec trunk and try again. I think this is
> > due to a bug that was resolved in the 2718 (believe it or not).
>
> Just updated and am at 2719. The problem still happens.

Thanks for trying. Sorry it's still a problem.

How are you running the specs (rake? spec command? textmate?) and what
precisely is the error that you get? Please include a stack trace (not
just one line)

Thanks,
David
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] rspec causing validates_presence_of to validate twice?

2007-10-17 Thread Steve
On Wed, 17 Oct 2007 21:12:27 +, Steve wrote:

> On Wed, 17 Oct 2007 15:41:19 -0500, David Chelimsky wrote:
> 
>> Please update to the latest rspec trunk and try again. I think this is
>> due to a bug that was resolved in the 2718 (believe it or not).
> 
> Just updated and am at 2719. The problem still happens.

May or may not be relevant, but I have other validates_presence_of calls,
and they all work exactly as expected.

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] rspec causing validates_presence_of to validate twice?

2007-10-17 Thread Steve
On Wed, 17 Oct 2007 15:41:19 -0500, David Chelimsky wrote:

> Please update to the latest rspec trunk and try again. I think this is
> due to a bug that was resolved in the 2718 (believe it or not).

Just updated and am at 2719. The problem still happens.

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] rspec causing validates_presence_of to validate twice?

2007-10-17 Thread David Chelimsky
On 10/17/07, Steve <[EMAIL PROTECTED]> wrote:
> On Wed, 17 Oct 2007 15:05:01 -0500, David Chelimsky wrote:
>
> > Versions? RSpec? Rails?
> >
>
> Details details. :)
>
> rspec/rspec_on_rails(trunk): r2717
> rails(trunk): r7822

Please update to the latest rspec trunk and try again. I think this is
due to a bug that was resolved in the 2718 (believe it or not).
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] rspec causing validates_presence_of to validate twice?

2007-10-17 Thread Steve
On Wed, 17 Oct 2007 15:05:01 -0500, David Chelimsky wrote:

> Versions? RSpec? Rails?
> 

Details details. :)

rspec/rspec_on_rails(trunk): r2717
rails(trunk): r7822

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] Any tips on teaching BDD with RSpec?

2007-10-17 Thread Ashley Moran

On Oct 17, 2007, at 6:52 pm, Ed Howland wrote:

> If it were up to me, I would start with BDD, Probably, immediately
> right after hello_world.rb. Even before they learn any Ruby syntax at
> all. Your toy app sounds more like a real application to me. It has
> actual user stories, confirmable results, etc.
>
> Why not break the usual cycle of code a little, test, code a bit more,
> test, repeat, from the start? RSpec is a DSL, like Rails is a DSL. And
> you don't need to know much ruby to get started in Rails. I say that
> holds true in RSpec as well. The only qualms I can see is the concept
> of Mocks. But you could introduce that in something he is familiar
> with like Java.

That's an interesting approach.  My only hesitation is that if he's  
seen to be writing Rails apps it might be interpreted by management  
that he's learnt everything there is to know about behaviour-driven  
object-oriented MVC web programming, and I wouldn't get chance to  
show him the good stuff before I leave.

I think it's good to see something working, but I wanted to avoid  
instilling Rails = Ruby in him.  That's why I started writing specs  
for trivial things, then simple things like loading a YAML file.

Interestingly, mocks were a tough one.  It took a while to explain  
the difference between full and partial mocks, and the difference  
between mocking instances and stubbing on classes.  I don't think it  
was the concept of imaginary objects, more the idea of setting  
expectations on them and describing interactions, as opposed to  
seeing whether the final output of the program is right.


> I only wish my mentor had forced me to learn test first, back in the
> day. But that was before all you geniuses where on the scene to set us
> straight!

I feel spoilt too, I was lucky to stumble on RSpec (and more  
importantly, rspec-users) so soon after I started learning unit  
testing.  And Jim is a lucky guy too, having someone like me around  
to tirelessly relay the replies of experts to him.

Ashley


--
blog @ http://aviewfromafar.net/
linked-in @ http://www.linkedin.com/in/ashleymoran
currently @ home

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] Any tips on teaching BDD with RSpec?

2007-10-17 Thread Ashley Moran

On Oct 17, 2007, at 8:54 pm, David Chelimsky wrote:

> Behaviour Driven Development in Ruby with RSpec
> by David Chelimsky and Aslak Hellesoy
>
> Sadly, not yet in print, but coming soon from the Pragmatic Bookshelf.

I forgot about that one :)  Can't we pre-order the beta yet?


> In the mean time, you might want to give this one a peek:
>
> http://www.amazon.com/Software-Development-Principles-Patterns- 
> Practices/dp/0135974445

You recommended that one once before, this is my cue to actually buy  
a copy



--
blog @ http://aviewfromafar.net/
linked-in @ http://www.linkedin.com/in/ashleymoran
currently @ home

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] Any tips on teaching BDD with RSpec?

2007-10-17 Thread David Chelimsky
On 10/17/07, Shane Mingins <[EMAIL PROTECTED]> wrote:
> On 18/10/2007, at 8:54 AM, David Chelimsky wrote:
>
> > Behaviour Driven Development in Ruby with RSpec
> > by David Chelimsky and Aslak Hellesoy
> >
> > Sadly, not yet in print, but coming soon from the Pragmatic Bookshelf.
> >
>
> Will it be released in PDF beta any sooner?

Definitely. We just don't know when yet. Believe me, as soon as we
have that nailed down this list will be among the first to know :)

Cheers,
David
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] rspec causing validates_presence_of to validate twice?

2007-10-17 Thread David Chelimsky
Versions? RSpec? Rails?

On 10/17/07, Steve <[EMAIL PROTECTED]> wrote:
> I had posted this on the regular Rails list, but upon trying this in
> script/console, it seems like the behavior only exists when running rspec.
>
> I'm getting some weird behavior in one of my models. I have a model
> defined something like this
>
> class User < ActiveRecord::Base
>   attr_accessor :password
>
>   validates_presence_of :password
> end
>
> If I validate the model without specifying a password, I get  ["can't be
> blank", "can't be blank"] for :password instead of just one "cant't be
> blank". If I comment out the validates_presence_of statement, then no
> errors. So it doesn't seem like it's being defined elsewhere(through a
> plugin or some such). Any idea what might be going on here?
>
> Like mentioned above, if I do this in script/console I only get "can't be
> blank" once, as expected.
>
> I should note that I'm not blaming rspec, moreso, where should I be
> starting to look? My spec looks like this(snipped the other passing tests):
>
> describe User do
>   include UserExampleHelperMethods
>
>   before(:each) do
> @user = User.new
> @user.password = '123456'
> @user.password_confirmation = '123456'
>   end
>
>   it 'should be invalid without a password when creating' do
> @user.attributes = valid_user_attributes
> @user.password = nil
> @user.password_confirmation = nil
> @user.should_not be_valid
> @user.errors.on(:password).should == "can't be blank"
>   end
> end
>
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] Any tips on teaching BDD with RSpec?

2007-10-17 Thread Shane Mingins
On 18/10/2007, at 8:54 AM, David Chelimsky wrote:

> Behaviour Driven Development in Ruby with RSpec
> by David Chelimsky and Aslak Hellesoy
>
> Sadly, not yet in print, but coming soon from the Pragmatic Bookshelf.
>

Will it be released in PDF beta any sooner?

Cheers
Shane



___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


[rspec-users] rspec causing validates_presence_of to validate twice?

2007-10-17 Thread Steve
I had posted this on the regular Rails list, but upon trying this in
script/console, it seems like the behavior only exists when running rspec.

I'm getting some weird behavior in one of my models. I have a model
defined something like this

class User < ActiveRecord::Base
  attr_accessor :password

  validates_presence_of :password
end

If I validate the model without specifying a password, I get  ["can't be
blank", "can't be blank"] for :password instead of just one "cant't be
blank". If I comment out the validates_presence_of statement, then no
errors. So it doesn't seem like it's being defined elsewhere(through a
plugin or some such). Any idea what might be going on here?

Like mentioned above, if I do this in script/console I only get "can't be
blank" once, as expected.

I should note that I'm not blaming rspec, moreso, where should I be
starting to look? My spec looks like this(snipped the other passing tests):

describe User do
  include UserExampleHelperMethods
  
  before(:each) do
@user = User.new
@user.password = '123456'
@user.password_confirmation = '123456'
  end
  
  it 'should be invalid without a password when creating' do
@user.attributes = valid_user_attributes
@user.password = nil
@user.password_confirmation = nil
@user.should_not be_valid
@user.errors.on(:password).should == "can't be blank"
  end
end

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] Any tips on teaching BDD with RSpec?

2007-10-17 Thread David Chelimsky
On 10/17/07, Ashley Moran <[EMAIL PROTECTED]> wrote:
> I was actually going to ask this as a separate post some time.  I'm
> pretty good (I like to think) with unit specs and breaking behaviour
> down, but have not looked much at higher-level user-story based
> testing.  (And broader agile concepts generally)  What's the best
> book on the subject for someone in my situation?

Behaviour Driven Development in Ruby with RSpec
by David Chelimsky and Aslak Hellesoy

Sadly, not yet in print, but coming soon from the Pragmatic Bookshelf.

In the mean time, you might want to give this one a peek:

http://www.amazon.com/Software-Development-Principles-Patterns-Practices/dp/0135974445
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] Any tips on teaching BDD with RSpec?

2007-10-17 Thread Ashley Moran

On Oct 17, 2007, at 6:14 pm, Pat Maddox wrote:

> First of all, fun situation to be in!  I like installing BDD into
> impressionable minds  - I create one more person who thinks I'm
> brilliant.

Lol - true, this is one of the better problems I've had to deal with.


>
> I would say the best way to do this is to pair.  Start off with a toy
> app, introducing him to the syntax and basics of RSpec.  I would
> definitely start off with user stories, and then get into the
> nuts-and-bolts object spec'ing.  Perhaps you could write one full
> scenario in story runner (as I'm sure that's completely foreign to
> him),

It's also foreign to me!  [hangs head in shame]  I've been too busy  
to keep up with the latest RSpec gadgets.  I just googled and was  
about to ask if you had seen this link:  but on closer  
inspection I suspect the answer may be yes :)

I was actually going to ask this as a separate post some time.  I'm  
pretty good (I like to think) with unit specs and breaking behaviour  
down, but have not looked much at higher-level user-story based  
testing.  (And broader agile concepts generally)  What's the best  
book on the subject for someone in my situation?

I have not tried RSpec trunk - I'll fetch it out tonight and see if I  
can get some stories up and running, and teach him everything I know  
tomorrow :)  I'm not averse to learning stuff as I teach it - I  
taught him FlexMock before I'd used it myself.  Gernally though, it's  
nice to have an idea what you're talking about.



> and then you two can bounce back and forth while implementing
> it.  You start off doing 60% of the coding letting him take 40%.
> Gradually let him take over more as he gets the hang of it, then you
> can lean back and sip pina coladas, swacking him with a ruler whenever
> he missteps.

This may be the key step I'm missing.  (Gradually letting him take  
over, not whacking him with a ruler.)  I think I might be expecting  
too much too soon.  Unfortunately I still keep getting bombarded with  
spontaneous "by the way we need this server farm re-installing  
tomorrow"-type requests so I needed something I could leave him to it.


> After you've done a little toy app, I would go to a part of your real
> app.  If you've got any areas that have weak/no coverage, write some
> specs for it together.  You can help show him how to retrofit specs
> onto existing code, and you strengthen your coverage to boot!

Good idea, I have a couple of pretty cleanly-separated web service  
interfaces written by his predecessor.  This other guy destroyed  
everything he touched, so there are plenty of things I can justify re- 
writing.


> I think you'll BOTH learn more and be far more efficient if you pair
> together rather than giving him a bit of theory/tips & tricks and then
> leaving him to his own devices.

I suspect you are entirely right.  Unfortunately, our corporate  
culture has historically been "why are you spending so much time  
learning when you could be coding", and it can get politically  
difficult to be seen to be doing nothing at times.

My last question then is... since he has not done Rails before, would  
it be better to jump straight onto the main project he will be  
working on, or a dummy project first?

Actually we have something he could possibly help out with - I found  
out the other day that the setup system for one of our web services  
involves posting potential customers paper forms and waiting for them  
to fax the completed ones over*.  So perhaps I can twist my boss's  
arm that we should do a more Web 0.9 solution to this as a combined  
learn/code effort.

That would make the final sprint like this:

* take over some more of the coding on the demo app he is rewriting,  
but let him grab the keyboard as soon as he sees what needs doing (I  
wanted it to be all his work, but I'm sure if it's mostly his work  
that may be as good)
* build a really basic monkey-see, monkey-do Rails app so he's got an  
idea of MVC (like I say, it's ALL new)
* spec some behaviour for the online setup app (that I think I will  
christen Postfax, in tribute) possibly in the Story Runner that I  
learnt an hour from now
* implement some really basic behaviour myself, get him to add some  
more basic behaviour
* try some more advanced stuff and hopefully let him take over slowly
* get the pina colada and ruler ready

Sounds like a plan?

Cheers!
Ashley


*No, I am not making this up.  I couldn't believe it either.


--
blog @ http://aviewfromafar.net/
linked-in @ http://www.linkedin.com/in/ashleymoran
currently @ home


___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] Strange mock_model behaviour with ActiveResource model

2007-10-17 Thread James Hughes
On 10/12/07, Bryan Ray <[EMAIL PROTECTED]> wrote:
> Can you post your entire:
>
> it "should assign the found fa_codes for the view" block? as well as
> your fa_code controller? perhaps pastie it and link.
>
> That appears to be the spec failing.

Hi Brian,

It's actually all of the it blocks inside the "describe
FaCodesController, "handling GET /fa_codes" do" block -- and, if they
weren't commented out right now, all of these describe blocks all fail
in the same way:

describe FaCodesController, "handling GET /fa_codes.xml" do
describe FaCodesController, "handling GET /fa_codes/1" do
describe FaCodesController, "handling GET /fa_codes/1.xml" do

Here's the model, controller_spec and controller:

http://pastie.caboo.se/108209

FYI, I tried changing the base class of the model to
ActiveRecord::Base and got the same error.

jh

>
> James Hughes wrote:
> > Hi,
> >
> > I have two models in an app that inherit from ActiveResource::Base.
> > The scaffold controller tests for one of the models works fine, but
> > the other one dies when calling mock_model in the "handling GET
> > /fa_codes" spec:
> >
> > Specifically, the call to mock model here:
> >
> >  before do
> > @fa_code = mock_model(FaCode)
> > FaCode.stub!(:find).and_return([EMAIL PROTECTED])
> >   end
> >
> > generates this failure:
> >
> > NameError in 'FaCodesController handling GET /fa_codes should assign
> > the found fa_codes for the view'
> > uninitialized constant Spec::Rails::Initializer
> > (eval):11:in `class'
> > /home/jhughes/dev/rj/gump_rewrite/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/rails_example.rb:85:in
> > `add_stubs'
> > /home/jhughes/dev/rj/gump_rewrite/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/rails_example.rb:73:in
> > `mock_model'
> > ./spec/controllers/fa_codes_controller_spec.rb:64:
> >
> > This is with edge rails, trunk rspec and rspec_on_rails. I might have
> > pegged this as some Ares wierdness, but there are two models with the
> > same setup, and only one dies like this.
> >
> > Any ideas?
> >
> > James
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] RailsStory - lessons learned

2007-10-17 Thread s.ross
> The welcome controller fails when the HTTP_USER_AGENT is missing.

Alvin--

Try:

request.stub!(:user_agent).and_return('Mozilla')

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] Any tips on teaching BDD with RSpec?

2007-10-17 Thread Ed Howland
On 10/17/07, David Chelimsky <[EMAIL PROTECTED]> wrote:
> On 10/17/07, Pat Maddox <[EMAIL PROTECTED]> wrote:
> > I think you'll BOTH learn more and be far more efficient if you pair
> > together rather than giving him a bit of theory/tips & tricks and then
> > leaving him to his own devices.
>
> Hear, hear!!!
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


I have to agree w/Pat here, wrt to pair programming. (And let me say
that I am _so_ jealous!)

If it were up to me, I would start with BDD, Probably, immediately
right after hello_world.rb. Even before they learn any Ruby syntax at
all. Your toy app sounds more like a real application to me. It has
actual user stories, confirmable results, etc.

Why not break the usual cycle of code a little, test, code a bit more,
test, repeat, from the start? RSpec is a DSL, like Rails is a DSL. And
you don't need to know much ruby to get started in Rails. I say that
holds true in RSpec as well. The only qualms I can see is the concept
of Mocks. But you could introduce that in something he is familiar
with like Java.

I only wish my mentor had forced me to learn test first, back in the
day. But that was before all you geniuses where on the scene to set us
straight!

Ed



-- 
Ed Howland
http://greenprogrammer.blogspot.com
"The information transmitted is intended only for the person or entity
to which it is addressed and may contain proprietary, confidential
and/or legally privileged material. Any review, retransmission,
dissemination or other use of, or taking of any action in reliance
upon, this information by persons or entities other than the intended
recipient is prohibited. If you received this in error, please contact
the sender and delete the material from all computers."
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] Any tips on teaching BDD with RSpec?

2007-10-17 Thread David Chelimsky
On 10/17/07, Pat Maddox <[EMAIL PROTECTED]> wrote:
> I think you'll BOTH learn more and be far more efficient if you pair
> together rather than giving him a bit of theory/tips & tricks and then
> leaving him to his own devices.

Hear, hear!!!
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] Any tips on teaching BDD with RSpec?

2007-10-17 Thread Pat Maddox
On 10/17/07, Ashley Moran <[EMAIL PROTECTED]> wrote:
> 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 uni)
>* then let him write a small program (to a rough description I
> came up with) in Ruby however he wants
>* then teach him how to do BDD-driven OO
>* then let him re-write the sample app in a BDD way.
>
> The app loads a YAML file that lists some URLs, fetches the pages off
> the interweb, extracts some data from the body of the spec, and
> outputs it to XML.  He's picking stuff up quick - he wrote it in
> about 1 1/2 days despite only learning Ruby last week.
>
> I've gone through a really simple BDD example with him that is quite
> similar to part of the bigger app - he seems to follow the syntax of
> RSpec and flexmock, understands the concepts of full and partial
> mocks, etc.  But I've left him to rewrite his app along the same
> lines, and it's like there is a void.  Where before he just kept
> working at little bits until the output built up, now he's got the
> ability to isolate simple bits of code and develop/test them (eg
> formatting a  tag from a URL), he's taking longer.  He seems to
> be struggling to pick isolated pieces of functionality out of the
> bigger problem.
>
> One thing I have done for him is write a functional test - one that
> runs the whole app "WebParse.run(infile, outfile)" black-box style,
> and compares the output in "outfile" to the output of his existing
> app (which we've decided between us is correct and suitable as a
> reference).  I'm not sure if this has helped or confused the issue.
>
> Clearly there is something important I am not explaining, something I
> take for granted.  Does anyone have any ideas what? I was hoping
> someone else here has been through the experience of teaching BDD
> (RSpec or otherwise) from scratch and may be able to point me in the
> right direction.
>
> Thanks for any advice
> Ashley
>
>
> PS I haven't told him to subscribe to this list yet, so I'm safe to
> talk about him for a bit :o)
>
>
> --
>
> blog @ http://aviewfromafar.net/
> linked-in @ http://www.linkedin.com/in/ashleymoran
> currently @ work
>
>
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>

Hey Ashley,

First of all, fun situation to be in!  I like installing BDD into
impressionable minds  - I create one more person who thinks I'm
brilliant.

I would say the best way to do this is to pair.  Start off with a toy
app, introducing him to the syntax and basics of RSpec.  I would
definitely start off with user stories, and then get into the
nuts-and-bolts object spec'ing.  Perhaps you could write one full
scenario in story runner (as I'm sure that's completely foreign to
him), and then you two can bounce back and forth while implementing
it.  You start off doing 60% of the coding letting him take 40%.
Gradually let him take over more as he gets the hang of it, then you
can lean back and sip pina coladas, swacking him with a ruler whenever
he missteps.

After you've done a little toy app, I would go to a part of your real
app.  If you've got any areas that have weak/no coverage, write some
specs for it together.  You can help show him how to retrofit specs
onto existing code, and you strengthen your coverage to boot!

I think you'll BOTH learn more and be far more efficient if you pair
together rather than giving him a bit of theory/tips & tricks and then
leaving him to his own devices.

Pat
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] plain text stories: motivation number 27

2007-10-17 Thread James Cox

On 17 Oct 2007, at 15:41, David Chelimsky wrote:

> This is mostly theoretical, but ...
>
> I'm starting to use lighthouse (http://llighthouseapp.com) for my
> projects at work. I'm organizing iterations as milestones and stories
> as tickets tagged to a milestone.
>
> Lighthouse offers an API so that you can write access the data in your
> account and write apps to process that data.
>
> I think you see where this is going.
>
> It seems to me that a plain text story could be stored in a lighthouse
> ticket, read in via the lighthouse API ... AND EXECUTED BY STORY
> RUNNER.
>
> Call me crazy :)
>
> Sure, this is theoretical in terms of lighthouse - but it reveals an
> important benefit of plain text stories: it would be possible to
> express stories in any of a variety of systems and have them consumed
> by an adapter that feeds them in to story runner.
>
> Thoughts?


That's really cool -- i'd look to do the same with Pivotal Labs'  
Tracker -- export my stories and run them directly. The problem of  
course is acceptance - what happens if someone changes a story in a  
ticket? how do you easily track/manage that?

  -- james

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


[rspec-users] Any tips on teaching BDD with RSpec?

2007-10-17 Thread Ashley Moran
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 uni)
   * then let him write a small program (to a rough description I  
came up with) in Ruby however he wants
   * then teach him how to do BDD-driven OO
   * then let him re-write the sample app in a BDD way.

The app loads a YAML file that lists some URLs, fetches the pages off  
the interweb, extracts some data from the body of the spec, and  
outputs it to XML.  He's picking stuff up quick - he wrote it in  
about 1 1/2 days despite only learning Ruby last week.

I've gone through a really simple BDD example with him that is quite  
similar to part of the bigger app - he seems to follow the syntax of  
RSpec and flexmock, understands the concepts of full and partial  
mocks, etc.  But I've left him to rewrite his app along the same  
lines, and it's like there is a void.  Where before he just kept  
working at little bits until the output built up, now he's got the  
ability to isolate simple bits of code and develop/test them (eg  
formatting a  tag from a URL), he's taking longer.  He seems to  
be struggling to pick isolated pieces of functionality out of the  
bigger problem.

One thing I have done for him is write a functional test - one that  
runs the whole app "WebParse.run(infile, outfile)" black-box style,  
and compares the output in "outfile" to the output of his existing  
app (which we've decided between us is correct and suitable as a  
reference).  I'm not sure if this has helped or confused the issue.

Clearly there is something important I am not explaining, something I  
take for granted.  Does anyone have any ideas what? I was hoping  
someone else here has been through the experience of teaching BDD  
(RSpec or otherwise) from scratch and may be able to point me in the  
right direction.

Thanks for any advice
Ashley


PS I haven't told him to subscribe to this list yet, so I'm safe to  
talk about him for a bit :o)


--

blog @ http://aviewfromafar.net/
linked-in @ http://www.linkedin.com/in/ashleymoran
currently @ work


___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] plain text stories: motivation number 27

2007-10-17 Thread Ben Mabey
That truly would be the "holy grail".  Before this whole discussion of 
plain text stories came up I was playing around with the idea of 
creating an app for story collaboration between developers and 
customers.  So developers and customers alike would login to the system 
and create, modify, and comment (I was think Django Book styling 
commenting) on stories. I think this would facilitate discussions of 
stories between developers and customers who don't have the luxury of 
always working at the same location.  There are of course many other 
benefits of a system like this for teams that are on site- it would 
create living documenation that would evolve with the project, and 
versioning would provide a window on past iterations.  The other benefit 
would be to have helpers in the app that would explain to customers what 
a story is exactly, and maybe have wizards on creating a story (so a 
step process going though scenarios, and the different clauses  like 
given, when, etc.) 

I was thinking that the app would then generate the skeleton of the 
story file for the developer to work with.  What I was having hard time 
solving was updating the stories based off of  modified stories.  This 
problem was touched on the step matchers thread when someone thought 
that the plain text stories would generates the "real" story testing 
code.  But having the stories being truly plain text based would get rid 
of this problem and allow such a story collaboration app to be created 
and be very straightforward to do. 

For this reason I would love to see something like plain text stories 
happen.  The stories could be pulled from such an app and be ran just 
like your suggesting they could be pulled from lighthouse. 

I guess you can call me crazy too. :)

David Chelimsky wrote:
> This is mostly theoretical, but ...
>
> I'm starting to use lighthouse (http://llighthouseapp.com) for my
> projects at work. I'm organizing iterations as milestones and stories
> as tickets tagged to a milestone.
>
> Lighthouse offers an API so that you can write access the data in your
> account and write apps to process that data.
>
> I think you see where this is going.
>
> It seems to me that a plain text story could be stored in a lighthouse
> ticket, read in via the lighthouse API ... AND EXECUTED BY STORY
> RUNNER.
>
> Call me crazy :)
>
> Sure, this is theoretical in terms of lighthouse - but it reveals an
> important benefit of plain text stories: it would be possible to
> express stories in any of a variety of systems and have them consumed
> by an adapter that feeds them in to story runner.
>
> Thoughts?
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>   

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] plain text stories: motivation number 27

2007-10-17 Thread Jonathan Linowes

On Oct 17, 2007, at 11:26 AM, David Chelimsky wrote:


>
> 
>
>> wow, and maybe some day, you could press a button to generate a
>> screencast of a story...
>> (almost not kidding...)
>
> Actually you can already do better than a screencast using tools like
> watir and selenium which actually run tests against the app in a
> browser (so you can see it happening).
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

yep, capture that and add an audio narrative...
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] plain text stories: motivation number 27

2007-10-17 Thread Pat Maddox
On 10/17/07, David Chelimsky <[EMAIL PROTECTED]> wrote:
> This is mostly theoretical, but ...
>
> I'm starting to use lighthouse (http://llighthouseapp.com) for my
> projects at work. I'm organizing iterations as milestones and stories
> as tickets tagged to a milestone.
>
> Lighthouse offers an API so that you can write access the data in your
> account and write apps to process that data.
>
> I think you see where this is going.
>
> It seems to me that a plain text story could be stored in a lighthouse
> ticket, read in via the lighthouse API ... AND EXECUTED BY STORY
> RUNNER.
>
> Call me crazy :)
>
> Sure, this is theoretical in terms of lighthouse - but it reveals an
> important benefit of plain text stories: it would be possible to
> express stories in any of a variety of systems and have them consumed
> by an adapter that feeds them in to story runner.
>
> Thoughts?
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>

Definitely.  I sort of hold up the value of plain-text stories as
self-evident, but this example illustrates why they're so valuable.
Basically, anywhere you could ever want to express requirements
(email, ticket system, wiki, whatever), you can do so, and the result
is executable.  That's mind-boggling to me.

Pat
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


[rspec-users] blog on TDD from acceptance/functional testing

2007-10-17 Thread Huang Liang
Here is a blog about TDD. http://hl.thoughtworkers.org/?p=7

It talks about starting TDD from writing functional/acceptance tests
according to acceptance criteria of stories, then drilling down to the unit
tests.
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] plain text stories: motivation number 27

2007-10-17 Thread David Chelimsky
On 10/17/07, Jonathan Linowes <[EMAIL PROTECTED]> wrote:
>
> On Oct 17, 2007, at 10:41 AM, David Chelimsky wrote:
>
> > This is mostly theoretical, but ...
> >
> > I'm starting to use lighthouse (http://llighthouseapp.com) for my
> > projects at work. I'm organizing iterations as milestones and stories
> > as tickets tagged to a milestone.
> >
> > Lighthouse offers an API so that you can write access the data in your
> > account and write apps to process that data.
> >
> > I think you see where this is going.
> >
> > It seems to me that a plain text story could be stored in a lighthouse
> > ticket, read in via the lighthouse API ... AND EXECUTED BY STORY
> > RUNNER.
> >
> > Call me crazy :)
> >
> > Sure, this is theoretical in terms of lighthouse - but it reveals an
> > important benefit of plain text stories: it would be possible to
> > express stories in any of a variety of systems and have them consumed
> > by an adapter that feeds them in to story runner.



> wow, and maybe some day, you could press a button to generate a
> screencast of a story...
> (almost not kidding...)

Actually you can already do better than a screencast using tools like
watir and selenium which actually run tests against the app in a
browser (so you can see it happening).
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] plain text stories: motivation number 27

2007-10-17 Thread Jonathan Linowes

On Oct 17, 2007, at 10:41 AM, David Chelimsky wrote:

> This is mostly theoretical, but ...
>
> I'm starting to use lighthouse (http://llighthouseapp.com) for my
> projects at work. I'm organizing iterations as milestones and stories
> as tickets tagged to a milestone.
>
> Lighthouse offers an API so that you can write access the data in your
> account and write apps to process that data.
>
> I think you see where this is going.
>
> It seems to me that a plain text story could be stored in a lighthouse
> ticket, read in via the lighthouse API ... AND EXECUTED BY STORY
> RUNNER.
>
> Call me crazy :)
>
> Sure, this is theoretical in terms of lighthouse - but it reveals an
> important benefit of plain text stories: it would be possible to
> express stories in any of a variety of systems and have them consumed
> by an adapter that feeds them in to story runner.
>
> Thoughts?
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

wow, and maybe some day, you could press a button to generate a  
screencast of a story...
(almost not kidding...)


___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] works in script but not in rake

2007-10-17 Thread Jonathan Linowes
On Oct 17, 2007, at 1:26 AM, David Chelimsky wrote:

> On 10/17/07, Jonathan Linowes <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> This is weird
>>
>> All my current spec examples are passing (about 750 of 'em) except a
>> set of 6 in a specific controller spec. I get the following failure
>> on each 6 when I run it via
>> $ rake spec
>
> Do you have --reverse in your spec/spec.opts file? If so, the specs
> are being run in reverse order w/ rake, but not when you just run the
> file directly. This usually indicates that there is an undesirable
> dependency between examples in your specs.
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users


I renamed that particular action ("accept") and the error goes away,  
so apparently I had some namespace conflict in the controller





___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


[rspec-users] helpful blog on Acceptance Testing/Unit Testing

2007-10-17 Thread David Chelimsky
Hey all,

While I object to the name "testing", Uncle Bob's recent blog on
Acceptance Testing/Unit Testing might prove interesting for those of
you grappling with the meaning of Story Runner (which fits in the
Acceptance Testing space) vs Spec Runner (which fits in the Unit
Testing space).

http://blog.objectmentor.com/articles/2007/10/17/tdd-with-acceptance-tests-and-unit-tests

Enjoy!

Cheers,
David
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] Scenarios Plugin Pre-Announcement

2007-10-17 Thread Scott Taylor

On Oct 17, 2007, at 1:38 AM, John W. Long wrote:

> On 10/16/07, Andy Watts <[EMAIL PROTECTED]> wrote:
>> I recently spent a lot of time looking at something similar before  
>> going
>> with the fixtures replacement plugin.
>> It gives me new_user, create_user, create_user(:first_name =>
>> 'overriddefault' ).
>> Also creates records for associations where required.  This is  
>> useful in
>> story runner, where I'm mocking less.
>> screencast here
>> http://railsnewbie.com/files/fixture_replacement_demo_new.mov
>
> I like the auto generation of those methods. That's something that we
> have thought about and intend to add to Scenarios at some point in the
> future. The huge advantage of Scenarios over the FixtureReplacement
> plugin (if I understand it correctly) is that it gives you a way to
> group and manage your record creation calls. So you can say you want
> to use the Accounts scenario and it will load up your basic accounts,
> transactions, etc...

I haven't had the chance to really play with your plugin.  How is it  
different than fixture scenarios (from err.the.blog)?

Scott

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


[rspec-users] plain text stories: motivation number 27

2007-10-17 Thread David Chelimsky
This is mostly theoretical, but ...

I'm starting to use lighthouse (http://llighthouseapp.com) for my
projects at work. I'm organizing iterations as milestones and stories
as tickets tagged to a milestone.

Lighthouse offers an API so that you can write access the data in your
account and write apps to process that data.

I think you see where this is going.

It seems to me that a plain text story could be stored in a lighthouse
ticket, read in via the lighthouse API ... AND EXECUTED BY STORY
RUNNER.

Call me crazy :)

Sure, this is theoretical in terms of lighthouse - but it reveals an
important benefit of plain text stories: it would be possible to
express stories in any of a variety of systems and have them consumed
by an adapter that feeds them in to story runner.

Thoughts?
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] Example for attr_accessible?

2007-10-17 Thread Wincent Colaiuta
El 17/10/2007, a las 7:26, "Pat Maddox" <[EMAIL PROTECTED]> escribió:

> Well, you'll find differing opinions on this.  Every time I've done
> validations I've written a spec that actually exercises the behavior.
> For example
>
> class Person < ActiveRecord::Base
>   validates_presence_of :name
> end
>
> describe Person do
>   it "should not be valid without a name" do
> p = Person.new
> p.should_not be_valid
> p.errors.on(:name).should == "can't be blank"
>   end
> end
>
> As far as I'm concerned, that's specifying the behavior.  A person
> without a name is not valid, and it results in an error message on
> name.  Doing it the way we've discussed in this thread is ugly and
> stupid, imo.

I agree that you'll find many opinions on this. My personal take is  
that you should be testing the behaviour, not testing that the  
"validates..." method was called.

Why? Because while this is fine for a simple validation like  
validates_presence_of, it can fall down for complex validations  
with :on, :if, and other clauses. The problem is that it is fairly  
easy to write a complex validation that doesn't actually do what you  
think it does. Testing that you set it up gives you very little in  
that case; you should be testing that it *does* what you think it  
does. You are not testing ActiveRecord in this case (it's well  
tested); you are testing that your use of ActiveRecord gives you the  
desired behaviour. And as has already been pointed out, you can write  
a custom matcher to make such oft-used specs easy to write. My own  
take on this is here:



Compare this with attr_accesible. That's much simpler; it takes a  
list of symbols. It is much harder to make a mistake. In that case I  
think it's fine to mock the call and just check that your code does  
the attr_accessible call. But having said that, seeing as testing the  
behaviour directly is so simple (just try mass assigning and see if  
it worked or not) I just test the behaviour anyway and forget about  
the mock+load trick.

Cheers,
Wincent

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users