summaryrefslogtreecommitdiff
path: root/test/feature.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/feature.rb')
-rw-r--r--test/feature.rb29
1 files changed, 16 insertions, 13 deletions
diff --git a/test/feature.rb b/test/feature.rb
index da7437a..6faf403 100644
--- a/test/feature.rb
+++ b/test/feature.rb
@@ -3,9 +3,7 @@ require_relative "setup.rb"
class FeatureTest < MiniTest::Test
def test_opentox_feature
- @feature = OpenTox::Feature.new
- @feature.title = "tost"
- @feature.save
+ @feature = OpenTox::Feature.create(:title => "tost")
assert_equal true, OpenTox::Feature.where(title: "tost").exists?, "#{@feature.id} is not accessible."
assert_equal true, OpenTox::Feature.where(id: @feature.id).exists?, "#{@feature.id} is not accessible."
@@ -16,7 +14,7 @@ class FeatureTest < MiniTest::Test
@feature2 = OpenTox::Feature.find(@feature.id)
assert_equal "tost", @feature2[:title]
assert_equal "tost", @feature2.title
- assert_equal 'Feature', @feature2.type
+ assert_kind_of Feature, @feature2
@feature2[:title] = "feature2"
@feature2.save
@@ -28,8 +26,6 @@ class FeatureTest < MiniTest::Test
id = @feature2.id
@feature2.delete
- #TODO
- #assert_raises OpenTox::ResourceNotFoundError do
assert_raises Mongoid::Errors::DocumentNotFound do
OpenTox::Feature.find(id)
end
@@ -38,17 +34,16 @@ class FeatureTest < MiniTest::Test
def test_duplicated_features
metadata = {
:title => "feature duplication test",
- :string => true,
+ :nominal => true,
:description => "feature duplication test"
}
- feature = OpenTox::Feature.find_or_create_by metadata
- dup_feature = OpenTox::Feature.find_or_create_by metadata
+ feature = NumericBioAssay.find_or_create_by metadata
+ dup_feature = NumericBioAssay.find_or_create_by metadata
+ assert_kind_of Feature, feature
assert !feature.id.nil?, "No Feature ID in #{feature.inspect}"
assert !feature.id.nil?, "No Feature ID in #{dup_feature.inspect}"
assert_equal feature.id, dup_feature.id
feature.delete
- #TODO
- #assert_raises OpenTox::ResourceNotFoundError do
assert_raises Mongoid::Errors::DocumentNotFound do
OpenTox::Feature.find(feature.id)
end
@@ -57,6 +52,14 @@ class FeatureTest < MiniTest::Test
end
end
-end
-
+ def test_smarts_feature
+ feature = Smarts.find_or_create_by(:smarts => "CN")
+ assert feature.smarts, "CN"
+ assert_kind_of Smarts, feature
+ feature.smarts = 'cc'
+ assert feature.smarts, "cc"
+ original = Feature.where(:title => 'CN').first
+ assert original.smarts, "CN"
+ end
+end