Skip to content

Commit 355cda0

Browse files
committed
Add specs for random name and e-mail methods
Babby's first RSpec. Style is consistent with the rest of the tests.
1 parent 8bd5d10 commit 355cda0

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

spec/lib/rex/text_spec.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,49 @@
7171
end
7272
end
7373

74+
context ".rand_surname" do
75+
it "should return a random surname" do
76+
described_class::Surnames.should include(described_class.rand_surname)
77+
end
78+
end
79+
80+
context ".rand_name" do
81+
it "should return a random name" do
82+
names = described_class::Names_Female + described_class::Names_Male
83+
names.should include(described_class.rand_name)
84+
end
85+
end
86+
87+
context ".rand_name_female" do
88+
it "should return a random female name" do
89+
described_class::Names_Female.should include(described_class.rand_name_female)
90+
end
91+
end
92+
93+
context ".rand_name_male" do
94+
it "should return a random male name" do
95+
described_class::Names_Male.should include(described_class.rand_name_male)
96+
end
97+
end
98+
99+
context ".rand_mail_address" do
100+
it "should return a random mail address" do
101+
names = described_class::Names_Female + described_class::Names_Male
102+
surnames = described_class::Surnames
103+
tlds = described_class::TLDs
104+
105+
# XXX: This is kinda dirty
106+
mail_address = described_class.rand_mail_address.split("@").map { |x| x.split(".") }
107+
name, surname = mail_address.first.first, mail_address.first.last
108+
domain, tld = "example", mail_address.last.last # Poor man's stubbing to preserve TLD
109+
110+
names.should include(name)
111+
surnames.should include(surname)
112+
domain.should eq("example")
113+
tlds.should include(tld)
114+
end
115+
end
116+
74117
end
75118
end
76119

0 commit comments

Comments
 (0)