I tried something similar. Actually, put a puts outside it all to
make sure it was loading.
Yes it is loading, but the code is not running. I'm not sure why.
Here is the file that is getting loaded. Looks similar to yours.
puts("Loading")
class Spec::Example::ExampleGroup
def execute(*args, &block)
puts "Begin transaction and override execute()"
DB.transaction{super(*args, &block); puts "raise error"; raise
Sequel::Rollback}
puts "End transaction"
end
end
I never see the STDOUT except for the 'Loading' when I do a rake spec.
Something is wrong here and I'm having a hard time figuring it out.
rspec 1.3.0
rspec-rails 1.3.2
require 'spec_helper'
describe StoredProc do
describe "called with valid data" do
it "should not return an ErrMsg" do
call_lpn_pick_ex_proc(:delivery_id => 'TestValid010',
:line_number => 1,
:serial_capture => 'N').should == nil
end
end
end
private
def call_lpn_pick_ex_proc(opts={})
valid_args = valid_lpn_pick_ex_proc_args.merge(opts)
StoredProc.new(valid_args).run
end
class StoredProc
attr_accessor :name,
:args,
:errmsg
def initialize(args)
self.args = args
@ds = DB.dataset
@ds.row_proc = proc{|h| h.values.first}
end
def run
DB.transaction do
self.args = self.args.to_a.map{|a| a[1]} if self.args.is_a?
(Hash)
self.errmsg = @ds.call_sproc(:first, self.name, *self.args)
raise "StoredProc: returned an error message\n#{self.errmsg}"
unless self.errmsg.nil?
end
end
end
On Jun 4, 4:28 pm, Jeremy Evans <[email protected]> wrote:
> On Jun 4, 1:22 pm, Jeremy Evans <[email protected]> wrote:
>
>
>
>
>
> > On Jun 4, 12:48 pm, GregD <[email protected]> wrote:
>
> > > Ruby novice -> I don't see the execute method defined for
> > > Spec::Example::ExampleGroup.
>
> > > So, what is super calling?
>
> > > I tried putting puts into the code to see if it was being executed. I
> > > did not see the output. So, I'm thinking execute method is not ever
> > > be called. Or rspec is filtering STDOUT.
>
> > More likely it's not being called. What version of rspec are you
> > using? It might be a later version than I'm using, and they could
> > have changed the API. It used to be defined in
> > Spec::Example::ExampleMethods, which was included in
> > Spec::Example::ExampleGroup, so super in Spec::Example::ExampleGroup
> > would call the version in Spec::Example::ExampleMethods.
>
> Still appears to be
> there:http://github.com/dchelimsky/rspec/blob/master/lib/spec/example/examp...
>
> Are you sure your code is being executed at all. Try this instead:
>
> class Spec::Example::ExampleGroup
> puts "overriding execute"
> def execute(*args, &block)
> puts "in overridden execute"
> DB.transaction{super(*args, &block); raise Sequel::Rollback}
> end
> end
>
> If you only see the first puts but not the second, I'm not sure what
> is going on. If you don't see either, then your code isn't being
> loaded.
>
> Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.