Skip to content

Commit

Permalink
Add support for rom-repository
Browse files Browse the repository at this point in the history
  • Loading branch information
elskwid committed Mar 6, 2017
1 parent c95b75b commit 983fc7b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ gemspec
group :test do
gem 'dry-struct'
gem 'rom', git: 'https://github.com/rom-rb/rom.git', branch: 'master'
gem 'rom-repository', git: 'https://github.com/rom-rb/rom-repository', branch: 'master'
gem 'rspec', '~> 3.1'
gem 'codeclimate-test-reporter', require: false
gem 'inflecto'
Expand Down
2 changes: 2 additions & 0 deletions lib/rom/csv/relation.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'rom/memory'
require 'rom/plugins/relation/key_inference'

module ROM
module CSV
Expand All @@ -11,6 +12,7 @@ module CSV
# @api public
class Relation < ROM::Memory::Relation
adapter :csv
use :key_inference

def count
dataset.count
Expand Down
14 changes: 14 additions & 0 deletions spec/integration/gateway_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'spec_helper'
require 'dry-struct'
require 'rom/repository'

describe 'CSV gateway' do
context 'without extra options' do
Expand Down Expand Up @@ -135,5 +136,18 @@ class UserWithAddress < Dry::Struct
expect(user[:email]).to eql('[email protected]')
end
end

describe 'with a repository' do
let(:repo) do
Class.new(ROM::Repository[:users]).new(container)
end

it 'auto-maps to structs' do
user = repo.users.first

expect(user.name).to eql('Julie')
expect(user.email).to eql('[email protected]')
end
end
end
end

0 comments on commit 983fc7b

Please sign in to comment.