Hi Robert

If you're expecting the other developers to write Ruby as well, you could 
provide a shared RSpec example group (within your own gem, if you have one?) 
that they could then apply in their own tests.

    # common/shared/specs.rb (use a more meaningful file name :)
    share_examples_for 'a widget' do
      it { should respond_to(:all_of_the_things) }
    end

    # Then, in their tests
    require 'common/shared/specs'
    
    describe MyCustomWidget do
      it_should_behave_like 'a widget'
    end

There's the implicit subject being used (MyCustomWidget.new), but each dev can 
customise that if they wish to.

If you're using MiniTest or TestUnit, I think a module with the common tests 
will do the trick just as nicely.

At a higher level, you could apply this approach to HTTP API specs, if that's 
the level of communication (check that the expected paths don't return a 404 
status, and perhaps other lower level implementation details).

And besides all this - good documentation is a very good idea as well!

-- 
Pat

On 30/11/2012, at 10:05 AM, Iain Beeston wrote:

> +1 for using tests to define behaviour (isn't that what tests are for?)
> 
> 
> 
> Iain
> 
> 
> 
> On 29 November 2012 23:08, Sebastian Porto <[email protected]> wrote:
> By writing tests most likely. You could write a test that calls the methods 
> on the class and  checks the return values that you want. Then handle that 
> test to the other developers, then they just need to make the tests pass by 
> implementing the real thing.
> 
> However as these are different apps, how are they talking to each other? The 
> tests would need to check the API between the two apps.
> 
> Sebastian
> 
>>      Robert Gravina  29 November 2012 8:48 PM
>> Hello!
>> 
>> I have this situation where I'd like to allow other developers to write code 
>> that works with some other code I'm writing. Basically, I'd like to say 
>> "please implement a class which has at least these specific methods and 
>> gives me data in this format, and tell me (the code) what this class is so I 
>> can call methods on it and use the return values". A little bit like 
>> Interfaces in languages like Java or Obj-C allow you to do. It doesn't have 
>> to be as flexible as a full blown plugin system!
>> 
>> The actual use case, if it helps clarify my question - I've written code (in 
>> Rails)  which collates statistics for reporting on e-learning apps (also in 
>> Rails, some part of the same app and some completely separate Rails apps) 
>> and developers of these apps would like to provide this info, such as 
>> "number of lessons passed", "time studied" etc. without having to know too 
>> much of the specifics of the reporting code like what models/db tables are 
>> used, or how it collates the info etc.
>> 
>> My question is - how do you normally handle this in Ruby. Through good 
>> documentation? A certain coding pattern? A gem?
>> 
>> Thanks!
>> 
>> Robert
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ruby or Rails Oceania" 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/rails-oceania?hl=en.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby or Rails Oceania" 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/rails-oceania?hl=en.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby or Rails Oceania" 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/rails-oceania?hl=en.


-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" 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/rails-oceania?hl=en.

<<attachment: postbox-contact.jpg>>

Reply via email to