This repository has been archived by the owner on Sep 16, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Adding in specs for minimapper/ar using sqlite.
- Loading branch information
Showing
6 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
require "minimapper/common" | ||
|
||
module Minimapper | ||
class AR | ||
def add(entity) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require "spec_helper" | ||
require "minimapper/entity" | ||
require "minimapper/ar" | ||
|
||
class TestEntity < Minimapper::Entity | ||
attributes :name, :github_url | ||
validates :name, presence: true | ||
end | ||
|
||
class TestMapper < Minimapper::AR | ||
private | ||
|
||
def entity_klass | ||
TestEntity | ||
end | ||
|
||
def record_klass | ||
Record | ||
end | ||
|
||
class Record < ActiveRecord::Base | ||
attr_accessible :name | ||
self.table_name = :projects | ||
end | ||
end | ||
|
||
describe Minimapper::AR do | ||
let(:repository) { TestMapper.new } | ||
let(:entity_klass) { TestEntity } | ||
|
||
include_examples :mapper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require "active_record" | ||
require "minimapper" | ||
|
||
ROOT = File.expand_path(File.join(File.dirname(__FILE__), "..")) | ||
Dir[File.join(ROOT, "spec/support/shared_examples/*.rb")].each { |f| require f } | ||
|
||
ActiveRecord::Base.establish_connection :adapter => "sqlite3", :database => ":memory:" | ||
|
||
RSpec.configure do |config| | ||
config.before(:each) do | ||
ActiveRecord::Base.connection.execute "DELETE FROM projects;" | ||
end | ||
end | ||
|
||
silence_stream(STDOUT) do | ||
ActiveRecord::Schema.define(:version => 0) do | ||
create_table :projects, :force => true do |t| | ||
t.string :name | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters