isolate-scenarios 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/IsolateScenarios ADDED
@@ -0,0 +1,11 @@
1
+ baseline do
2
+ gem 'puppet', '= 0.24.8'
3
+ gem 'facter', '>= 1.5.4'
4
+ gem 'highline', '>= 1.5.0'
5
+ gem 'builder', '>= 2.1.2'
6
+ end
7
+
8
+ gem_version_scenario 'activesupport',
9
+ '2.1.2',
10
+ '2.2.3',
11
+ '2.3.5'
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Joshua Nichols
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,101 @@
1
+ = isolate-scenarios
2
+
3
+ When you're developing libraries that interact with Rails, or any other large project, it can be difficult to know if you are compatible with any specific version, and to make sure you remain compatible.
4
+
5
+ isolate (http://github.com/jbarnette/isolate) was released as a way to help sandbox the gems available to your project. This is pretty great, because it lets you know for sure that only the gems as well as the specific version you care about.
6
+
7
+ The only thing this is missing is the ability to define the gem version scenarios you care about, and be able run your test suite against each scenario. And that is where isolate-scenarios comes into place.
8
+
9
+ == Getting started
10
+
11
+ You need the gem first:
12
+
13
+ gem install isolate-scenarios
14
+
15
+ Now head over to your project. There are two additions you'll need. First, you need an IsolateScenario file, which describes your gem dependencies, as well as the gem you'll want to test different versions of:
16
+
17
+ baseline do
18
+ # This is the same syntax as isolate's Isolate file
19
+ gem 'puppet', '= 0.24.8'
20
+ gem 'facter', '>= 1.5.4'
21
+ gem 'highline', '>= 1.5.0'
22
+ gem 'builder', '>= 2.1.2'
23
+ end
24
+
25
+ # This is the gem we'll be testing different versions of
26
+ # first arg is the gem name, and all other args are versions to test
27
+ gem_version_scenario 'activesupport',
28
+ '2.1.2',
29
+ '2.2.3',
30
+ '2.3.5',
31
+ '2.3.8',
32
+ '3.0.0.beta4'
33
+
34
+ To verify this is setup, you can use 'isolate-scenarios list' to show them:
35
+
36
+ activesupport:
37
+ * 2.1.2
38
+ * 2.2.3
39
+ * 2.3.5
40
+ * 2.3.8
41
+ * 3.0.0.beta4
42
+
43
+ Next, you'll need to update your test suite's helper, typically spec/spec_helper.rb or test/test_helper.rb. You need to place this line as soon as you can in the file:
44
+
45
+ require 'isolate/scenarios/now'
46
+
47
+ Now, when you run your tests, it will default to using the last version you specified. For example:
48
+
49
+ $ rake spec
50
+ (in shadow_puppet)
51
+ Activating scenario: activesupport-3.0.0.beta4
52
+ # omitted
53
+
54
+ If you want to test against a specific scenario, you can specify it as an environment variable:
55
+
56
+ $ rake spec ISOLATE_SCENARIO=2.3.8
57
+ (in shadow_puppet)
58
+ Activating scenario: activesupport-2.3.8
59
+ # omitted
60
+
61
+ This is cool and all, but we still would love to test all the scenarios in one shot. 'isolate-scenarios rake' lets you just do that. This will iterate over each scenario, and invoke rake with any args you pass it.
62
+
63
+
64
+ $ isolate-scenarios rake spec
65
+ (in shadow_puppet)
66
+ Activating scenario: activesupport-2.1.2
67
+ # omitted
68
+
69
+ (in shadow_puppet)
70
+ Activating scenario: activesupport-2.2.3
71
+ # omitted
72
+
73
+ (in shadow_puppet)
74
+ Activating scenario: activesupport-2.3.5
75
+ # omitted
76
+
77
+ (in shadow_puppet)
78
+ Activating scenario: activesupport-2.3.8
79
+ # omitted
80
+
81
+ == Limitations
82
+
83
+ Most projects I've worked on that need something like this only vary across one gem. As a result, gem_version_scenario only works for specifying one gem that varies. I tried coming up for some better defining multiple ones, but not having run into that situation, I passed for now.
84
+
85
+ Some of the API may be slightly limited because I was going for the simplest case that worked to test in isolation for a project. The 'now!' method, and others, aren't nearly as flexible as isolate proper.
86
+
87
+ There can be a bit of redudancy in gem dependency, ie you might specify them in your Rakefile via jeweler, or in Gemfile, or in Isolate, etc. isolate-scenarios doesn't try to reduce that redudancy at all yet.
88
+
89
+ 0 tests. I'm sorry, but I'm a bad bad man wanting to spike out an initial version. I'm pretty much sure I'll be rewriting parts of this, and having tests going forward.
90
+
91
+ == Note on Patches/Pull Requests
92
+
93
+ * Fork the project.
94
+ * Make your feature addition or bug fix.
95
+ * Add tests for it. This is important so I don't break it in a future version unintentionally.
96
+ * Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
97
+ * Send me a pull request. Bonus points for topic branches.
98
+
99
+ == Copyright
100
+
101
+ Copyright (c) 2010 Joshua Nichols. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,48 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "isolate-scenarios"
8
+ gem.version = "0.0.2"
9
+ gem.summary = %Q{Tool for testing libraries using different senarios of gem versions}
10
+ gem.description = %Q{Tool for testing libraries using different senarios of gem versions}
11
+ gem.email = "josh@technicalpickles.com"
12
+ gem.homepage = "http://github.com/technicalpickles/isolate-scenarios"
13
+ gem.authors = ["Joshua Nichols"]
14
+ gem.add_dependency "thor"
15
+ gem.add_dependency "isolate"
16
+ gem.add_development_dependency "rspec", ">= 1.2.9"
17
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
+ end
19
+ Jeweler::GemcutterTasks.new
20
+ rescue LoadError
21
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
+ end
23
+
24
+ require 'spec/rake/spectask'
25
+ Spec::Rake::SpecTask.new(:spec) do |spec|
26
+ spec.libs << 'lib' << 'spec'
27
+ spec.spec_files = FileList['spec/**/*_spec.rb']
28
+ end
29
+
30
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
31
+ spec.libs << 'lib' << 'spec'
32
+ spec.pattern = 'spec/**/*_spec.rb'
33
+ spec.rcov = true
34
+ end
35
+
36
+ task :spec => :check_dependencies
37
+
38
+ task :default => :spec
39
+
40
+ require 'rake/rdoctask'
41
+ Rake::RDocTask.new do |rdoc|
42
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
43
+
44
+ rdoc.rdoc_dir = 'rdoc'
45
+ rdoc.title = "isolate-scenarios #{version}"
46
+ rdoc.rdoc_files.include('README*')
47
+ rdoc.rdoc_files.include('lib/**/*.rb')
48
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'isolate/scenarios'
3
+
4
+ Isolate::Scenarios::Cli.start
@@ -0,0 +1,68 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{isolate-scenarios}
8
+ s.version = "0.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Joshua Nichols"]
12
+ s.date = %q{2010-07-01}
13
+ s.default_executable = %q{isolate-scenarios}
14
+ s.description = %q{Tool for testing libraries using different senarios of gem versions}
15
+ s.email = %q{josh@technicalpickles.com}
16
+ s.executables = ["isolate-scenarios"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "IsolateScenarios",
25
+ "LICENSE",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "bin/isolate-scenarios",
29
+ "isolate-scenarios.gemspec",
30
+ "lib/isolate-scenarios.rb",
31
+ "lib/isolate/scenarios.rb",
32
+ "lib/isolate/scenarios/cli.rb",
33
+ "lib/isolate/scenarios/now.rb",
34
+ "lib/isolate/scenarios/sandbox.rb",
35
+ "spec/isolate-scenarios_spec.rb",
36
+ "spec/spec.opts",
37
+ "spec/spec_helper.rb"
38
+ ]
39
+ s.homepage = %q{http://github.com/technicalpickles/isolate-scenarios}
40
+ s.rdoc_options = ["--charset=UTF-8"]
41
+ s.require_paths = ["lib"]
42
+ s.rubygems_version = %q{1.3.6}
43
+ s.summary = %q{Tool for testing libraries using different senarios of gem versions}
44
+ s.test_files = [
45
+ "spec/isolate-scenarios_spec.rb",
46
+ "spec/spec_helper.rb"
47
+ ]
48
+
49
+ if s.respond_to? :specification_version then
50
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
51
+ s.specification_version = 3
52
+
53
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
54
+ s.add_runtime_dependency(%q<thor>, [">= 0"])
55
+ s.add_runtime_dependency(%q<isolate>, [">= 0"])
56
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
57
+ else
58
+ s.add_dependency(%q<thor>, [">= 0"])
59
+ s.add_dependency(%q<isolate>, [">= 0"])
60
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
61
+ end
62
+ else
63
+ s.add_dependency(%q<thor>, [">= 0"])
64
+ s.add_dependency(%q<isolate>, [">= 0"])
65
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
66
+ end
67
+ end
68
+
@@ -0,0 +1,30 @@
1
+ require 'thor'
2
+ module Isolate
3
+ module Scenarios
4
+ class Cli < Thor
5
+ include Thor::Actions
6
+
7
+ desc "list", "list scenarios"
8
+ def list
9
+ sandbox = Isolate::Scenarios::Sandbox.new
10
+
11
+ puts "#{sandbox.gem_to_vary}:"
12
+ sandbox.versions.each do |version|
13
+ puts "* #{sandbox.gem_to_vary}-#{version}"
14
+ end
15
+ end
16
+
17
+ desc "rake", "rake for each scenarios"
18
+ def rake(*)
19
+ ARGV.delete('rake')
20
+
21
+ sandbox = Isolate::Scenarios::Sandbox.new
22
+
23
+ sandbox.versions.each do |version|
24
+ system "rake ISOLATE_SCENARIO=#{sandbox.gem_to_vary}-#{version} #{ARGV.join(' ')}"
25
+ end
26
+ end
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,2 @@
1
+ require 'isolate/scenarios'
2
+ Isolate::Scenarios.now!
@@ -0,0 +1,43 @@
1
+ module Isolate
2
+ module Scenarios
3
+ class Sandbox
4
+ attr_accessor :gem_to_vary, :versions
5
+
6
+ def current_scenario
7
+ if ENV['ISOLATE_SCENARIO']
8
+ scenario = versions.detect do |version|
9
+ ENV['ISOLATE_SCENARIO']== "#{gem_to_vary}-#{version}"
10
+ end
11
+ scenario || raise("No scenario defined for #{ENV['ISOLATE_SCENARIO']}")
12
+ else
13
+ versions.last
14
+ end
15
+ end
16
+
17
+ def initialize
18
+ file = "IsolateScenarios"
19
+ instance_eval IO.read(file), file, 1
20
+ end
21
+
22
+ def baseline(&block)
23
+ @baseline_sandbox = Isolate::Sandbox.new(&block)
24
+ end
25
+
26
+ def gem_version_scenario(gem, *versions)
27
+ @gem_to_vary = gem
28
+ @versions = versions.flatten
29
+ end
30
+
31
+ def activate
32
+ puts "Activating scenario: #{gem_to_vary}-#{current_scenario}"
33
+
34
+ @baseline_sandbox ||= Isolate::Sandbox.new
35
+ @baseline_sandbox.gem gem_to_vary, current_scenario
36
+
37
+ @baseline_sandbox.activate(Isolate.env)
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+
@@ -0,0 +1,12 @@
1
+ require 'isolate'
2
+ require 'isolate/scenarios/sandbox'
3
+ require 'isolate/scenarios/cli'
4
+
5
+ module Isolate
6
+ module Scenarios
7
+ def self.now!
8
+ @@sandbox = Isolate::Scenarios::Sandbox.new
9
+ @@sandbox.activate
10
+ end
11
+ end
12
+ end
@@ -0,0 +1 @@
1
+ require 'isolate/scenarios'
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Isolate::Scenarios do
4
+ it "doesn't have test" do
5
+ fail "I'm a naughty little project without tests"
6
+ end
7
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,11 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'spec'
4
+ require 'spec/autorun'
5
+
6
+ require 'isolate-scenarios'
7
+ Isolate::Scenarios.now!
8
+
9
+ Spec::Runner.configure do |config|
10
+
11
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: isolate-scenarios
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ version: 0.0.2
10
+ platform: ruby
11
+ authors:
12
+ - Joshua Nichols
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-07-01 00:00:00 -04:00
18
+ default_executable: isolate-scenarios
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: thor
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ - !ruby/object:Gem::Dependency
33
+ name: isolate
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
41
+ version: "0"
42
+ type: :runtime
43
+ version_requirements: *id002
44
+ - !ruby/object:Gem::Dependency
45
+ name: rspec
46
+ prerelease: false
47
+ requirement: &id003 !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ segments:
52
+ - 1
53
+ - 2
54
+ - 9
55
+ version: 1.2.9
56
+ type: :development
57
+ version_requirements: *id003
58
+ description: Tool for testing libraries using different senarios of gem versions
59
+ email: josh@technicalpickles.com
60
+ executables:
61
+ - isolate-scenarios
62
+ extensions: []
63
+
64
+ extra_rdoc_files:
65
+ - LICENSE
66
+ - README.rdoc
67
+ files:
68
+ - .document
69
+ - .gitignore
70
+ - IsolateScenarios
71
+ - LICENSE
72
+ - README.rdoc
73
+ - Rakefile
74
+ - bin/isolate-scenarios
75
+ - isolate-scenarios.gemspec
76
+ - lib/isolate-scenarios.rb
77
+ - lib/isolate/scenarios.rb
78
+ - lib/isolate/scenarios/cli.rb
79
+ - lib/isolate/scenarios/now.rb
80
+ - lib/isolate/scenarios/sandbox.rb
81
+ - spec/isolate-scenarios_spec.rb
82
+ - spec/spec.opts
83
+ - spec/spec_helper.rb
84
+ has_rdoc: true
85
+ homepage: http://github.com/technicalpickles/isolate-scenarios
86
+ licenses: []
87
+
88
+ post_install_message:
89
+ rdoc_options:
90
+ - --charset=UTF-8
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ segments:
98
+ - 0
99
+ version: "0"
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ segments:
105
+ - 0
106
+ version: "0"
107
+ requirements: []
108
+
109
+ rubyforge_project:
110
+ rubygems_version: 1.3.6
111
+ signing_key:
112
+ specification_version: 3
113
+ summary: Tool for testing libraries using different senarios of gem versions
114
+ test_files:
115
+ - spec/isolate-scenarios_spec.rb
116
+ - spec/spec_helper.rb