pillboxr 0.0.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,106 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require 'test_helper'
3
-
4
- class PillboxrTest < Test::Unit::TestCase
5
-
6
- def setup
7
- # @meds = load_yaml_fixture
8
- Pillboxr.test!
9
- end
10
-
11
- def test_should_find_by_combo_shape
12
- med = Pillboxr.first(:params=>{'color'=>"C48324;C48323"})
13
- assert_equal("Acetaminophen 150 MG / Aspirin 180 MG / Codeine 30 MG Oral Capsule", med.rxstring)
14
- end
15
-
16
- def test_should_accept_shape_as_hex
17
- meds = Pillboxr.all(:params=>{'shape' => 'C48336'})
18
- assert_equal(2345, Pillboxr.record_count)
19
- end
20
-
21
- def test_should_accept_color_as_hex
22
- meds = Pillboxr.all(:params => {'color' => "C48328"})
23
- assert_equal(886, Pillboxr.record_count)
24
- end
25
-
26
- def test_should_accept_multiple_colors
27
- meds = Pillboxr.all(:params => { 'color' => ['C48328', 'C48327']})
28
- assert_equal(1, meds.count)
29
- assert_equal('Selfemra 20 MG Oral Capsule', meds.first.rxstring)
30
- end
31
-
32
- def test_should_accept_shape_as_string
33
- meds = Pillboxr.all(:params => {'shape' => 'capsule'})
34
- assert_equal(2345, Pillboxr.record_count)
35
- meds.each { |m| assert_equal('capsule', m.shape.kind_of?(Array) ? m.shape.first.downcase : m.shape.downcase) }
36
- end
37
-
38
- def test_should_accept_color_as_string
39
- meds = Pillboxr.all(:params => {'color' => 'white'})
40
- assert_equal(4364, Pillboxr.record_count)
41
- end
42
-
43
- def test_param_combinations_should_work
44
- meds = Pillboxr.all(:params => {'shape' => 'C48348', 'color' => 'C48325'})
45
- assert_equal(2401, Pillboxr.record_count)
46
- end
47
-
48
- def test_imprint_search_should_work
49
- meds = Pillboxr.all(:params => {'imprint' => 'NVR'})
50
- assert_equal(69, Pillboxr.record_count)
51
- end
52
-
53
- def test_size_search_should_work
54
- meds = Pillboxr.all(:params => {'size' => '12.00'})
55
- assert_equal(3082, Pillboxr.record_count)
56
- end
57
-
58
- def test_should_return_normalized_array_of_strings_for_inactive_ingredients
59
- meds = Pillboxr.all(:params => {:has_image => true})
60
- assert_equal(Array, meds.first.inactive.class)
61
- meds.first.inactive.each do |ing|
62
- assert_no_match(/\s$/, ing)
63
- assert_no_match(/^\s/, ing)
64
- end
65
- assert_equal("SILICON DIOXIDE", meds.first.inactive[1])
66
- end
67
-
68
- def test_should_return_appropriate_dea_schedule
69
- med = Pillboxr.first(:params => {:ingredient => 'Hydromorphone'})
70
- assert_equal('Schedule II', med.dea)
71
- end
72
-
73
- def test_should_allow_searching_for_multiple_active_ingredients
74
- med = Pillboxr.all(:params => {:ingredient => ['amlodipine', 'benazepril']})
75
- assert_equal(28, med.count)
76
- med = Pillboxr.all(:params => {:ingredient => ['valsartan','hydrochlorothiazide', 'amlodipine']})
77
- assert_not_nil(med)
78
- assert_equal(5, med.count)
79
- end
80
-
81
- def test_should_return_a_valid_image_url
82
- meds = Pillboxr.all(:params => {:has_image => 1})
83
- meds.each { |m| assert_equal("http://pillbox.nlm.nih.gov/assets/super_small/#{m.image_id}ss.png", m.image_url)}
84
- end
85
-
86
- def test_should_return_an_array_of_valid_urls
87
- meds = Pillboxr.all(:params => {:has_image => 1})
88
- meds.each do |m|
89
- assert_equal(["http://pillbox.nlm.nih.gov/assets/super_small/#{m.image_id}ss.png",
90
- "http://pillbox.nlm.nih.gov/assets/small/#{m.image_id}sm.jpg",
91
- "http://pillbox.nlm.nih.gov/assets/medium/#{m.image_id}md.jpg",
92
- "http://pillbox.nlm.nih.gov/assets/large/#{m.image_id}lg.jpg"], m.image_url('all'))
93
- end
94
- end
95
-
96
- def test_should_return_a_valid_trade_name
97
- med = Pillboxr.first(:params => {:ingredient => 'Sildenafil'})
98
- assert_equal('Viagra', med.trade_name)
99
- end
100
-
101
- if RUBY_VERSION > '1.9'
102
- def test_should_rescue_rexml_parser_error
103
- assert_nothing_raised { med = Pillboxr.all(:params => {:dea => "a"} ) }
104
- end
105
- end
106
- end
@@ -1,16 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.unshift File.dirname(File.dirname(__FILE__))
3
- require 'test/unit'
4
- require 'lib/pillboxr'
5
-
6
- class Test::Unit::TestCase
7
-
8
- def load_yaml_fixture(path = all_meds.yml)
9
- absolute_path = File.join(File.dirname(__FILE__), "fixtures", path)
10
- YAML::load_file absolute_path
11
- end
12
-
13
- def deny(*args)
14
- args.each { |arg| assert !arg }
15
- end
16
- end