carrierwave-viewer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,34 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'rspec'
4
+ require 'webmock/rspec'
5
+ require 'carrierwave'
6
+ require 'carrierwave-viewer'
7
+ require 'support/test_model'
8
+ require 'support/test_uploader'
9
+
10
+ RSpec.configure do |config|
11
+ config.before do
12
+ CarrierWave.configure do |groupdocs|
13
+ groupdocs.groupdocs_client_id = '07aaaf95f8eb33a4'
14
+ groupdocs.groupdocs_private_key = '5cb711b3a52ffc5d90ee8a0f79206f5a'
15
+ end
16
+ FileUtils.rm_rf('tmp')
17
+ end
18
+ end
19
+
20
+ # Borrowed from groupdocs-ruby specs
21
+ # Mocks API server.
22
+ #
23
+ def mock_api_server(json, headers = {})
24
+ request = stub_request(:any, /#{GroupDocs.api_server}.*/)
25
+ request = request.with(:headers => headers) unless headers.empty?
26
+ request.to_return(:body => json)
27
+ end
28
+
29
+ #
30
+ # Loads JSON file.
31
+ #
32
+ def load_json(name)
33
+ File.read("spec/support/#{name}.json")
34
+ end
@@ -0,0 +1,9 @@
1
+ {
2
+ "status": "Ok",
3
+ "result":
4
+ {
5
+ "adj_name": "File.pdf",
6
+ "guid": "123abc",
7
+ "type": "Words"
8
+ }
9
+ }
@@ -0,0 +1,3 @@
1
+ class TestModel
2
+ attr_accessor :groupdocs_guid
3
+ end
@@ -0,0 +1,14 @@
1
+ class TestUploader < CarrierWave::Uploader::Base
2
+ include CarrierWave::Viewer
3
+
4
+ def store_dir
5
+ "tmp/store"
6
+ end
7
+
8
+ def cache_dir
9
+ "tmp/cache"
10
+ end
11
+
12
+ storage :file
13
+
14
+ end
@@ -0,0 +1,18 @@
1
+ require File.expand_path('spec/spec_helper')
2
+
3
+ describe CarrierWave::Viewer do
4
+ let(:file) { File.open("spec/fixtures/groupdocs.pdf") }
5
+ let(:object) { TestModel.new }
6
+
7
+ before do
8
+ mock_api_server(load_json('file_upload'))
9
+ @uploader = TestUploader.new(object)
10
+ end
11
+
12
+ it "should have uploaded file to GroupDocs" do
13
+ @uploader.store!(file)
14
+ object.groupdocs_guid.should_not be_blank
15
+ object.groupdocs_guid.should == '123abc'
16
+ end
17
+
18
+ end
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: carrierwave-viewer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - GarPit
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: carrierwave
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.6.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.6.2
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.3'
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: '1.3'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '2.6'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '2.6'
78
+ - !ruby/object:Gem::Dependency
79
+ name: webmock
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: Carrierwave integration with GroupDocs service
95
+ email:
96
+ - garik.piton@gmail.com
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - Gemfile
103
+ - LICENSE.txt
104
+ - README.md
105
+ - Rakefile
106
+ - carrierwave-viewer.gemspec
107
+ - lib/carrierwave-viewer.rb
108
+ - lib/carrierwave-viewer/config.rb
109
+ - lib/carrierwave-viewer/version.rb
110
+ - lib/carrierwave-viewer/viewer.rb
111
+ - spec/config_spec.rb
112
+ - spec/fixtures/groupdocs.pdf
113
+ - spec/spec_helper.rb
114
+ - spec/support/file_upload.json
115
+ - spec/support/test_model.rb
116
+ - spec/support/test_uploader.rb
117
+ - spec/viewer_spec.rb
118
+ homepage: ''
119
+ licenses:
120
+ - MIT
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ none: false
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 1.8.25
140
+ signing_key:
141
+ specification_version: 3
142
+ summary: Carrierwave integration with GroupDocs service
143
+ test_files:
144
+ - spec/config_spec.rb
145
+ - spec/fixtures/groupdocs.pdf
146
+ - spec/spec_helper.rb
147
+ - spec/support/file_upload.json
148
+ - spec/support/test_model.rb
149
+ - spec/support/test_uploader.rb
150
+ - spec/viewer_spec.rb