github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

freelancing-god / ginger

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 19
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Run specs/tests multiple times through different gem versions — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Adding call to rake.bat if rake fails, and will raise an error if rake.bat 
fails as well. Thanks to Darragh Curran for the patch suggestion. Gem is 
now 1.2.0 as well. 
freelancing-god (author)
Thu Nov 26 20:45:19 -0800 2009
commit  3694696a0a6b276c098c4c43b75e149a0965cb57
tree    129cd8c11ec4e013faf5792199a7e369418522e3
parent  17fece6db2791fa410b32ff9af035099d23b37df
ginger /
name age
history
message
file .gitignore Sat Oct 11 05:21:27 -0700 2008 Working version 1.0 - docs still needed [freelancing-god]
file LICENCE Sat Oct 11 01:38:43 -0700 2008 Adding some structure, basic files [freelancing-god]
file README.textile Thu Nov 26 20:45:19 -0800 2009 Adding call to rake.bat if rake fails, and will... [freelancing-god]
file Rakefile Thu Nov 26 20:37:24 -0800 2009 Switching to jeweler [freelancing-god]
file VERSION Thu Nov 26 20:45:19 -0800 2009 Adding call to rake.bat if rake fails, and will... [freelancing-god]
directory bin/ Loading commit data...
file ginger.gemspec Thu Nov 26 20:45:19 -0800 2009 Adding call to rake.bat if rake fails, and will... [freelancing-god]
directory lib/ Thu Nov 26 20:37:24 -0800 2009 Switching to jeweler [freelancing-god]
directory spec/ Tue May 19 23:26:12 -0700 2009 allow a name for a scenario which is output whe... [adzap]
directory tasks/ Thu Nov 26 20:37:24 -0800 2009 Switching to jeweler [freelancing-god]
README.textile

Ginger is a small gem that allows you to test your projects using multiple versions of gem libraries. The idea is from Ian White’s garlic – hence the related name of this – but my approach is a bit different, since I don’t test my plugins from within a rails application. Maybe they can be merged at some point – I just hacked this up quickly to fit my needs.

To get it all working, you need to do four things. The first is, of course, to install this gem.

sudo gem install ginger --source=http://gemcutter.org

Next, add the following line of code to your spec_helper.rb file (or equivalent):

require 'ginger'

You’ll want to put it as high up as possible – in particular, before any require calls to libraries you want to cover multiple versions of.

Step number three is creating the sets of scenarios in a file called ginger_scenarios.rb, which should go in the root, spec or test directory of your project. Here’s an example, showing off the syntax possibilities.

require 'ginger'

Ginger.configure do |config|
  config.aliases["active_record"] = "activerecord"
  
  ar_1_2_6 = Ginger::Scenario.new
  ar_1_2_6[/^active_?record$/] = "1.15.6"
  
  ar_2_0_2 = Ginger::Scenario.new
  ar_2_0_2[/^active_?record$/] = "2.0.2"
  
  ar_2_1_1 = Ginger::Scenario.new
  ar_2_1_1[/^active_?record$/] = "2.1.1"
  
  config.scenarios << ar_1_2_6 << ar_2_0_2 << ar_2_1_1
end

Above, I’ve added three different scenarios, for three different versions of ActiveRecord. I also added an alias, as people sometimes use the underscore, and sometimes don’t. The gem’s name has no underscore though, so the value of the alias matches the gem name (whereas the key would be alternative usage).

You can have multiple gems set in each scenario – and you don’t have to use regular expressions, you can just use straight strings.

sphinx_scenario = Ginger::Scenario.new
sphinx_scenario["riddle"] = "0.9.8"
sphinx_scenario["thinking_sphinx"] = "0.9.8"

Don’t forget to add them to @config@’s scenarios collection, else they’re not saved anywhere.

To better discern different defined scenarios you can create them with a name. The name will be output when the scenario runs as the title.

sphinx_scenario = Ginger::Scenario.new('Thinking Sphinx 0.9.8')

And finally, you’ll want to run the tests or specs for each scenario. This is done using the ginger CLI tool, which parrots whatever parameters you give it onto rake. So just do something like:

ginger spec
ginger test
ginger spec:unit

Contributors

  • Adam Meehan
  • Darragh Curran
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server