Thanks a lot Aron. Successfully created the folder structure 

One more step of suggestion needed.  Below is the sample class I need to 
test, can you guide me how to create tests that validates the functions etc 
and how to do test coverage? 


module Nucleon
class Codes 
#----------------------------------------------------------------------------- 
# 
Code index @@registry = {} @@status_index = {} @@next_code = 0 #--- def self
.registry @@registry end #--- def self.index(status_code = nil) if 
status_code.nil? || ! status_code.integer? @@status_index else status_code = 
status_code.to_i if @@status_index.has_key?(status_code) @@status_index[
status_code] else @@status_index[registry[:unknown_status]] end end end #--- 
def self.render_index(status_code = nil) output = "Status index:\n" 
@@status_index.each do |code, name| name = name.gsub(/_/, ' ').capitalize if 
! status_code.nil? && status_code == code output << sprintf(" [ %3i ] - %s\n
", code, name) else output << sprintf(" %3i - %s\n", code, name) end end 
output << "\n" output end 
#----------------------------------------------------------------------------- 
# 
Code construction def self.code(name) name = name.to_sym unless registry.
has_key?(name) status_code = @@next_code @@next_code = @@next_code + 1 # 
TODO: Add more information to the index (like a help message) @@registry[
name] = status_code @@status_index[status_code] = name.to_s end end #--- def 
self.codes(*codes) codes.each do |name| code(name) end end 
#----------------------------------------------------------------------------- 
# 
Return status codes on demand def [](name) name = name.to_sym if @@registry.
has_key?(name) @@registry[name] else @@registry[:unknown_status] end end 
#--- def method_missing(method, *args, &block) self[method] end 
#----------------------------------------------------------------------------- 
# 
Core status codes code(:success) # This must be added first (needs to be 0) 
code(:help_wanted) code(:unknown_status) code(:action_unprocessed) code(
:batch_error) code(:validation_failed) code(:access_denied) endend
Thanks in advance .

Regards,
Avinash Duggirala
Skype:avinash5302 

On Thursday, September 18, 2014 9:20:54 PM UTC+5:30, Aaron Kromer wrote:
>
> Avinash,
>
> Glad to hear you like RSpec. Setting up a gem project is fairly similar. 
> Just start your gem, add rspec as a development dependency and run the 
> rspec setup: rspec --init. That will create the .rspec and 
> spec/spec_helper.rb files for you. After that it’s just as normal. The 
> folder structure is up to you. In general, my suggestion is to mirror your 
> lib directory. This is in the rspec-rails docs, though it probably can be 
> added to the main rspec docs too. I’ve copied and adjusted the doc to 
> remove the rails-y part:
>
> It is suggested that the spec/ directory structure generally mirror both
> app/ and lib/. This makes it easy to locate corresponding code and spec
> files.
>
> *Example:*
>
>  lib
>  ├── country_map
>  │   ├── city.rb
>  │   └── state.rb
>  ├── country_map.rb
>  └── tasks
>      ├── irc.rake
>  spec
>  ├── country_map
>  │   ├── city_spec.rb
>  │   └── state_spec.rb
>  ├── country_map_spec.rb
>  ├── spec_helper.rb
>  ├── support
>  │   ├── allow_remote_requests.rb
>  │   ├── custom_matchers.rb
>  └── tasks
>      ├── irc_spec.rb
>
> Happy specing
> ​
>
> On Thu, Sep 18, 2014 at 8:08 AM, Venkata Avinash Duggirala <
> [email protected] <javascript:>> wrote:
>
>> Hi,
>>
>> I need to do UNIT Testing to a gem which is in development. I want to use 
>> RSPEC framework. I am well versed in using RSPEC framework to automate web 
>> application.
>>
>> But, I never created a project to do unit testing a gem. Can anyone 
>> provide me how to start up, setting up the project, how folder structure 
>> should.
>>
>> Awaiting reply.
>>
>> Regards,
>> Avinash Duggirala
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "rspec" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] <javascript:>
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/rspec/8271cc91-6d84-458e-8329-e2416dd61c86%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/rspec/8271cc91-6d84-458e-8329-e2416dd61c86%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/6238056a-ac03-4b60-98f4-8cf71b71308f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to