jamjar 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41b2c7622c51f6a2732ac06ae947570dbcb2fc9d
4
- data.tar.gz: 96afcc2f2de2301bdff75e7114718ef2fb29fcf7
3
+ metadata.gz: 961841cf0afeaac3d88c100be19d014a5648ae89
4
+ data.tar.gz: e9bc1b79a1143c1a892e2756781dc9d8d36a129c
5
5
  SHA512:
6
- metadata.gz: 5511e12f7556edd4306cca45626824dd976ddd9242d2a6882ca5b802f077ef6f1837e4ac3bd6ffeb68cfa2b38086e1b9daf52c1f4582ce412ac7a0f194ed5141
7
- data.tar.gz: 3e9f9fb9e5b70795a550235679f66b2c607bc2f947a082442bf02dba7f1fa13317e0ac7bdd7830efba2006b2c36135f26d0865f9ab6e37f189c842f2bccd4c88
6
+ metadata.gz: f25c7abd966afd28ec173d88db2764cbb6c098e86a303c2be5f4a7da246bf2f00c2519378a962c76bd41a2ce212f50b4b9be6639f7cce2e2d96c1cbd6e5afa59
7
+ data.tar.gz: 346e086a5793f03e2b8bcf53a78d32304f4f1a3569042de1e675c1127a19fcb39cde3e0d51f9de0daada5b8d2b50b0aa1289879caea4e1f3ad2abb2e0ed590f0
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ jamjar
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.1.5
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ gem "bundler"
8
8
  gem "rake"
9
9
 
10
10
  gem "rspec"
11
+ gem "rspec-expect_it"
11
12
  gem "fuubar"
12
13
 
13
14
  # gem "simplecov", require: false
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # JamJar
2
2
 
3
- JamJar dynamically creates SQLite-backed, in memory, ActiveRecord models to help you test your ActiveRecord extensions.
3
+ JamJar dynamically creates ActiveRecord models, backed by in-memory SQLite, to help you test your ActiveRecord extensions.
4
4
 
5
5
  ## Installation
6
6
 
@@ -16,7 +16,31 @@ And then execute:
16
16
 
17
17
  ## Usage
18
18
 
19
- TODO
19
+ To generate a new model, simply call:
20
+
21
+ ```ruby
22
+ JamJar.model
23
+ ```
24
+
25
+ You can pass a block, which will be evaluated in the model's class context:
26
+
27
+ ```ruby
28
+ model = JamJar.model do
29
+ def self.foo
30
+ "bar"
31
+ end
32
+ end
33
+
34
+ model.foo #=> "bar"
35
+ ```
36
+
37
+ You can add columns to your model's table with `column`.
38
+
39
+ ```ruby
40
+ JamJar.model do
41
+ column :foo, :string
42
+ end
43
+ ```
20
44
 
21
45
  ## Contributing
22
46
 
data/jamjar.gemspec CHANGED
@@ -18,5 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(spec)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.required_ruby_version = ">= 1.9.2"
22
+
21
23
  spec.add_runtime_dependency "activerecord", ">= 3.2"
24
+ spec.add_runtime_dependency "sqlite3", ">= 1.3.10"
22
25
  end
@@ -0,0 +1,12 @@
1
+ require "active_record"
2
+
3
+ module JamJar
4
+ class Model < ActiveRecord::Base
5
+ self.abstract_class = true
6
+ establish_connection adapter: :sqlite3, database: ":memory:"
7
+
8
+ def self.column(name, type)
9
+ self.connection.add_column(self.table_name, name, type)
10
+ end
11
+ end
12
+ end
@@ -1,8 +1,8 @@
1
1
  module JamJar
2
2
  module VERSION
3
- MAJOR = 0
3
+ MAJOR = 1
4
4
  MINOR = 0
5
- PATCH = 1
5
+ PATCH = 0
6
6
 
7
7
  BETA = nil
8
8
 
data/lib/jamjar.rb CHANGED
@@ -1,5 +1,17 @@
1
+ require "jamjar/model"
1
2
  require "jamjar/version"
2
3
 
3
4
  module JamJar
4
- # Your code goes here...
5
+ @@table_count = 0
6
+
7
+ def self.model
8
+ model = Class.new(JamJar::Model)
9
+
10
+ model.table_name = "table_#{@@table_count}"
11
+ @@table_count += 1
12
+
13
+ model.connection.create_table(model.table_name)
14
+ model.class_eval(&Proc.new) if block_given?
15
+ model
16
+ end
5
17
  end
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe JamJar do
4
+ describe "#model" do
5
+ subject { JamJar.model }
6
+
7
+ specify { expect_it.to be < ActiveRecord::Base }
8
+ specify { expect_it.to be_connected }
9
+
10
+ context "with block" do
11
+ subject { JamJar.model { def self.a; true; end } }
12
+
13
+ specify { expect(subject.a).to be_truthy }
14
+ end
15
+
16
+ context "with columns" do
17
+ subject { JamJar.model { column :foo, :string } }
18
+
19
+ specify { expect(subject.new).to respond_to(:foo) }
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,40 @@
1
+ require "bundler"
2
+
3
+ unless ENV["TRAVIS_CI"]
4
+ if RUBY_VERSION[0] == "2"
5
+ require "byebug"
6
+ else
7
+ require "debugger"
8
+ end
9
+ end
10
+
11
+ # if ENV["TRAVIS_CI"]
12
+ # require "simplecov"
13
+ # require "coveralls"
14
+
15
+ # SimpleCov.formatter = Coveralls::SimpleCov::Formatter
16
+
17
+ # SimpleCov.start do
18
+ # add_filter "/spec/"
19
+ # end
20
+ # end
21
+
22
+ if ENV["TRAVIS_CI"]
23
+ Bundler.require
24
+ else
25
+ Bundler.require(:default, :tools)
26
+ end
27
+
28
+ # if defined?(Rails) && !Rails.respond_to?(:env)
29
+ # module Rails
30
+ # def self.env
31
+ # "default_env"
32
+ # end
33
+ # end
34
+ # end
35
+
36
+ Dir[File.expand_path("../support/**/*.rb", __FILE__)].each {|f| require f }
37
+
38
+ RSpec.configure do |config|
39
+ config.order = "random"
40
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jamjar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Drake-Brockman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-11 00:00:00.000000000 Z
11
+ date: 2014-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.10
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.3.10
27
41
  description: JamJar dynamically creates SQLite-backed, in memory, ActiveRecord models
28
42
  to help you test your ActiveRecord extensions.
29
43
  email:
@@ -33,13 +47,18 @@ extensions: []
33
47
  extra_rdoc_files: []
34
48
  files:
35
49
  - ".gitignore"
50
+ - ".ruby-gemset"
51
+ - ".ruby-version"
36
52
  - Gemfile
37
53
  - LICENSE
38
54
  - README.md
39
55
  - Rakefile
40
56
  - jamjar.gemspec
41
57
  - lib/jamjar.rb
58
+ - lib/jamjar/model.rb
42
59
  - lib/jamjar/version.rb
60
+ - spec/jamjar_spec.rb
61
+ - spec/spec_helper.rb
43
62
  homepage: https://github.com/thomasfedb/jamjar
44
63
  licenses:
45
64
  - MIT
@@ -52,7 +71,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
71
  requirements:
53
72
  - - ">="
54
73
  - !ruby/object:Gem::Version
55
- version: '0'
74
+ version: 1.9.2
56
75
  required_rubygems_version: !ruby/object:Gem::Requirement
57
76
  requirements:
58
77
  - - ">="
@@ -60,8 +79,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
79
  version: '0'
61
80
  requirements: []
62
81
  rubyforge_project:
63
- rubygems_version: 2.4.5
82
+ rubygems_version: 2.4.3
64
83
  signing_key:
65
84
  specification_version: 4
66
85
  summary: JamJar generates ActiveRecord models for use in tests.
67
- test_files: []
86
+ test_files:
87
+ - spec/jamjar_spec.rb
88
+ - spec/spec_helper.rb