simple2ch 0.1.1 → 0.1.2

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.
data/spec/res_spec.rb CHANGED
@@ -67,13 +67,13 @@ describe Simple2ch::Res do
67
67
  it_behaves_like 'have valid anchors'
68
68
  end
69
69
  context 'when it have range and separated anchors pattern#1' do
70
- let(:contents){%Q{>1-5,6,8}}
71
- let(:anchor) {[1,2,3,4,5,6,8]}
70
+ let(:contents) { %Q{>1-5,6,8} }
71
+ let(:anchor) { [1, 2, 3, 4, 5, 6, 8] }
72
72
  it_behaves_like 'have valid anchors'
73
73
  end
74
74
  context 'when it have range and separated anchors pattern#2' do
75
- let(:contents){%Q{>1,3, 9−13\n25}}
76
- let(:anchor) {[1,3,9,10,11,12,13]}
75
+ let(:contents) { %Q{>1,3, 9−13\n25} }
76
+ let(:anchor) { [1, 3, 9, 10, 11, 12, 13] }
77
77
  it_behaves_like 'have valid anchors'
78
78
  end
79
79
  context 'when it have ARASHI anchors' do
@@ -95,4 +95,19 @@ describe Simple2ch::Res do
95
95
  it_behaves_like 'have valid anchors'
96
96
  end
97
97
  end
98
+
99
+ describe '#recepted_anchors' do
100
+ let(:board_name) { 'ニュー速VIP' }
101
+ let(:url) { 'http://viper.2ch.sc/news4vip/' }
102
+ let(:thread_key) { '1409796283' }
103
+ let(:board) { Board.new board_name, url }
104
+ let(:thre) { Thre.new board, thread_key }
105
+ let(:res) { thre.reses([40])[0] }
106
+ let(:input_thre) { res.thre = thre}
107
+ subject{ input_thre; res.received_anchors }
108
+ it { is_expected.to be_a_kind_of Array }
109
+ its(:size) { is_expected.to be == 4 }
110
+ it { is_expected.to be == [43, 44, 45, 54] }
111
+ end
112
+
98
113
  end
data/spec/thre_spec.rb CHANGED
@@ -6,32 +6,55 @@ describe Simple2ch::Thre do
6
6
  let(:dat_data) { '1409796283.dat<>C言語の勉強始めたんだがな (144)' }
7
7
  let(:thre) { Simple2ch::Thre.parse(board, dat_data) }
8
8
 
9
- context 'should have title' do
9
+ describe 'should have title' do
10
10
  subject { thre.title }
11
11
  it { is_expected.to be_a_kind_of(String) }
12
12
  end
13
13
 
14
- context 'should have thread key' do
14
+ describe 'should have thread key' do
15
15
  subject { thre.thread_key }
16
16
  it { is_expected.to be_a_kind_of(String) }
17
17
  it { is_expected.to match /\d{10}/ }
18
18
  end
19
19
 
20
- context 'should have numbers of responses' do
20
+ describe 'should have numbers of responses' do
21
21
  subject { thre.num_of_response }
22
22
  it { is_expected.to be_a_kind_of(Fixnum) }
23
23
  it { is_expected.to be > 0 }
24
24
  end
25
25
 
26
- context 'should have responses' do
26
+ describe 'should have responses' do
27
27
  subject { thre.reses }
28
28
  it { is_expected.to be_a_kind_of(Array) }
29
29
  it { subject.each{ |r| expect(r).to be_a_kind_of(Simple2ch::Res) } }
30
30
  its(:size) { is_expected.to be > 0 }
31
31
  end
32
32
 
33
- context 'should have if Kako log' do
33
+ describe 'should have if Kako log' do
34
34
  subject { thre.kako_log? }
35
35
  it { is_expected.to be_truthy }
36
36
  end
37
+
38
+ describe '#reses' do
39
+ shared_examples 'have specified reses' do
40
+ subject{thre.reses(specified_reses)}
41
+ it{is_expected.to be_a_kind_of Array}
42
+ its(:size){is_expected.to be == size}
43
+ end
44
+ context 'when without res_num' do
45
+ let(:size){144}
46
+ let(:specified_reses){nil}
47
+ it_behaves_like 'have specified reses'
48
+ end
49
+
50
+ context 'when with res_num' do
51
+ let(:size){3}
52
+ let(:specified_reses){[1,2,10]}
53
+ it_behaves_like 'have specified reses'
54
+ it{
55
+ extracted_reses = thre.reses(specified_reses)
56
+ expect(extracted_reses[2]).to be == thre.reses.find{|r| r.res_num==10}
57
+ }
58
+ end
59
+ end
37
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple2ch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - dogwood008
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-12 00:00:00.000000000 Z
11
+ date: 2014-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -112,6 +112,7 @@ files:
112
112
  - doc/Simple2ch/Dat.html
113
113
  - doc/Simple2ch/DatParseException.html
114
114
  - doc/Simple2ch/KakoLogException.html
115
+ - doc/Simple2ch/NoThreGivenException.html
115
116
  - doc/Simple2ch/NotA2chUrlException.html
116
117
  - doc/Simple2ch/Res.html
117
118
  - doc/Simple2ch/Simple2chException.html