votd 2.2.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,38 +5,51 @@ describe "Votd::Base" do
5
5
 
6
6
  describe ".text" do
7
7
  it "returns the default scripture verse" do
8
- votd.text.should == "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life."
8
+ expect(votd.text).to eq "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life."
9
9
  end
10
10
  end
11
11
 
12
12
  describe ".reference" do
13
13
  it "returns the default scripture reference" do
14
- votd.reference.should == "John 3:16"
14
+ expect(votd.reference).to eq "John 3:16"
15
15
  end
16
16
  end
17
17
 
18
18
  describe ".version / .translation" do
19
19
  it "returns the default bible version" do
20
- votd.translation.should == "KJV"
21
- votd.version.should == "KJV"
20
+ expect(votd.translation).to eq "KJV"
21
+ expect(votd.version).to eq "KJV"
22
+ end
23
+ end
24
+
25
+ describe ".version_name / .translation_name" do
26
+ it "returns the default bible version" do
27
+ expect(votd.translation_name).to eq "King James Version"
28
+ expect(votd.version_name).to eq "King James Version"
29
+ end
30
+ end
31
+
32
+ describe ".link" do
33
+ it 'returns the default link' do
34
+ expect(votd.link).to eq 'https://www.biblegateway.com/passage/?search=John+3%3A16&version=KJV'
22
35
  end
23
36
  end
24
37
 
25
38
  describe ".date" do
26
39
  it "returns the default date" do
27
- votd.date.should == Date.today
40
+ expect(votd.date).to eq Date.today
28
41
  end
29
42
  end
30
43
 
31
44
  describe ".copyright" do
32
45
  it "returns nil copyright information" do
33
- votd.copyright.should be_nil
46
+ expect(votd.copyright).to be_nil
34
47
  end
35
48
  end
36
49
 
37
50
  describe ".to_html" do
38
51
  it "returns a HTML version" do
39
- votd.to_html.should == read_fixture("base/base.html")
52
+ expect(votd.to_html).to eq read_fixture("base/base.html")
40
53
  end
41
54
  end
42
55
 
@@ -46,8 +59,8 @@ describe "Votd::Base" do
46
59
  "<p>#{votd.reference}|#{votd.text}|#{votd.version}</p>"
47
60
  end
48
61
  desired_output = read_fixture("base/base_custom.html")
49
- html_from_block.should == desired_output
50
- votd.to_html.should == desired_output
62
+ expect(html_from_block).to eq desired_output
63
+ expect(votd.to_html).to eq desired_output
51
64
  end
52
65
 
53
66
  it "generates a VotdError when not used with a block" do
@@ -57,11 +70,11 @@ describe "Votd::Base" do
57
70
 
58
71
  describe ".to_text" do
59
72
  it "returns a text-formatted version" do
60
- votd.to_text.should == read_fixture("base/base.txt")
73
+ expect(votd.to_text).to eq read_fixture("base/base.txt")
61
74
  end
62
75
 
63
76
  it "is aliased to .to_s" do
64
- votd.to_s.should == read_fixture("base/base.txt")
77
+ expect(votd.to_s).to eq read_fixture("base/base.txt")
65
78
  end
66
79
  end
67
80
 
@@ -71,8 +84,8 @@ describe "Votd::Base" do
71
84
  "#{votd.reference}|#{votd.text}|#{votd.version}"
72
85
  end
73
86
  desired_output = read_fixture("base/base_custom.txt")
74
- text_from_block.should == desired_output
75
- votd.to_text.should == desired_output
87
+ expect(text_from_block).to eq desired_output
88
+ expect(votd.to_text).to eq desired_output
76
89
  end
77
90
 
78
91
  it "generates a VotdError when not used with a block" do
@@ -2,114 +2,156 @@ require 'spec_helper'
2
2
 
3
3
  describe "Votd::BibleGateway" do
4
4
  let(:votd) { Votd::BibleGateway.new }
5
+ let(:votd_nlt) { Votd::BibleGateway.new(:nlt) }
5
6
 
6
- before do
7
- fake_a_uri(Votd::BibleGateway::URI, "bible_gateway/bible_gateway.rss")
8
- end
7
+ let(:uri_regex) { /#{Votd::BibleGateway::URI}\d*/ }
9
8
 
10
- it "is a type of BibleGateway" do
11
- votd.should be_a(Votd::BibleGateway)
12
- end
9
+ context 'With the default version' do
10
+ before do
11
+ fake_a_uri(uri_regex, "bible_gateway/bible_gateway.rss")
12
+ end
13
13
 
14
- describe ".text" do
15
- it "returns the correct scripture verse" do
16
- votd.text.should == "If we confess our sins, he is faithful and just and will forgive us our sins and purify us from all unrighteousness."
14
+ it "is a type of BibleGateway" do
15
+ expect(votd).to be_a(Votd::BibleGateway)
17
16
  end
18
- end
19
17
 
20
- describe ".reference" do
21
- it "returns the correct scripture reference" do
22
- votd.reference.should == "1 John 1:9"
18
+ describe ".text" do
19
+ it "returns the correct scripture verse" do
20
+ expect(votd.text).to eq "If we confess our sins, he is faithful and just and will forgive us our sins and purify us from all unrighteousness."
21
+ end
23
22
  end
24
- end
25
23
 
26
- describe ".version / .translation" do
27
- it "returns the correct bible version" do
28
- votd.version.should == "NIV"
29
- votd.translation.should == "NIV"
24
+ describe ".reference" do
25
+ it "returns the correct scripture reference" do
26
+ expect(votd.reference).to eq "1 John 1:9"
27
+ end
30
28
  end
31
- end
32
29
 
33
- describe ".date" do
34
- it "returns the correct date" do
35
- votd.date.should == Date.today
30
+ describe ".version / .translation" do
31
+ it "returns the correct bible version" do
32
+ expect(votd.version).to eq "NIV"
33
+ expect(votd.translation).to eq "NIV"
34
+ end
36
35
  end
37
- end
38
36
 
39
- describe ".copyright" do
40
- it "returns copyright information" do
41
- votd.copyright.should == "Brought to you by BibleGateway.com. Copyright (C) . All Rights Reserved."
37
+ describe ".version_name / .translation_name" do
38
+ it "returns the correct bible version name" do
39
+ expect(votd.version_name).to eq "New International Version"
40
+ expect(votd.translation_name).to eq "New International Version"
41
+ end
42
42
  end
43
- end
44
43
 
45
- describe ".to_html" do
46
- it "returns a HTML version" do
47
- votd.to_html.should == read_fixture("bible_gateway/bible_gateway.html")
44
+ describe ".date" do
45
+ it "returns the correct date" do
46
+ expect(votd.date).to eq Date.today
47
+ end
48
48
  end
49
- end
50
49
 
51
- describe ".custom_html" do
52
- it "overrides the default .to_html formatting" do
53
- votd.custom_html do |votd|
54
- "<p>#{votd.reference}|#{votd.text}|#{votd.version}</p>"
50
+ describe ".copyright" do
51
+ it "returns copyright information" do
52
+ expect(votd.copyright).to eq "Brought to you by BibleGateway.com. Copyright (C) . All Rights Reserved."
55
53
  end
56
- votd.to_html.should == read_fixture("bible_gateway/bible_gateway_custom.html")
57
54
  end
58
55
 
59
- it "generates a VotdError when not used with a block" do
60
- expect{votd.custom_html}.to raise_error(Votd::VotdError)
56
+ describe ".link" do
57
+ it 'returns the link' do
58
+ expect(votd.link).to eq 'http://www.biblegateway.com/passage/?search=1+John+1%3A9&version=NIV'
59
+ end
61
60
  end
62
- end
63
61
 
64
- describe ".to_text" do
65
- it "returns a text-formatted version" do
66
- votd.to_text.should == read_fixture("bible_gateway/bible_gateway.txt")
62
+ describe ".to_html" do
63
+ it "returns a HTML version" do
64
+ expect(votd.to_html).to eq read_fixture("bible_gateway/bible_gateway.html")
65
+ end
67
66
  end
68
67
 
69
- it "is aliased to .to_s" do
70
- votd.to_s.should == read_fixture("bible_gateway/bible_gateway.txt")
68
+ describe ".custom_html" do
69
+ it "overrides the default .to_html formatting" do
70
+ votd.custom_html do |votd|
71
+ "<p>#{votd.reference}|#{votd.text}|#{votd.version}</p>"
72
+ end
73
+ expect(votd.to_html).to eq read_fixture("bible_gateway/bible_gateway_custom.html")
74
+ end
75
+
76
+ it "generates a VotdError when not used with a block" do
77
+ expect{votd.custom_html}.to raise_error(Votd::VotdError)
78
+ end
71
79
  end
72
- end
73
80
 
74
- describe ".custom_text" do
75
- it "overrides the default.to_text formatting" do
76
- text_from_block = votd.custom_text do |votd|
77
- "#{votd.reference}|#{votd.text}|#{votd.version}"
81
+ describe ".to_text" do
82
+ it "returns a text-formatted version" do
83
+ expect(votd.to_text).to eq read_fixture("bible_gateway/bible_gateway.txt")
84
+ end
85
+
86
+ it "is aliased to .to_s" do
87
+ expect(votd.to_s).to eq read_fixture("bible_gateway/bible_gateway.txt")
78
88
  end
79
- desired_output = read_fixture("bible_gateway/bible_gateway_custom.txt")
80
- text_from_block.should == desired_output
81
- votd.to_text.should == desired_output
82
89
  end
83
90
 
84
- it "generates a VotdError when not used with a block" do
85
- expect{votd.custom_text}.to raise_error(Votd::VotdError)
91
+ describe ".custom_text" do
92
+ it "overrides the default.to_text formatting" do
93
+ text_from_block = votd.custom_text do |votd|
94
+ "#{votd.reference}|#{votd.text}|#{votd.version}"
95
+ end
96
+ desired_output = read_fixture("bible_gateway/bible_gateway_custom.txt")
97
+ expect(text_from_block).to eq desired_output
98
+ expect(votd.to_text).to eq desired_output
99
+ end
100
+
101
+ it "generates a VotdError when not used with a block" do
102
+ expect{votd.custom_text}.to raise_error(Votd::VotdError)
103
+ end
86
104
  end
87
105
  end
88
106
 
89
107
  context "When an error occurrs" do
90
108
  before do
91
- fake_a_broken_uri(Votd::BibleGateway::URI)
109
+ fake_a_broken_uri(uri_regex)
92
110
  end
93
111
 
94
112
  it "falls back to default VotD values" do
95
- votd.version.should == Votd::Base::DEFAULT_BIBLE_VERSION
96
- votd.reference.should == Votd::Base::DEFAULT_BIBLE_REFERENCE
97
- votd.text.should == Votd::Base::DEFAULT_BIBLE_TEXT
113
+ expect(votd.version).to eq Votd::Base::DEFAULT_BIBLE_VERSION
114
+ expect(votd.reference).to eq Votd::Base::DEFAULT_BIBLE_REFERENCE
115
+ expect(votd.text).to eq Votd::Base::DEFAULT_BIBLE_TEXT
98
116
  end
99
117
  end
100
118
 
101
119
  context "When the text is not a proper sentence" do
102
120
  before do
103
- fake_a_uri(Votd::BibleGateway::URI, "bible_gateway/bible_gateway_with_partial.rss")
121
+ fake_a_uri(uri_regex, "bible_gateway/bible_gateway_with_partial.rss")
104
122
  end
105
123
 
106
124
  it "prepends an ellipsis if first letter is not a capital letter" do
107
- votd.text.should =~ /^\.{3}\w/
125
+ expect(votd.text).to match /^\.{3}\w/
108
126
  end
109
127
 
110
128
  it "appends an ellipsis if last character is not a period" do
111
- votd.text.should =~ /ness\.{3}$/
129
+ expect(votd.text).to match /ness\.{3}$/
112
130
  end
113
131
  end
114
132
 
133
+ context 'When specifying a version' do
134
+ before do
135
+ fake_a_uri("#{Votd::BibleGateway::URI}#{51}", 'bible_gateway/bible_gateway_nlt.rss')
136
+ end
137
+
138
+ describe ".text" do
139
+ it "returns the correct scripture verse" do
140
+ expect(votd_nlt.text).to eq "Let the message about Christ, in all its richness, fill your lives. Teach and counsel each other with all the wisdom he gives. Sing psalms and hymns and spiritual songs to God with thankful hearts."
141
+ end
142
+
143
+ it 'returns the correct version info' do
144
+ expect(votd_nlt.version).to eq 'NLT'
145
+ expect(votd_nlt.version_name).to eq 'New Living Translation'
146
+ end
147
+
148
+ it "returns copyright information" do
149
+ expect(votd_nlt.copyright).to eq "Brought to you by BibleGateway.com. Copyright (C) NLT. All Rights Reserved."
150
+ end
151
+
152
+ it 'returns the link' do
153
+ expect(votd_nlt.link).to eq 'https://www.biblegateway.com/passage/?search=Colossians+3%3A16&version=51'
154
+ end
155
+ end
156
+ end
115
157
  end
@@ -2,114 +2,126 @@ require 'spec_helper'
2
2
 
3
3
  describe "Votd::ESVBible" do
4
4
  let(:votd) { Votd::ESVBible.new }
5
-
5
+
6
6
  before do
7
7
  fake_a_uri(Votd::ESVBible::URI, "esvbible/esvbible.rss")
8
8
  end
9
-
9
+
10
10
  it "is a type of ESVBible" do
11
- votd.should be_a(Votd::ESVBible)
11
+ expect(votd).to be_a(Votd::ESVBible)
12
12
  end
13
-
13
+
14
14
  describe ".text" do
15
15
  it "returns the correct scripture verse" do
16
- votd.text.should == "For you did not receive the spirit of slavery to fall back into fear, but you have received the Spirit of adoption as sons, by whom we cry, \"Abba! Father!\""
16
+ expect(votd.text).to eq "For you did not receive the spirit of slavery to fall back into fear, but you have received the Spirit of adoption as sons, by whom we cry, \"Abba! Father!\""
17
17
  end
18
18
  end
19
-
19
+
20
20
  describe ".reference" do
21
21
  it "returns the correct scripture reference" do
22
- votd.reference.should == "Romans 8:15"
22
+ expect(votd.reference).to eq "Romans 8:15"
23
23
  end
24
24
  end
25
-
25
+
26
26
  describe ".version / .translation" do
27
27
  it "returns the correct bible version" do
28
- votd.version.should == "ESV"
29
- votd.translation.should == "ESV"
28
+ expect(votd.version).to eq "ESV"
29
+ expect(votd.translation).to eq "ESV"
30
+ end
31
+ end
32
+
33
+ describe ".version_name / .translation_name" do
34
+ it "returns the correct bible version" do
35
+ expect(votd.version_name).to eq "English Standard Version"
36
+ expect(votd.translation_name).to eq "English Standard Version"
30
37
  end
31
38
  end
32
-
39
+
33
40
  describe ".date" do
34
41
  it "returns the correct date" do
35
- votd.date.should == Date.today
42
+ expect(votd.date).to eq Date.today
36
43
  end
37
44
  end
38
-
45
+
39
46
  describe ".copyright" do
40
47
  it "returns copyright information" do
41
- votd.copyright.should == "The Holy Bible, English Standard Version copyright 2001 by Crossway Bibles, a publishing ministry of Good News Publishers. Used by permission. All rights reserved."
48
+ expect(votd.copyright).to eq "The Holy Bible, English Standard Version copyright 2001 by Crossway Bibles, a publishing ministry of Good News Publishers. Used by permission. All rights reserved."
49
+ end
50
+ end
51
+
52
+ describe ".link" do
53
+ it 'returns the link' do
54
+ expect(votd.link).to eq 'http://www.gnpcb.org/esv/search/?passage=Romans+8%3A15&date=20131029'
42
55
  end
43
56
  end
44
-
57
+
45
58
  describe ".to_html" do
46
59
  it "returns a HTML version" do
47
- votd.to_html.should == read_fixture("esvbible/esvbible.html")
60
+ expect(votd.to_html).to eq read_fixture("esvbible/esvbible.html")
48
61
  end
49
62
  end
50
-
63
+
51
64
  describe ".custom_html" do
52
65
  it "overrides the default .to_html formatting" do
53
66
  votd.custom_html do |votd|
54
67
  "<p>#{votd.reference}|#{votd.text}|#{votd.version}</p>"
55
68
  end
56
- votd.to_html.should == read_fixture("esvbible/esvbible_custom.html")
69
+ expect(votd.to_html).to eq read_fixture("esvbible/esvbible_custom.html")
57
70
  end
58
-
71
+
59
72
  it "generates a VotdError when not used with a block" do
60
- expect{votd.custom_html}.to raise_error(Votd::VotdError)
73
+ expect{ votd.custom_html }.to raise_error(Votd::VotdError)
61
74
  end
62
75
  end
63
-
76
+
64
77
  describe ".to_text" do
65
78
  it "returns a text-formatted version" do
66
- votd.to_text.should == read_fixture("esvbible/esvbible.txt")
79
+ expect(votd.to_text).to eq read_fixture("esvbible/esvbible.txt")
67
80
  end
68
-
81
+
69
82
  it "is aliased to .to_s" do
70
- votd.to_s.should == read_fixture("esvbible/esvbible.txt")
83
+ expect(votd.to_s).to eq read_fixture("esvbible/esvbible.txt")
71
84
  end
72
85
  end
73
-
86
+
74
87
  describe ".custom_text" do
75
88
  it "overrides the default .to_text formatting" do
76
89
  text_from_block = votd.custom_text do |votd|
77
90
  "#{votd.reference}|#{votd.text}|#{votd.version}"
78
91
  end
79
92
  desired_output = read_fixture("esvbible/esvbible_custom.txt")
80
- text_from_block.should == desired_output
81
- votd.to_text.should == desired_output
93
+ expect(text_from_block).to eq desired_output
94
+ expect(votd.to_text).to eq desired_output
82
95
  end
83
-
96
+
84
97
  it "generates a VotdError when not used with a block" do
85
- expect{votd.custom_text}.to raise_error(Votd::VotdError)
98
+ expect{ votd.custom_text }.to raise_error(Votd::VotdError)
86
99
  end
87
100
  end
88
-
101
+
89
102
  context "When an error occurs" do
90
103
  before do
91
104
  fake_a_broken_uri(Votd::ESVBible::URI)
92
105
  end
93
-
106
+
94
107
  it "falls back to default VotD values" do
95
- votd.version.should == Votd::Base::DEFAULT_BIBLE_VERSION
96
- votd.reference.should == Votd::Base::DEFAULT_BIBLE_REFERENCE
97
- votd.text.should == Votd::Base::DEFAULT_BIBLE_TEXT
108
+ expect(votd.version).to eq Votd::Base::DEFAULT_BIBLE_VERSION
109
+ expect(votd.reference).to eq Votd::Base::DEFAULT_BIBLE_REFERENCE
110
+ expect(votd.text).to eq Votd::Base::DEFAULT_BIBLE_TEXT
98
111
  end
99
112
  end
100
-
113
+
101
114
  context "When the text is not a proper sentence" do
102
115
  before do
103
116
  fake_a_uri(Votd::ESVBible::URI, "esvbible/esvbible_with_partial.rss")
104
117
  end
105
-
118
+
106
119
  it "prepends an ellipsis if first letter is not a capital letter" do
107
- votd.text.should =~ /^\.{3}\w/
120
+ expect(votd.text).to match /^\.{3}\w/
108
121
  end
109
-
122
+
110
123
  it "appends an ellipsis if last character is a letter, a comma or a semicolon" do
111
- votd.text.should =~ /\w\.{3}$/
124
+ expect(votd.text).to match /\w\.{3}$/
112
125
  end
113
126
  end
114
-
115
127
  end
@@ -6,7 +6,8 @@ include Votd::Helper::CommandLine
6
6
  describe Votd::Helper::CommandLine do
7
7
  describe "#banner" do
8
8
  it "prints a banner wrapped at the correct location" do
9
- $stdout.should_receive(:puts).with("======\n foo \n======")
9
+ #$stdout.should_receive(:puts).with("======\n foo \n======")
10
+ expect($stdout).to receive(:puts).with("======\n foo \n======")
10
11
  banner("foo", 6)
11
12
  end
12
13
  end
@@ -14,7 +15,7 @@ describe Votd::Helper::CommandLine do
14
15
  describe "#word_wrap" do
15
16
  it "wraps text at the specified column" do
16
17
  text = "The quick brown fox jumps over the lazy dog."
17
- word_wrap(text, 20).should == "The quick brown fox\njumps over the lazy\ndog."
18
+ expect(word_wrap(text, 20)).to eq "The quick brown fox\njumps over the lazy\ndog."
18
19
  end
19
20
  end
20
21
  end
@@ -6,26 +6,26 @@ describe Votd::Helper::Text do
6
6
  describe ".strip_html_tags" do
7
7
  it "removes HTML tags from a given string" do
8
8
  text = %q[<p>The <span name="foo">quick</span> brown fox.</p><br />]
9
- strip_html_tags(text).should == "The quick brown fox."
9
+ expect(strip_html_tags(text)).to eq "The quick brown fox."
10
10
  end
11
11
  end
12
12
 
13
13
  describe ".clean_verse_start" do
14
14
  it "prepends '...' if the first letter is not a capital letter" do
15
15
  text = "for God so loved"
16
- clean_verse_start(text).should == "...for God so loved"
16
+ expect(clean_verse_start(text)).to eq "...for God so loved"
17
17
  end
18
18
  end
19
19
 
20
20
  describe ".clean_verse_end" do
21
21
  it "appends '...' if the verse ends without a period" do
22
22
  text = "For God so loved"
23
- clean_verse_end(text).should == "For God so loved..."
23
+ expect(clean_verse_end(text)).to eq "For God so loved..."
24
24
  end
25
25
 
26
26
  it "appends '...' if the verse ends in a ',' or ';'" do
27
- ["loved,", "loved;"].each do |text|
28
- clean_verse_end(text).should == "loved..."
27
+ ["loved,", "loved;"].each do |text|
28
+ expect(clean_verse_end(text)).to eq "loved..."
29
29
  end
30
30
  end
31
31
  end