code_spike 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in code_spike.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Sean Behan
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # CodeSpike
2
+
3
+ ## Installation
4
+
5
+ ```bash
6
+ gem install code_spike
7
+ ```
8
+
9
+ CodeSpike is a simple Gem for spiking ActiveRecord models. It uses an in memory sqlite3 database and requires all the necessary libs
10
+ for unit testing. In addition it provides a DSL for creating the database schema as well calling test methods.
11
+
12
+ I created this Gem because when working on complex ActiveRecord associations, I like to hop outside of Rails to isolate the problem. Setting up
13
+ ActiveRecord outside of Rails is easy enough, but the setup is a little verbose and I can never quite remember all the libraries
14
+ or the exact syntax. So I spend time googling or looking back through old code, which I don't like doing if I've already solved the problem.
15
+
16
+ This Gem just wraps the setup and adds a simple DSL that I can remember, so I can move right into the problem I'm working on!
17
+
18
+ ## Usage
19
+
20
+ ```ruby
21
+ require 'code_spike'
22
+
23
+ schema do
24
+ create_table(:people ){ |t| t.string :name }
25
+ end
26
+
27
+ class Person < ActiveRecord::Base; end
28
+
29
+ units do
30
+ test "person create" do
31
+ assert Person.create!
32
+ end
33
+ end
34
+ ```
35
+
36
+ For comparison, this is how you would do the same thing without this Gem.
37
+
38
+ ```ruby
39
+ require 'test/unit'
40
+ require 'active_support/core_ext/class/subclasses'
41
+ require 'active_support/test_case'
42
+ require 'active_record'
43
+
44
+ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
45
+ ActiveRecord::Migration.verbose = false
46
+
47
+ ActiveRecord::Schema.define do
48
+ create_table(:people ){ |t| t.string :name }
49
+ end
50
+
51
+ class Person < ActiveRecord::Base; end
52
+
53
+ class CodeSpikeTest < ActiveSupport::TestCase
54
+ teardown { ActiveRecord::Base.subclasses.each { |klass| klass.destroy_all} }
55
+
56
+ test "person create" do
57
+ assert Person.create!
58
+ end
59
+ end
60
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/code_spike/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Sean Behan"]
6
+ gem.email = ["inbox@seanbehan.com"]
7
+ gem.description = %q{Down and dirty ActiveRecord code spiking outside of Rails}
8
+ gem.summary = %q{CodeSpike is a simple Gem for spiking ActiveRecord models. It uses an in memory sqlite3 database and requires all the necessary libs for unit testing. In addition it provides a DSL for creating the database schema as well calling test methods.}
9
+ gem.homepage = "http://github.com/gristmill"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "code_spike"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = CodeSpike::VERSION
17
+
18
+ gem.add_dependency "activesupport", "~> 3.2"
19
+ gem.add_dependency "activerecord", "~> 3.2"
20
+ gem.add_dependency "sqlite3", "~> 1.3"
21
+ end
@@ -0,0 +1,3 @@
1
+ module CodeSpike
2
+ VERSION = "0.0.1"
3
+ end
data/lib/code_spike.rb ADDED
@@ -0,0 +1,36 @@
1
+ require 'test/unit'
2
+ require 'active_support/core_ext/class/subclasses'
3
+ require 'active_support/test_case'
4
+ require 'active_record'
5
+
6
+ # A simple example using CodeSpike
7
+ #
8
+ # require 'code_spike'
9
+ #
10
+ # schema do
11
+ # create_table(:people ){ |t| t.string :name }
12
+ # end
13
+ #
14
+ # class Person < ActiveRecord::Base; end
15
+ #
16
+ # units do
17
+ # test "something interesting" do
18
+ # assert Person.create!
19
+ # end
20
+ # end
21
+ def schema(&block)
22
+ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
23
+ ActiveRecord::Migration.verbose = false
24
+
25
+ ActiveRecord::Schema.define do
26
+ instance_eval(&block)
27
+ end
28
+ end
29
+
30
+ class CodeSpike < ActiveSupport::TestCase
31
+ teardown { ActiveRecord::Base.subclasses.each { |klass| klass.destroy_all} }
32
+ end
33
+
34
+ def units(&block)
35
+ CodeSpike.instance_eval(&block)
36
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: code_spike
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sean Behan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: &70367016368160 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.2'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70367016368160
25
+ - !ruby/object:Gem::Dependency
26
+ name: activerecord
27
+ requirement: &70367016380160 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '3.2'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70367016380160
36
+ - !ruby/object:Gem::Dependency
37
+ name: sqlite3
38
+ requirement: &70367016376940 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '1.3'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70367016376940
47
+ description: Down and dirty ActiveRecord code spiking outside of Rails
48
+ email:
49
+ - inbox@seanbehan.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - LICENSE
57
+ - README.md
58
+ - Rakefile
59
+ - code_spike.gemspec
60
+ - lib/code_spike.rb
61
+ - lib/code_spike/version.rb
62
+ homepage: http://github.com/gristmill
63
+ licenses: []
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 1.8.17
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: CodeSpike is a simple Gem for spiking ActiveRecord models. It uses an in
86
+ memory sqlite3 database and requires all the necessary libs for unit testing. In
87
+ addition it provides a DSL for creating the database schema as well calling test
88
+ methods.
89
+ test_files: []