2010-08-17 01:12:34 utc |
jmettraux |
dhf: you should have no problem testing the consume method of a participant |
2010-08-17 01:13:09 utc |
jmettraux |
have to run |
2010-08-17 01:20:26 utc |
gmcinnes |
spamhead |
2010-08-17 04:20:28 utc |
dhf |
jmettraux: I assume I should either emulate a workitem or can I easily instantiate an actual one. I created one but got an error related to fs_storage. I do not want to run a process, I just want to call the consume to test it. |
2010-08-17 04:21:49 utc |
jmettraux |
you can create a workitem by doing wi = Ruote::Workitem.new('fields' => {}) |
2010-08-17 04:22:12 utc |
jmettraux |
then participant.consume(wi) |
2010-08-17 04:26:16 utc |
dhf |
I will try it |
2010-08-17 05:46:00 utc |
dhf |
if the participant tries to add something to the work item it seems I get an error on storage for nilclass http://pastie.org/1097071 |
2010-08-17 05:48:41 utc |
dhf |
the participant does add several fields to the workitem |
2010-08-17 06:17:41 utc |
jmettraux |
dhf: sorry, back |
2010-08-17 06:18:15 utc |
jmettraux |
your participant is trying to reply to the engine |
2010-08-17 06:19:00 utc |
jmettraux |
you have to mock the context/storage |
2010-08-17 06:19:44 utc |
jmettraux |
when you instantiate the participant, do something like |
2010-08-17 06:22:31 utc |
jmettraux |
http://gist.github.com/528678 |
2010-08-17 06:23:58 utc |
jmettraux |
tosch_le: hello |
2010-08-17 06:24:08 utc |
tosch_le |
hello folks! |
2010-08-17 06:24:38 utc |
tosch_le |
i see, you're contemplating about the "spec my participant" problem from yesterday :-) |
2010-08-17 06:26:49 utc |
jmettraux |
dhf: or simply neutralize the reply_to_engine method, like in http://gist.github.com/528688 |
2010-08-17 06:26:58 utc |
jmettraux |
tosch_le: yes |
2010-08-17 06:27:18 utc |
jmettraux |
the participant wants to reply to the engine |
2010-08-17 06:27:26 utc |
jmettraux |
and there is no engine/storage |
2010-08-17 06:27:33 utc |
jmettraux |
so it triggers an error |
2010-08-17 06:27:48 utc |
jmettraux |
http://pastie.org/1097071 |
2010-08-17 06:36:56 utc |
tosch_le |
the participant replies in the consume method? |
2010-08-17 06:37:59 utc |
jmettraux |
yes |
2010-08-17 06:38:09 utc |
jmettraux |
classical local participant |
2010-08-17 06:38:41 utc |
tosch_le |
i suppose i would stub the reply_to_engine method |
2010-08-17 06:38:44 utc |
jmettraux |
def consume(workitem); workitem.fields['hello'] = 'world'; reply_to_engine(workitem); end |
2010-08-17 06:39:58 utc |
tosch_le |
something like "participant_instance.expects(:reply_to_engine).with(workitem)" |
2010-08-17 06:40:24 utc |
tosch_le |
that even specs the fact that reply_to_engine is called within the method |
2010-08-17 06:46:14 utc |
jmettraux |
cool |
2010-08-17 06:46:58 utc |
jmettraux |
is that a rspec idiom or do you need something like mocha to do it ? |
2010-08-17 06:47:16 utc |
tosch_le |
let me have a look in the rspec book |
2010-08-17 06:48:23 utc |
tosch_le |
"A message expectation, a.k.a. mock expectation, is a method stub that |
2010-08-17 06:48:24 utc |
tosch_le |
will raise an error if it is never called. In RSpec, we create a message |
2010-08-17 06:48:24 utc |
tosch_le |
expectation using the should_receive( ) |
2010-08-17 06:48:24 utc |
tosch_le |
" |
2010-08-17 06:49:01 utc |
tosch_le |
participant_instance.should_receive(:reply_to_engine) |
2010-08-17 06:49:42 utc |
tosch_le |
the ".with(workitem)" may be added, too. |
2010-08-17 06:50:58 utc |
jmettraux |
if you could gist it the complete example :-) |
2010-08-17 06:52:26 utc |
tosch_le |
is there the existing spec code anywhere? |
2010-08-17 06:53:27 utc |
jmettraux |
nowhere |
2010-08-17 06:53:51 utc |
jmettraux |
dhf: could we have a look at your spec and make it work for you ? |
2010-08-17 06:54:49 utc |
tosch_le |
giving an example gist is fine, but it's really only the one line above. |
2010-08-17 06:57:28 utc |
tosch_le |
http://gist.github.com/528730 |
2010-08-17 06:58:10 utc |
jmettraux |
many thanks |
2010-08-17 06:58:20 utc |
jmettraux |
I should really switch all my testing to rspec |
2010-08-17 06:58:59 utc |
tosch_le |
never mind, glad to be helpful. |
2010-08-17 06:59:32 utc |
tosch_le |
the mocking and stubbing stuff really makes it easy to isolate testing to certain aspects of a method/class |
2010-08-17 07:00:47 utc |
jmettraux |
loving it :-) |
2010-08-17 07:01:08 utc |
tosch_le |
"The RSpec Book" from the "he Pragmatic Bookshelf" is worth its price imho |
2010-08-17 07:01:30 utc |
tosch_le |
there's a 't' missing in the line above… |
2010-08-17 07:01:40 utc |
jmettraux |
I got it |
2010-08-17 07:02:04 utc |
tosch_le |
that was a hint for the rest of the world ;-p |
2010-08-17 07:02:19 utc |
jmettraux |
but was always turned off by .should == or .should x |
2010-08-17 07:02:33 utc |
jmettraux |
but now finding my marks |
2010-08-17 07:02:54 utc |
jmettraux |
or always stuck with test/unit, because of habits |
2010-08-17 07:03:01 utc |
jmettraux |
and it's here |
2010-08-17 07:03:21 utc |
tosch_le |
i never started with test/unit, so it's easy for me |
2010-08-17 07:03:24 utc |
jmettraux |
but now moving on, thanks to you and Kenneth |
2010-08-17 07:05:31 utc |
jmettraux |
wow, you're lucky |
2010-08-17 07:06:05 utc |
tosch_le |
no, not lucky, we never used to write tests at our small company |
2010-08-17 07:06:37 utc |
tosch_le |
that drives as mad now in our somehow grown and barely manageable php project. |
2010-08-17 07:07:10 utc |
tosch_le |
so i'm going to use rspec for all future ruby projects we develop :-) |
2010-08-17 07:08:22 utc |
jmettraux |
may all the future projects be ruby projects |
2010-08-17 07:08:48 utc |
tosch_le |
wise words. |
2010-08-17 07:10:16 utc |
tosch_le |
rspec matchers i like most: object.should be_* (calls object.*?) and in rails lambda.should.change |
2010-08-17 07:11:11 utc |
tosch_le |
'have_*' and 'has_*' are nice ones, too. |
2010-08-17 08:50:49 utc |
jmettraux |
tosch_le: I feel rk is ready for a 2.1.11 release, what do you think ? |
2010-08-17 08:51:51 utc |
tosch_le |
you have set the "done" marks on the wishlist entries, so i suppose, yes, let's release. |
2010-08-17 08:53:59 utc |
jmettraux |
I will actually double-check all the storage implementations at first |
2010-08-17 09:34:20 utc |
tosch_le |
just do a "rake release" if you're ready :-) |
2010-08-17 09:34:52 utc |
jmettraux |
lol |
2010-08-17 12:26:22 utc |
jmettraux |
tosch_le : I'll probably need your help to double check rk's README |
2010-08-17 12:26:34 utc |
jmettraux |
then you can greenlight me for the release |
2010-08-17 12:26:51 utc |
tosch_le |
what means 'probably'? ;-) |
2010-08-17 12:29:45 utc |
tosch_le |
I'd drop the dependencies list; the gemfile is literal enough for that |
2010-08-17 12:31:44 utc |
jmettraux |
do it please |
2010-08-17 12:31:46 utc |
jmettraux |
;-) |
2010-08-17 12:31:58 utc |
tosch_le |
fine :-) |
2010-08-17 12:32:15 utc |
jmettraux |
if you have the time |
2010-08-17 12:32:58 utc |
tosch_le |
i do. |
2010-08-17 12:33:39 utc |
tosch_le |
the configuration section isn't up to date, too, i'll fix that. |
2010-08-17 12:34:23 utc |
jmettraux |
I will investigate how to secure /_ruote |
2010-08-17 12:35:15 utc |
jmettraux |
I have this rails application and I just activated _ruote in it, but it's like a loaded gun |
2010-08-17 12:36:07 utc |
tosch_le |
too true. but it's the user's responsibility to secure the app – at least at the moment |
2010-08-17 12:36:37 utc |
jmettraux |
indeed, but I will document some ways to do it |
2010-08-17 12:36:51 utc |
tosch_le |
that's great |
2010-08-17 12:50:17 utc |
tosch_le |
hmm, there isn't a default ruote engine to load anymore if none is bound? |
2010-08-17 12:50:35 utc |
tosch_le |
that's ok, but i need to figure that out in the readme |
2010-08-17 13:17:30 utc |
jmettraux |
I'll cover you, if you don't know what to write, insert a explain this or that |
2010-08-17 13:17:55 utc |
tosch_le |
ok, i'm trying my best |
2010-08-17 13:40:50 utc |
tosch_le |
http://github.com/tosch/ruote-kit/commit/241b326d5bce82429163cda6b51eecb871ff0d94 |
2010-08-17 13:47:20 utc |
jmettraux |
very good :-) |
2010-08-17 13:48:35 utc |
tosch_le |
i hope there are not too many mistakes :-) |
2010-08-17 13:49:31 utc |
jmettraux |
looks OK, I'll re-read it tomorrow |
2010-08-17 13:49:37 utc |
jmettraux |
many thanks ! |
2010-08-17 13:49:54 utc |
tosch_le |
never mind. i'm always glad to be helpful |
2010-08-17 13:50:44 utc |
jmettraux |
:-) |
2010-08-17 19:34:46 utc |
dhf |
Sorry I missed your post request last night. It seems to work now but here it is: http://pastie.org/1098424 |
2010-08-17 21:49:01 utc |
dhf |
I converted to the format from tousch_le provided and it works ok. Is the proper response to the engine when done reply(workitem) or reply_to_engine(workitem) |
2010-08-17 23:32:14 utc |
jmettraux |
dhf: I've seen your http://pastie.org/1098424 |
2010-08-17 23:32:20 utc |
jmettraux |
hello |
2010-08-17 23:32:37 utc |
jmettraux |
since you're using rspec you should have a look at "should_receive" |
2010-08-17 23:33:47 utc |
dhf |
I am experimenting with that now |
2010-08-17 23:33:56 utc |
jmettraux |
it lets you test whether reply_to_engine is called and whether the workitem was modified in the way you expected |
2010-08-18 00:43:56 utc |
dhf |
Is the correct one reply(workitem) or reply_to_engine(workitem)? |
2010-08-18 00:44:33 utc |
jmettraux |
both are correct |
2010-08-18 00:44:56 utc |
jmettraux |
it was reply_to_engine initially, but I simplified to reply |