fallcli 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe FallCli::CLI do
4
+ include_context "spec"
5
+
6
+ describe "version" do
7
+ it "shows the correct version" do
8
+
9
+ @cli.options = @cli.options.merge(:version => true)
10
+ @cli.version
11
+
12
+ expect($stdout.string.chomp).to eq("FallCli #{FallCli::VERSION.to_s}")
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ describe FallCli::Configuration do
4
+ include_context "spec"
5
+
6
+ let(:tmp_path) { project_path + "/tmp/fallcli" }
7
+
8
+ after :each do
9
+ # Clean up the temp file.
10
+ File.delete(project_path + "/tmp/fallcli") if File.exist?(project_path + "/tmp/fallcli")
11
+ end
12
+
13
+ it "is a singleton" do
14
+ expect(FallCli::Configuration).to be_a Class
15
+ expect do
16
+ FallCli::Configuration.new
17
+ end.to raise_error(NoMethodError, /private method `new' called/)
18
+ end
19
+
20
+ it "has a data attribute" do
21
+ config = FallCli::Configuration.instance
22
+ expect(config.data).to be
23
+ end
24
+
25
+ describe "the file" do
26
+ let(:app_key) { "foo" }
27
+ let(:secret_key) { "bar" }
28
+ let(:app_token) { "baz" }
29
+ let(:app_secret) { "blegga" }
30
+
31
+ let(:config) { config = FallCli::Configuration.instance }
32
+
33
+ before :each do
34
+ # Create a temporary file
35
+ config.create_config_file(app_key, secret_key, app_token, app_secret)
36
+ end
37
+
38
+ it "can be created" do
39
+ expect(File.exist?(tmp_path)).to be_true
40
+ end
41
+
42
+ it "can be loaded" do
43
+ data = config.load_config_file
44
+ expect(data).to_not be_nil
45
+ end
46
+
47
+ describe "the file format"
48
+ let(:data) { YAML.load_file(tmp_path) }
49
+
50
+ it "should have an app key" do
51
+ auth = data["authentication"]
52
+ expect(auth).to have_key("app_key")
53
+ end
54
+
55
+ it "should have a secret key" do
56
+ auth = data["authentication"]
57
+ expect(auth).to have_key("secret_key")
58
+ end
59
+
60
+ it "should have an app token" do
61
+ client = data["client"]
62
+ expect(client).to have_key("app_token")
63
+ end
64
+
65
+ it "should have an app secret" do
66
+ client = data["client"]
67
+ expect(client).to have_key("app_secret")
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,14 @@
1
+ {
2
+ "size": "225.4KB",
3
+ "rev": "35e97029684fe",
4
+ "thumb_exists": false,
5
+ "bytes": 230783,
6
+ "modified": "Tue, 19 Jul 2011 21:55:38 +0000",
7
+ "client_mtime": "Mon, 18 Jul 2011 18:04:35 +0000",
8
+ "path": "/Getting_Started.pdf",
9
+ "is_dir": false,
10
+ "icon": "page_white_acrobat",
11
+ "root": "dropbox",
12
+ "mime_type": "application/pdf",
13
+ "revision": 220823
14
+ }
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe FallCli::Middleware::Base do
4
+ include_context "spec"
5
+
6
+ let(:klass) { described_class }
7
+
8
+ describe ".initialize" do
9
+ it "prints a clear line" do
10
+ $stdout.should_receive(:print).with("")
11
+ klass.new({})
12
+ end
13
+ end
14
+
15
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe FallCli::Middleware::CheckConfiguration do
4
+ include_context "spec"
5
+
6
+ describe ".call" do
7
+ it "raises SystemExit with no configuration" do
8
+
9
+ # Delete the temp configuration file.
10
+ File.delete(project_path + "/tmp/fallcli")
11
+
12
+ expect {described_class.new(app).call(env) }.to raise_error(SystemExit)
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe FallCli::Middleware::InjectConfiguration do
4
+ include_context "spec"
5
+
6
+ describe ".call" do
7
+
8
+ it "loads the configuration into the environment" do
9
+ described_class.new(app).call(env)
10
+
11
+ env["config"].should == config
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ shared_context "spec" do
4
+ # Default configuration and
5
+ let(:config) { FallCli::Configuration.instance }
6
+ let(:app_key) { "foo" }
7
+ let(:secret_key) { "bar" }
8
+ let(:app_token) { "baz" }
9
+ let(:app_secret) { "qux" }
10
+ let(:app) { lambda { |env| } }
11
+ let(:env) { {} }
12
+
13
+ before(:each) do
14
+ $stdout.sync = true
15
+ $stderr.sync = true
16
+
17
+ @cli = FallCli::CLI.new
18
+
19
+ # Set a temprary project path and create fake config.
20
+ config.create_config_file(app_key, secret_key, app_token, app_secret)
21
+ config.reload!
22
+
23
+ # Keep track of the old stderr / out
24
+ @orig_stderr = $stderr
25
+ @orig_stdout = $stdout
26
+
27
+ # Make them strings so we can manipulate and compare.
28
+ $stderr = StringIO.new
29
+ $stdout = StringIO.new
30
+
31
+ end
32
+
33
+ after(:each) do
34
+ # Reassign the stderr / out so rspec can have it back.
35
+ $stderr = @orig_stderr
36
+ $stdout = @orig_stdout
37
+ end
38
+
39
+ after(:each) do
40
+ # Delete the temporary configuration file if it exists.
41
+ File.delete(project_path + "/tmp/fallcli") if File.exist?(project_path + "/tmp/fallcli")
42
+ end
43
+
44
+ end
@@ -0,0 +1,30 @@
1
+ require 'fallcli'
2
+ require 'webmock/rspec'
3
+ require 'shared/environment'
4
+
5
+ require 'simplecov'
6
+ require 'coveralls'
7
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
8
+ SimpleCov::Formatter::HTMLFormatter,
9
+ Coveralls::SimpleCov::Formatter
10
+ ]
11
+ SimpleCov.start do
12
+ coverage_dir('coverage/')
13
+ end
14
+
15
+ RSpec.configure do |config|
16
+ # Pretty tests
17
+ config.color_enabled = true
18
+
19
+ config.order = :random
20
+ end
21
+
22
+ def project_path
23
+ File.expand_path("../..", __FILE__)
24
+ end
25
+
26
+ def fixture(fixture_name)
27
+ File.new(project_path + "/spec/fixtures/#{fixture_name}.json")
28
+ end
29
+
30
+ ENV["FALLCLI_CONFIG_PATH"] = project_path + "/tmp/fallcli"
File without changes
metadata ADDED
@@ -0,0 +1,247 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fallcli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Peter Souter
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.18.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.18.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: dropbox-api-petems
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.1.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: dispel
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.7
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.0.7
69
+ - !ruby/object:Gem::Dependency
70
+ name: ruby-progressbar
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 1.2.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 1.2.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 10.1.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 10.1.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-core
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 2.13.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 2.13.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-expectations
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 2.13.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: 2.13.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec-mocks
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: 2.13.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: 2.13.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: webmock
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ~>
144
+ - !ruby/object:Gem::Version
145
+ version: 1.11.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ~>
151
+ - !ruby/object:Gem::Version
152
+ version: 1.11.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: coveralls
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ~>
158
+ - !ruby/object:Gem::Version
159
+ version: 0.7.1
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ~>
165
+ - !ruby/object:Gem::Version
166
+ version: 0.7.1
167
+ description: A curses CLI app for Dropbox
168
+ email:
169
+ - p.morsou@gmail.com
170
+ executables:
171
+ - fallcli
172
+ extensions: []
173
+ extra_rdoc_files: []
174
+ files:
175
+ - .gitignore
176
+ - .travis.yml
177
+ - Gemfile
178
+ - LICENSE.md
179
+ - README.md
180
+ - Rakefile
181
+ - bin/fallcli
182
+ - fallcli.gemspec
183
+ - lib/fallcli.rb
184
+ - lib/fallcli/browser_helper.rb
185
+ - lib/fallcli/cli.rb
186
+ - lib/fallcli/config.rb
187
+ - lib/fallcli/middleware.rb
188
+ - lib/fallcli/middleware/ask_for_credentials.rb
189
+ - lib/fallcli/middleware/base.rb
190
+ - lib/fallcli/middleware/browser.rb
191
+ - lib/fallcli/middleware/check_configuration.rb
192
+ - lib/fallcli/middleware/check_credentials.rb
193
+ - lib/fallcli/middleware/inject_client.rb
194
+ - lib/fallcli/middleware/inject_configuration.rb
195
+ - lib/fallcli/middleware/upload_browser.rb
196
+ - lib/fallcli/uploader_browser_helper.rb
197
+ - lib/fallcli/version.rb
198
+ - spec/cli/account.rb
199
+ - spec/cli/authorize_spec.rb
200
+ - spec/cli/help_cli_spec.rb
201
+ - spec/cli/verify_spec.rb
202
+ - spec/cli/version_cli_spec.rb
203
+ - spec/config_spec.rb
204
+ - spec/fixtures/verify_success.json
205
+ - spec/middleware/base_spec.rb
206
+ - spec/middleware/check_configuration_spec.rb
207
+ - spec/middleware/inject_configuration_spec.rb
208
+ - spec/shared/environment.rb
209
+ - spec/spec_helper.rb
210
+ - tmp/.gitkeep
211
+ homepage: https://github.com/petems/fallcli
212
+ licenses:
213
+ - MIT
214
+ metadata: {}
215
+ post_install_message:
216
+ rdoc_options: []
217
+ require_paths:
218
+ - lib
219
+ required_ruby_version: !ruby/object:Gem::Requirement
220
+ requirements:
221
+ - - '>='
222
+ - !ruby/object:Gem::Version
223
+ version: '0'
224
+ required_rubygems_version: !ruby/object:Gem::Requirement
225
+ requirements:
226
+ - - '>='
227
+ - !ruby/object:Gem::Version
228
+ version: '0'
229
+ requirements: []
230
+ rubyforge_project:
231
+ rubygems_version: 2.0.14
232
+ signing_key:
233
+ specification_version: 4
234
+ summary: FallCli is a curses CLI app for Dropbox
235
+ test_files:
236
+ - spec/cli/account.rb
237
+ - spec/cli/authorize_spec.rb
238
+ - spec/cli/help_cli_spec.rb
239
+ - spec/cli/verify_spec.rb
240
+ - spec/cli/version_cli_spec.rb
241
+ - spec/config_spec.rb
242
+ - spec/fixtures/verify_success.json
243
+ - spec/middleware/base_spec.rb
244
+ - spec/middleware/check_configuration_spec.rb
245
+ - spec/middleware/inject_configuration_spec.rb
246
+ - spec/shared/environment.rb
247
+ - spec/spec_helper.rb