Skip to content

Instantly share code, notes, and snippets.

@kimh
Last active August 29, 2015 14:10
Show Gist options
  • Save kimh/e2e0755f47f6703dc21c to your computer and use it in GitHub Desktop.
Save kimh/e2e0755f47f6703dc21c to your computer and use it in GitHub Desktop.
Accessing fields not mapped in lotus-model
require 'lotus/model'
require 'sequel'
require 'sqlite3'
require 'minitest/autorun'
require 'pp'
class Fruit
include Lotus::Entity
self.attributes = :type, :taste
end
class FruitRepository
include Lotus::Repository
end
describe "taste field is not mapped" do
before(:each) do
uri = "sqlite:///tmp/test.db"
Lotus::Model.configure do
adapter :sqlite, :sql, uri, default: true
mapping do
collection :fruits do
entity Fruit
attribute :id, Integer
attribute :type, String
# attribute :taste, String
end
end
end
database = Sequel.connect(uri)
database.drop_table? :fruits
database.create_table :fruits do
primary_key :id
String :type
String :taste
end
Lotus::Model.load!
end
it 'taste field is nil' do
FruitRepository.create(Fruit.new(type: "apple", taste: "awesome"))
FruitRepository.first.taste.must_be_nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment