Project

shamrock

0.01
No commit activity in last 3 years
No release in over 3 years
Shamrock helps you to use stub services in your application by starting a rack service in a Thread
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.9.2.2
~> 2.10.0
~> 0.6.4

Runtime

>= 0
 Project Readme

Build Status

Shamrock

Makes setting up stub services easy.

Installation

Add this line to your application's Gemfile:

gem 'shamrock'

And then execute:

$ bundle

Or install it yourself as:

$ gem install shamrock

Usage

You can then easily start the stub service either for the spec examples that need it, or globally in your spec_helper file. You can replace the Proc below with any Rack application. In some cases, we use Sinatra for stub services.

my_rack_app = proc {|env| [200, {"Content-Type" => "text/html"}, ["Hello Rack!"]]}
@service = Shamrock::Service.new(my_rack_app)
@service.start
@service.uri    # => #<URI::HTTP http://localhost:54321>

After you are done with the service:

@service.stop

Credits

Thanks to Wojciech Mach (http://github.com/wojtekmach) who helped to implement something like this for a stub service on a project for Stack Builders.

Thanks to Mike Barinek for writing up an example of this code that used Threads for starting the rack application - this gem draws from code in his blog post at http://pivotallabs.com/users/mbarinek/blog/articles/2043-testing-ruby-services-without-mocks

Thanks to Kurt Eldridge (http://github.com/truk) for pair programming on a test problem with Threads.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request