netprint 0.1.0 → 0.3.3

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.
@@ -7,8 +7,20 @@ describe Agent do
7
7
  before do
8
8
  @agent = Agent.new('user_id', 'password')
9
9
 
10
- stub_request(:get, 'https://www.printing.ne.jp/cgi-bin/mn.cgi?i=user_id&p=password').
11
- to_return(open(File.expand_path(File.dirname(__FILE__) + '/../list.html')).read)
10
+ stub_request(:get, 'https://www.printing.ne.jp/usr/web/NPCM0010.seam').
11
+ to_return(read_fixture_file('login.html'))
12
+
13
+ stub_request(:post, 'https://www.printing.ne.jp/usr/web/NPCM0010.seam').
14
+ with(body: {
15
+ 'NPCM0010' => 'NPCM0010',
16
+ 'NPCM0010:login-btn' => 'ログイン',
17
+ 'NPCM0010:userIdOrMailads-txt' => 'user_id',
18
+ 'NPCM0010:password-pwd' => 'password',
19
+ 'controlParamKey' => 'foo',
20
+ 'javax.faces.ViewState' => 'bar'
21
+ }
22
+ ).
23
+ to_return(read_fixture_file('list_empty.html'))
12
24
  end
13
25
 
14
26
  it 'should login' do
@@ -21,12 +33,30 @@ describe Agent do
21
33
 
22
34
  shared_examples_for '#upload' do
23
35
  it 'should upload' do
24
- stub_request(:get, 'https://www.printing.ne.jp/cgi-bin/mn.cgi?c=0&m=1&s=qwertyuiopoiuytrewq').
25
- to_return(open(File.expand_path(File.dirname(__FILE__) + '/../upload.html')).read)
26
- stub_request(:post, 'https://www.printing.ne.jp/cgi-bin/mn.cgi?c=0&m=1&s=qwertyuiopoiuytrewq').
27
- to_return(open(File.expand_path(File.dirname(__FILE__) + '/../list.html')).read)
28
- stub_request(:get, 'https://www.printing.ne.jp/cgi-bin/mn.cgi?c=0&m=0&s=qwertyuiopoiuytrewq').
29
- to_return(open(File.expand_path(File.dirname(__FILE__) + '/../list.html')).read)
36
+ stub_request(:post, 'https://www.printing.ne.jp/usr/web/auth/NPFL0010.seam').
37
+ with(body: {
38
+ 'NPFL0010' => 'NPFL0010',
39
+ 'display-max-rows' => '10',
40
+ 'create-document' => '',
41
+ 'controlParamKey' => 'xxx',
42
+ 'javax.faces.ViewState' => 'yyy'
43
+ }
44
+ ).
45
+ to_return(read_fixture_file('upload.html'))
46
+
47
+ stub_request(:post, 'https://www.printing.ne.jp/usr/web/auth/NPFL0020.seam').
48
+ to_return(read_fixture_file('list_processing.html'))
49
+
50
+ stub_request(:post, 'https://www.printing.ne.jp/usr/web/auth/NPFL0010.seam').
51
+ with(body: {
52
+ 'NPFL0010' => 'NPFL0010',
53
+ 'display-max-rows' => '10',
54
+ 'reload' => '',
55
+ 'controlParamKey' => 'xxx',
56
+ 'javax.faces.ViewState' => 'yyy'
57
+ }
58
+ ).
59
+ to_return(read_fixture_file('list_processed.html'))
30
60
 
31
61
  filename = File.expand_path(pdf_filename)
32
62
  @agent.login
@@ -36,12 +66,30 @@ describe Agent do
36
66
  end
37
67
 
38
68
  it 'should handle registration error' do
39
- stub_request(:get, 'https://www.printing.ne.jp/cgi-bin/mn.cgi?c=0&m=1&s=qwertyuiopoiuytrewq').
40
- to_return(open(File.expand_path(File.dirname(__FILE__) + '/../upload.html')).read)
41
- stub_request(:post, 'https://www.printing.ne.jp/cgi-bin/mn.cgi?c=0&m=1&s=qwertyuiopoiuytrewq').
42
- to_return(open(File.expand_path(File.dirname(__FILE__) + '/../list.html')).read)
43
- stub_request(:get, 'https://www.printing.ne.jp/cgi-bin/mn.cgi?c=0&m=0&s=qwertyuiopoiuytrewq').
44
- to_return(open(File.expand_path(File.dirname(__FILE__) + '/../error.html')).read)
69
+ stub_request(:post, 'https://www.printing.ne.jp/usr/web/auth/NPFL0010.seam').
70
+ with(body: {
71
+ 'NPFL0010' => 'NPFL0010',
72
+ 'display-max-rows' => '10',
73
+ 'create-document' => '',
74
+ 'controlParamKey' => 'xxx',
75
+ 'javax.faces.ViewState' => 'yyy'
76
+ }
77
+ ).
78
+ to_return(read_fixture_file('upload.html'))
79
+
80
+ stub_request(:post, 'https://www.printing.ne.jp/usr/web/auth/NPFL0020.seam').
81
+ to_return(read_fixture_file('list_processing.html'))
82
+
83
+ stub_request(:post, 'https://www.printing.ne.jp/usr/web/auth/NPFL0010.seam').
84
+ with(body: {
85
+ 'NPFL0010' => 'NPFL0010',
86
+ 'display-max-rows' => '10',
87
+ 'reload' => '',
88
+ 'controlParamKey' => 'xxx',
89
+ 'javax.faces.ViewState' => 'yyy'
90
+ }
91
+ ).
92
+ to_return(read_fixture_file('list_error.html'))
45
93
 
46
94
  filename = File.expand_path(pdf_filename)
47
95
  @agent.login
@@ -50,16 +98,39 @@ describe Agent do
50
98
  @agent.upload(filename)
51
99
  }.should raise_error(RegistrationError)
52
100
  end
101
+
102
+ it 'should handle upload error' do
103
+ stub_request(:post, 'https://www.printing.ne.jp/usr/web/auth/NPFL0010.seam').
104
+ with(body: {
105
+ 'NPFL0010' => 'NPFL0010',
106
+ 'display-max-rows' => '10',
107
+ 'create-document' => '',
108
+ 'controlParamKey' => 'xxx',
109
+ 'javax.faces.ViewState' => 'yyy'
110
+ }
111
+ ).
112
+ to_return(read_fixture_file('upload.html'))
113
+
114
+ stub_request(:post, 'https://www.printing.ne.jp/usr/web/auth/NPFL0020.seam').
115
+ to_return(read_fixture_file('upload_error.html'))
116
+
117
+ filename = File.expand_path(pdf_filename)
118
+ @agent.login
119
+
120
+ lambda {
121
+ @agent.upload(filename)
122
+ }.should raise_error(UploadError, 'error message')
123
+ end
53
124
  end
54
125
 
55
126
  context 'filename is ASCII only' do
56
- let(:pdf_filename) { File.dirname(__FILE__) + '/../foo.pdf' }
127
+ let(:pdf_filename) { fixture_file('foo.pdf') }
57
128
 
58
129
  it_should_behave_like '#upload'
59
130
  end
60
131
 
61
132
  context 'filename has non-ASCII characters' do
62
- let(:pdf_filename) { File.dirname(__FILE__) + '/../あいうえお.pdf' }
133
+ let(:pdf_filename) { fixture_file('あいうえお.pdf') }
63
134
 
64
135
  it_should_behave_like '#upload'
65
136
  end
@@ -13,11 +13,11 @@ describe Options do
13
13
  context 'default' do
14
14
  it do
15
15
  form = Object.new
16
- form.should be_checked('papersize', PAPERSIZE::A4)
17
- form.should be_checked('color', COLOR::BW)
18
- form.should be_checked('number', CODE_TYPE::ALNUM)
19
- form.should be_checked('secretcodesw', '0')
20
- form.should be_checked('mailsw', '0')
16
+ form.should be_checked('yus-size', PAPERSIZE::A4)
17
+ form.should be_checked('iro-cl', COLOR::BW)
18
+ form.should be_checked('yyk-type-cl', CODE_TYPE::ALNUM)
19
+ form.should be_checked('pin-num-set-fl', '0')
20
+ form.should be_checked('notice-onoff', '0')
21
21
 
22
22
  form.should_not_receive(:[]=)
23
23
 
@@ -30,13 +30,13 @@ describe Options do
30
30
 
31
31
  it do
32
32
  form = Object.new
33
- form.should be_checked('papersize', PAPERSIZE::A4)
34
- form.should be_checked('color', COLOR::BW)
35
- form.should be_checked('number', CODE_TYPE::ALNUM)
36
- form.should be_checked('secretcodesw', '1')
37
- form.should be_checked('mailsw', '0')
33
+ form.should be_checked('yus-size', PAPERSIZE::A4)
34
+ form.should be_checked('iro-cl', COLOR::BW)
35
+ form.should be_checked('yyk-type-cl', CODE_TYPE::ALNUM)
36
+ form.should be_checked('pin-num-set-fl', '1')
37
+ form.should be_checked('notice-onoff', '0')
38
38
 
39
- form.should_receive(:[]=).with('secretcode', '0123')
39
+ form.should_receive(:[]=).with('pin-no', '0123')
40
40
 
41
41
  subject.apply(form)
42
42
  end
@@ -47,13 +47,13 @@ describe Options do
47
47
 
48
48
  it do
49
49
  form = Object.new
50
- form.should be_checked('papersize', PAPERSIZE::A4)
51
- form.should be_checked('color', COLOR::BW)
52
- form.should be_checked('number', CODE_TYPE::ALNUM)
53
- form.should be_checked('secretcodesw', '0')
54
- form.should be_checked('mailsw', '1')
50
+ form.should be_checked('yus-size', PAPERSIZE::A4)
51
+ form.should be_checked('iro-cl', COLOR::BW)
52
+ form.should be_checked('yyk-type-cl', CODE_TYPE::ALNUM)
53
+ form.should be_checked('pin-num-set-fl', '0')
54
+ form.should be_checked('notice-onoff', '1')
55
55
 
56
- form.should_receive(:[]=).with('mailaddr', 'test@example.com')
56
+ form.should_receive(:[]=).with('mail-adr-to-tx', 'test@example.com')
57
57
 
58
58
  subject.apply(form)
59
59
  end
@@ -64,11 +64,11 @@ describe Options do
64
64
 
65
65
  it do
66
66
  form = Object.new
67
- form.should be_checked('papersize', PAPERSIZE::B4)
68
- form.should be_checked('color', COLOR::BW)
69
- form.should be_checked('number', CODE_TYPE::ALNUM)
70
- form.should be_checked('secretcodesw', '0')
71
- form.should be_checked('mailsw', '0')
67
+ form.should be_checked('yus-size', PAPERSIZE::B4)
68
+ form.should be_checked('iro-cl', COLOR::BW)
69
+ form.should be_checked('yyk-type-cl', CODE_TYPE::ALNUM)
70
+ form.should be_checked('pin-num-set-fl', '0')
71
+ form.should be_checked('notice-onoff', '0')
72
72
 
73
73
  form.should_not_receive(:[]=)
74
74
 
@@ -81,11 +81,11 @@ describe Options do
81
81
 
82
82
  it do
83
83
  form = Object.new
84
- form.should be_checked('papersize', PAPERSIZE::A4)
85
- form.should be_checked('color', COLOR::COLOR)
86
- form.should be_checked('number', CODE_TYPE::ALNUM)
87
- form.should be_checked('secretcodesw', '0')
88
- form.should be_checked('mailsw', '0')
84
+ form.should be_checked('yus-size', PAPERSIZE::A4)
85
+ form.should be_checked('iro-cl', COLOR::COLOR)
86
+ form.should be_checked('yyk-type-cl', CODE_TYPE::ALNUM)
87
+ form.should be_checked('pin-num-set-fl', '0')
88
+ form.should be_checked('notice-onoff', '0')
89
89
 
90
90
  form.should_not_receive(:[]=)
91
91
 
@@ -98,11 +98,11 @@ describe Options do
98
98
 
99
99
  it do
100
100
  form = Object.new
101
- form.should be_checked('papersize', PAPERSIZE::A4)
102
- form.should be_checked('color', COLOR::BW)
103
- form.should be_checked('number', CODE_TYPE::NUM)
104
- form.should be_checked('secretcodesw', '0')
105
- form.should be_checked('mailsw', '0')
101
+ form.should be_checked('yus-size', PAPERSIZE::A4)
102
+ form.should be_checked('iro-cl', COLOR::BW)
103
+ form.should be_checked('yyk-type-cl', CODE_TYPE::NUM)
104
+ form.should be_checked('pin-num-set-fl', '0')
105
+ form.should be_checked('notice-onoff', '0')
106
106
 
107
107
  form.should_not_receive(:[]=)
108
108
 
@@ -123,14 +123,14 @@ describe Options do
123
123
 
124
124
  it do
125
125
  form = Object.new
126
- form.should be_checked('papersize', PAPERSIZE::B5)
127
- form.should be_checked('color', COLOR::SELECT_WHEN_PRINT)
128
- form.should be_checked('number', CODE_TYPE::NUM)
129
- form.should be_checked('secretcodesw', '1')
130
- form.should be_checked('mailsw', '1')
131
-
132
- form.should_receive(:[]=).with('secretcode', '0987')
133
- form.should_receive(:[]=).with('mailaddr', 'foo@example.com')
126
+ form.should be_checked('yus-size', PAPERSIZE::B5)
127
+ form.should be_checked('iro-cl', COLOR::SELECT_WHEN_PRINT)
128
+ form.should be_checked('yyk-type-cl', CODE_TYPE::NUM)
129
+ form.should be_checked('pin-num-set-fl', '1')
130
+ form.should be_checked('notice-onoff', '1')
131
+
132
+ form.should_receive(:[]=).with('pin-no', '0987')
133
+ form.should_receive(:[]=).with('mail-adr-to-tx', 'foo@example.com')
134
134
 
135
135
  subject.apply(form)
136
136
  end
@@ -18,6 +18,14 @@ RSpec.configure do |config|
18
18
  # the seed, which is printed after each run.
19
19
  # --seed 1234
20
20
  config.order = 'random'
21
+
22
+ def fixture_file(name)
23
+ File.expand_path(File.dirname(__FILE__) + '/fixtures/' + name)
24
+ end
25
+
26
+ def read_fixture_file(name)
27
+ open(fixture_file(name)).read
28
+ end
21
29
  end
22
30
 
23
31
  RSpec::Matchers.define :be_checked do |name, value|
metadata CHANGED
@@ -1,84 +1,60 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netprint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.3.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - youpy
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-12-05 00:00:00.000000000 Z
11
+ date: 2020-08-26 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: 2.8.0
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: 2.8.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - "<"
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: netprint
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
33
+ version: '11.0'
54
34
  type: :development
55
35
  prerelease: false
56
36
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
37
  requirements:
59
- - - ! '>='
38
+ - - "<"
60
39
  - !ruby/object:Gem::Version
61
- version: '0'
40
+ version: '11.0'
62
41
  - !ruby/object:Gem::Dependency
63
42
  name: webmock
64
43
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
44
  requirements:
67
- - - ! '>='
45
+ - - ">="
68
46
  - !ruby/object:Gem::Version
69
47
  version: '0'
70
48
  type: :development
71
49
  prerelease: false
72
50
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
51
  requirements:
75
- - - ! '>='
52
+ - - ">="
76
53
  - !ruby/object:Gem::Version
77
54
  version: '0'
78
55
  - !ruby/object:Gem::Dependency
79
56
  name: mechanize
80
57
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
58
  requirements:
83
59
  - - '='
84
60
  - !ruby/object:Gem::Version
@@ -86,41 +62,22 @@ dependencies:
86
62
  type: :runtime
87
63
  prerelease: false
88
64
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
65
  requirements:
91
66
  - - '='
92
67
  - !ruby/object:Gem::Version
93
68
  version: 2.7.0
94
- - !ruby/object:Gem::Dependency
95
- name: addressable
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
102
- type: :runtime
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
69
  - !ruby/object:Gem::Dependency
111
70
  name: docopt
112
71
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
72
  requirements:
115
- - - ! '>='
73
+ - - ">="
116
74
  - !ruby/object:Gem::Version
117
75
  version: '0'
118
76
  type: :runtime
119
77
  prerelease: false
120
78
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
79
  requirements:
123
- - - ! '>='
80
+ - - ">="
124
81
  - !ruby/object:Gem::Version
125
82
  version: '0'
126
83
  description: A library to upload file to netprint
@@ -131,8 +88,9 @@ executables:
131
88
  extensions: []
132
89
  extra_rdoc_files: []
133
90
  files:
134
- - .gitignore
135
- - .rspec
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
136
94
  - Gemfile
137
95
  - LICENSE
138
96
  - README.md
@@ -143,55 +101,52 @@ files:
143
101
  - lib/netprint/constants.rb
144
102
  - lib/netprint/error.rb
145
103
  - lib/netprint/options.rb
146
- - lib/netprint/url.rb
147
104
  - lib/netprint/version.rb
148
105
  - netprint.gemspec
149
- - spec/error.html
150
- - spec/foo.pdf
151
- - spec/list.html
106
+ - spec/fixtures/foo.pdf
107
+ - spec/fixtures/list_empty.html
108
+ - spec/fixtures/list_error.html
109
+ - spec/fixtures/list_processed.html
110
+ - spec/fixtures/list_processing.html
111
+ - spec/fixtures/login.html
112
+ - spec/fixtures/upload.html
113
+ - spec/fixtures/upload_error.html
114
+ - spec/fixtures/あいうえお.pdf
152
115
  - spec/netprint/agent_spec.rb
153
116
  - spec/netprint/options_spec.rb
154
- - spec/netprint/url_spec.rb
155
117
  - spec/spec_helper.rb
156
- - spec/upload.html
157
- - spec/あいうえお.pdf
158
118
  homepage: ''
159
119
  licenses: []
120
+ metadata: {}
160
121
  post_install_message:
161
122
  rdoc_options: []
162
123
  require_paths:
163
124
  - lib
164
125
  required_ruby_version: !ruby/object:Gem::Requirement
165
- none: false
166
126
  requirements:
167
- - - ! '>='
127
+ - - ">="
168
128
  - !ruby/object:Gem::Version
169
129
  version: '0'
170
- segments:
171
- - 0
172
- hash: -565048395014736693
173
130
  required_rubygems_version: !ruby/object:Gem::Requirement
174
- none: false
175
131
  requirements:
176
- - - ! '>='
132
+ - - ">="
177
133
  - !ruby/object:Gem::Version
178
134
  version: '0'
179
- segments:
180
- - 0
181
- hash: -565048395014736693
182
135
  requirements: []
183
- rubyforge_project:
184
- rubygems_version: 1.8.25
136
+ rubygems_version: 3.1.2
185
137
  signing_key:
186
- specification_version: 3
138
+ specification_version: 4
187
139
  summary: A library to upload file to netprint
188
140
  test_files:
189
- - spec/error.html
190
- - spec/foo.pdf
191
- - spec/list.html
141
+ - spec/fixtures/foo.pdf
142
+ - spec/fixtures/list_empty.html
143
+ - spec/fixtures/list_error.html
144
+ - spec/fixtures/list_processed.html
145
+ - spec/fixtures/list_processing.html
146
+ - spec/fixtures/login.html
147
+ - spec/fixtures/upload.html
148
+ - spec/fixtures/upload_error.html
149
+ - spec/fixtures/あいうえお.pdf
192
150
  - spec/netprint/agent_spec.rb
193
151
  - spec/netprint/options_spec.rb
194
- - spec/netprint/url_spec.rb
195
152
  - spec/spec_helper.rb
196
- - spec/upload.html
197
- - spec/あいうえお.pdf