Skip to content

robertodecurnex/spectro

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
bin
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Spectro

Specs driven social meta-programming

Gem Version Gitter Build Status Code Climate Test Coverage YARD Docs

Prototype

Spectro will fetch an algorithm to cover the given spec form its DB and will then define the #hello method using it.

require 'spectro'

class Sample

  include Spectro

  implements \
    hello: [:name]

end

__END__
spec_for hello String -> String
  "Minion"  -> "Say Hello to Minion"
  "Roberto" -> "Say Hello to Roberto"
  "Roland"  -> "Say Hello to Roland"
sample = Sample.new

sample.hello 'Eddie' #=> 'Say Hello to Eddie'

Working with Mocks

Scenarios

  • Keep coding while waiting for an algorithm that covers your specs
  • Using Spectro just to mock stuff
require 'spectro'

class EmailValidator

  include Spectro

  implements \
    valid?: [:email]

end

__END__
spec_for valid? String -> TrueClass|FalseClass
  "valid@email.com"  -> true
  "invalidATemail.com" -> false
require 'email_validator' #=> Spectro::Exception::UndefinedMethodDefinition
Spectro.configure do |config|
  config.enable_mocks!
end

require 'email_validator'

email_validator = EmailValidator.new

email_validator.valid?("valid@email.com") #=> true 
email_validator.valid?("invalidATemail.com") #=> false 
email_validator.valid?("unknown_param@email.com") #=> raise Spectro::Exception::UnkwnonMockResponse

About

Specs driven social meta-programming

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages