-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdrugsearch_spec.rb
73 lines (51 loc) · 2.33 KB
/
drugsearch_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
require 'lib/drugsearch' # apparently this runs from the root of the project dir
describe DrugResolver do
it "should resolve 'mefloquine' to a603030" do
DrugResolver.resolve_drug_id('mefloquine').should == "a603030"
end
it "should return nil for real drugs that don't have medline plus drug information" do
DrugResolver.resolve_drug_id('LYSERGIC ACID DIETHYLAMIDE').should be_nil
end
it "should return nil for a non-existent drug" do
DrugResolver.resolve_drug_id('madeup').should be_nil
end
end
describe SideEffectScraper do
before(:all) do
@mefloquine_results = SideEffectScraper.get_side_effects('a603030')
@tylenol_results = SideEffectScraper.get_side_effects('a681004')
@amphotericin_results = SideEffectScraper.get_side_effects('a682643')
@metformin_results = SideEffectScraper.get_side_effects('a696005')
end
it "mefloquine (a603030) should return a hash with a drug name and a set of side effects" do
@mefloquine_results.should have_key(:drug_name)
@mefloquine_results.should have_key(:effect_lists)
end
it "mefloquine (a603030) should return a hash with two sets of side effects" do
@mefloquine_results[:effect_lists].size.should == 2
end
it "mefloquine's two groups of side effects should have different warning sentences" do
sent1 = @mefloquine_results[:effect_lists][0][:warning_sentence]
sent2 = @mefloquine_results[:effect_lists][1][:warning_sentence]
sent1.should_not == sent2
end
it "Amphotericin (a682643) should return a hash with three sets of side effects" do
@amphotericin_results[:effect_lists].size.should == 3
end
it "Metformin should return a hash with SIX sets of effects" do
@metformin_results[:effect_lists].size.should == 6
end
it "tylenol (a681004) should only have one group of side effects" do
@tylenol_results[:effect_lists].size.should == 1
end
it "Metformin should have an \"extra hazard\" flag" do
@metformin_results[:extra_hazard].should_not be_nil
end
# as of 11/2/2009, Tylenol's record DOES have an extra hazard flag.
# it "tylenol should NOT have an \"extra hazard\" flag" do
# @tylenol_results[:extra_hazard].should be_nil
# end
it "should return nil for non-existent medlineplus ids" do
SideEffectScraper.get_side_effects('asdf').should be_nil
end
end