ferver 1.2.1 → 1.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e42a62e59a7371617918ea1c1a52702b6765ade1
4
- data.tar.gz: 7144fe5b0a7167319a4f1837980f55796fabb554
3
+ metadata.gz: 53cab51e0ed1cb913ac92f9a19e927f9287115c4
4
+ data.tar.gz: 2be0b531e9d3b69bca13fbda397f84851fcbc414
5
5
  SHA512:
6
- metadata.gz: 1d3ee2dfde1b61732967fc3cd2011702dec256256ae73dd3110c956588fdbb39f954b44c3dc0f5798c04597309d8f306d3f72caa8fabc49a731ba864ab17cc04
7
- data.tar.gz: 7c658dfd826f29d134eb31fe0eb56a3973e5860c72446826cf3a7674e91063681a518a5adc1db1fb44b9940c19d27984773f5fd5258706cff0083118faecca79
6
+ metadata.gz: 0768729a9b85bb19183db20980214eeb22499d62a0fe23739dee08d9b635ff0eda80b937d09ee8e8801dadcefc041e1c07fbd7d3ff4087603af1e8f4d504aa43
7
+ data.tar.gz: 23c93f96598a6397cdc0e073acb16f58bd3da509be09a806638895d256c3d81b742e219822de5aa2897156906996b3ea768ed52af8fe6708c01c83528f69c50f
@@ -1 +1 @@
1
- 2.1.1
1
+ 2.2.0
@@ -1,10 +1,13 @@
1
1
  language: ruby
2
+ sudo: false
2
3
  rvm:
3
4
  - 1.9.3
4
5
  - 2.0.0
5
6
  - 2.1.0
7
+ - 2.2.0
6
8
  - ruby-head
7
9
 
8
10
  addons:
9
11
  code_climate:
10
- repo_token: aaa2bcd71ac641474a13caabe294beeb26abcc7c4dd82f3395a7b9193bb20d02
12
+ repo_token: aaa2bcd71ac641474a13caabe294beeb26abcc7c4dd82f3395a7b9193bb20d02
13
+
@@ -1,7 +1,23 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## 1.2.1 - 2014-11-14 - XX
4
+ ## 1.3.0 - 2015-10-24 - TBC
5
+
6
+ ### Added
7
+ * Don't serve hidden files by default
8
+ * New `--all` option to serve hidden files
9
+ * Sort files listed alphabetically
10
+
11
+ ### Deprecated
12
+ - Nothing.
13
+
14
+ ### Removed
15
+ - Nothing.
16
+
17
+ ### Fixed
18
+ - Don't serve empty files
19
+
20
+ ## 1.2.1 - 2014-11-15 - de54826
5
21
 
6
22
  ### Added
7
23
 
data/README.md CHANGED
@@ -17,6 +17,7 @@ Here's the spec for **ferver**:
17
17
  * available over http
18
18
  * provide a list of files as html and json
19
19
  * ignore directories
20
+ * ignore dotfiles - turn off with setting
20
21
  * serve files as individual files
21
22
  * minimal config
22
23
  * able to specify the directory to serve files from
@@ -41,15 +42,25 @@ $ ferver
41
42
 
42
43
  ##### Use a specific directory
43
44
 
44
- For exmple, to serve files from **/Users/rob/Projects/ferver/** directory pass the path in as below;
45
+ For exmple, to serve files from **/Users/rob/Projects/ferver/** directory pass the path in as below using the `--directory` option.
45
46
 
46
47
  ```bash
47
48
  $ ferver -d /Users/rob/Projects/ferver/
48
49
  ````
49
50
 
51
+ ##### Serve all files
52
+
53
+ By default, dotfiles will be hidden. Use the `--all` option to serve all files.
54
+
55
+ ```bash
56
+ $ ferver -a
57
+ ````
58
+
59
+ > Note that zero size files will always be hidden.
60
+
50
61
  ##### Command line help
51
62
 
52
- For a list of arguments just use the `-h` switch.
63
+ For a list of arguments just use the `--help` switch.
53
64
 
54
65
  ```bash
55
66
  $ ferver -h
@@ -67,7 +78,7 @@ List available files in your browser.
67
78
 
68
79
  #### JSON
69
80
 
70
- Requesting content-type `json`, for exampled passing the header `Accept: application/json` will return the list of files as json.
81
+ Requesting content-type `json`, for example passing the header `Accept: application/json` will return the list of files as json.
71
82
 
72
83
  ```bash
73
84
  curl -i -H "Accept: application/json" http://localhost:4567/files
@@ -83,15 +94,8 @@ For example to download file appearing third in the list displayed earlier, requ
83
94
 
84
95
  Please use the GitHub pull-request mechanism to submit contributions.
85
96
 
86
- After cloning the repo, you can run the web application without having to install the gem package by running a Rake task named `server`, or it's alias `s`.
87
-
88
- ```bash
89
- $ rake s
97
+ After cloning the repo, you can run the web application without having to publish and then install the gem package by calling the executable as per normal.
90
98
 
91
- # or
92
-
93
- $ rake s /path/to/dir
94
- ```
95
99
 
96
100
  ### License
97
101
 
data/Rakefile CHANGED
@@ -1,27 +1,8 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core'
3
- require 'rspec/core/rake_task'
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core"
3
+ require "rspec/core/rake_task"
4
4
 
5
- task :default => :spec
6
- task :s => :server
5
+ task default: :spec
7
6
 
8
7
  desc "Run all specs in spec directory (excluding plugin specs)"
9
8
  RSpec::Core::RakeTask.new(:spec)
10
-
11
- desc 'Run ferver locally from source'
12
- task :server do
13
- require 'rubygems'
14
- require 'bundler'
15
- Bundler.setup
16
- require 'ferver'
17
-
18
- # use the last argument (first is the rake task) as the file path to serve from
19
- ferver_path = (ARGV.length == 2 && ARGV.last) || nil
20
- Ferver.configure do |config|
21
- config.directory_path = ferver_path
22
- end
23
- Ferver::App.set :raise_errors, false
24
-
25
- # run!
26
- Ferver::App.run!
27
- end
data/bin/ferver CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'optparse'
4
- require 'sinatra'
4
+ $:.unshift File.join( File.dirname(__FILE__), "/../lib")
5
5
  require 'ferver'
6
6
 
7
7
  options = {}
@@ -9,6 +9,10 @@ OptionParser.new do |opts|
9
9
  opts.banner = 'Ferver: A simple web app to serve files over HTTP. Version: ' + Ferver::VERSION
10
10
  opts.separator ''
11
11
 
12
+ opts.on('-a', '--all', 'Serve hidden files') do |a|
13
+ options[:hidden] = a
14
+ end
15
+
12
16
  opts.on('-d', '--directory [DIRECTORY]', 'Specify the path to the directory to serve files from [optional]') do |directory|
13
17
  options[:directory] = directory
14
18
  end
@@ -20,6 +24,7 @@ OptionParser.new do |opts|
20
24
  end.parse!
21
25
 
22
26
  Ferver.configure do |config|
27
+ config.serve_hidden = options[:hidden]
23
28
  config.directory_path = options[:directory]
24
29
  end
25
30
  Ferver::App.set :environment, :production
@@ -4,6 +4,7 @@ require_relative 'ferver/configuration'
4
4
  require_relative 'ferver/directory_not_found_error'
5
5
  require_relative 'ferver/file_id_request'
6
6
  require_relative 'ferver/file_list'
7
+ require_relative 'ferver/found_file'
7
8
  require_relative 'ferver/version'
8
9
 
9
10
  module Ferver
@@ -11,18 +12,18 @@ module Ferver
11
12
  DEFAULT_FILE_SERVER_DIR_PATH = './'
12
13
 
13
14
  class << self
14
- attr_accessor :configuration
15
- end
15
+ attr_accessor :configuration
16
16
 
17
- def self.configuration
18
- @configuration ||= Configuration.new
19
- end
17
+ def configuration
18
+ @configuration ||= Configuration.new
19
+ end
20
20
 
21
- def self.reset
22
- @configuration = Configuration.new
23
- end
21
+ def reset
22
+ @configuration = Configuration.new
23
+ end
24
24
 
25
- def self.configure
26
- yield(configuration)
25
+ def configure
26
+ yield(configuration)
27
+ end
27
28
  end
28
29
  end
@@ -1,11 +1,18 @@
1
1
  module Ferver
2
2
  class Configuration
3
- attr_accessor :directory_path
3
+ attr_accessor :directory_path, :serve_hidden
4
4
 
5
5
  # Return the absolute path to the directory Ferver is serving files from.
6
6
  #
7
7
  def directory_path
8
8
  @directory_path || Ferver::DEFAULT_FILE_SERVER_DIR_PATH
9
9
  end
10
+
11
+ # Default to not serving hidden files
12
+ #
13
+ def serve_hidden
14
+ @serve_hidden || false
15
+ end
16
+ alias_method :serve_hidden?, :serve_hidden
10
17
  end
11
18
  end
@@ -10,6 +10,12 @@ module Ferver
10
10
  @ferver_list = FileList.new(current_ferver_path)
11
11
  end
12
12
 
13
+ before '/files/:id' do
14
+ halt(400, 'Bad request') unless valid_file_request?
15
+
16
+ find_file!
17
+ end
18
+
13
19
  error Ferver::DirectoryNotFoundError do
14
20
  halt 500, "Ferver: Directory '#{current_ferver_path}' not found."
15
21
  end
@@ -24,26 +30,19 @@ module Ferver
24
30
  if request.preferred_type.to_s == 'application/json'
25
31
  content_type :json
26
32
 
27
- ferver_list.all.to_json
33
+ ferver_list.map(&:name).to_json
28
34
  else
29
- erb :index, locals: { file_list: ferver_list.all,
30
- ferver_path: File.expand_path(current_ferver_path),
35
+ erb :index, locals: { file_list: ferver_list,
36
+ ferver_path: current_full_path,
31
37
  file_count: ferver_list.size }
32
38
  end
33
39
  end
34
40
 
35
41
  # download file
36
42
  get '/files/:id' do
37
- halt(400, 'Bad request') unless valid_file_request?
38
-
39
- if ferver_list.file_id_valid?(file_id_request.value)
40
- file_name = ferver_list.file_by_id(file_id_request.value)
41
- file = FileList.path_for_file(current_ferver_path, file_name)
42
-
43
- send_file(file, disposition: 'attachment', filename: File.basename(file))
44
- else
45
- status 404
46
- end
43
+ send_file(
44
+ @file.path_to_file, disposition: 'attachment', filename: @file.name
45
+ )
47
46
  end
48
47
 
49
48
  private
@@ -58,8 +57,18 @@ module Ferver
58
57
  file_id_request.valid?
59
58
  end
60
59
 
60
+ def find_file!
61
+ @file = ferver_list.file_by_id(file_id_request.value)
62
+ rescue IndexError
63
+ halt 404, 'File requested not found.'
64
+ end
65
+
61
66
  def current_ferver_path
62
67
  Ferver.configuration.directory_path
63
68
  end
69
+
70
+ def current_full_path
71
+ File.expand_path(current_ferver_path)
72
+ end
64
73
  end
65
74
  end
@@ -1,4 +1,3 @@
1
-
2
1
  module Ferver
3
- class DirectoryNotFoundError < StandardError; end
2
+ DirectoryNotFoundError = Class.new(StandardError)
4
3
  end
@@ -10,14 +10,7 @@ module Ferver
10
10
  end
11
11
 
12
12
  def value=(value)
13
- id = parse_value(value)
14
-
15
- if id.nil?
16
- @is_valid = false
17
- else
18
- @value = id
19
- @is_valid = true
20
- end
13
+ @value = parse_value(value)
21
14
  end
22
15
 
23
16
  def valid?
@@ -28,9 +21,11 @@ module Ferver
28
21
 
29
22
  def parse_value(value)
30
23
  begin
31
- Integer(value)
24
+ int_val = Integer(value)
25
+ @is_valid = true
26
+ int_val
32
27
  rescue
33
- nil
28
+ @is_valid = false
34
29
  end
35
30
  end
36
31
  end
@@ -4,44 +4,33 @@ require 'forwardable'
4
4
  #
5
5
  module Ferver
6
6
  class FileList
7
- extend Forwardable
8
7
  include Enumerable
9
8
 
10
- def_delegators :@files, :size, :each
11
-
12
9
  # Create a new instance with a path
13
10
  #
14
11
  def initialize(path)
15
12
  fail ArgumentError, 'No path is specified' if path.empty?
16
13
  fail DirectoryNotFoundError unless Dir.exist?(path)
17
14
 
18
- @files = []
19
15
  @configured_file_path = File.expand_path(path)
20
- find_files
16
+ @files = find_files.sort_by! { |f| f.name.downcase }
21
17
  end
22
18
 
23
- # Return an absolute path to a `file_name` in the `directory`
24
- #
25
- def self.path_for_file(directory, file_name)
26
- File.join(directory, file_name)
19
+ def each(&block)
20
+ files.each(&block)
27
21
  end
28
22
 
29
- # Is the file id a valid id for Ferver to serve
30
- #
31
- def file_id_valid?(file_id)
32
- file_id < files.size
23
+ def size
24
+ files.size
33
25
  end
34
26
 
35
27
  # Filename by its index
28
+ # An id out of range with raise IndexError
36
29
  #
37
30
  def file_by_id(id)
38
31
  files.fetch(id)
39
32
  end
40
33
 
41
- def all
42
- files
43
- end
44
-
45
34
  private
46
35
 
47
36
  attr_reader :configured_file_path, :files
@@ -49,13 +38,14 @@ module Ferver
49
38
  # Iterate through files in specified dir for files
50
39
  #
51
40
  def find_files
52
- @files = []
53
-
54
- Dir.foreach(configured_file_path) do |file|
55
- next if file == '.' || file == '..'
56
-
57
- file_path = FileList.path_for_file(configured_file_path, file)
58
- @files << file if File.file?(file_path)
41
+ [].tap do |results|
42
+ Dir.foreach(configured_file_path) do |file_name|
43
+ next if file_name == '.' || file_name == '..'
44
+ next if file_name =~ /^\./ && !Ferver.configuration.serve_hidden?
45
+
46
+ found_file = FoundFile.new(configured_file_path, file_name)
47
+ results << found_file if found_file.valid?
48
+ end
59
49
  end
60
50
  end
61
51
  end
@@ -0,0 +1,16 @@
1
+ module Ferver
2
+ class FoundFile
3
+ attr_reader :file_name, :path_to_file
4
+
5
+ alias_method :name, :file_name
6
+
7
+ def initialize(directory, file_name)
8
+ @file_name = file_name
9
+ @path_to_file = File.join(directory, file_name)
10
+ end
11
+
12
+ def valid?
13
+ File.file?(path_to_file) && !File.zero?(path_to_file)
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module Ferver
2
- VERSION = '1.2.1'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -7,9 +7,9 @@
7
7
  <body>
8
8
  <h3>Files served:</h3>
9
9
  <ul>
10
- <% file_list.each_with_index do |file_name, index| %>
10
+ <% file_list.each_with_index do |file, index| %>
11
11
 
12
- <li><a href="/files/<%= index %>"><%= file_name %></a></li>
12
+ <li><a href="/files/<%= index %>"><%= file.name %></a></li>
13
13
 
14
14
  <% end %>
15
15
 
@@ -25,4 +25,4 @@
25
25
  </html>
26
26
 
27
27
  <html>
28
- <body>
28
+ <body>
@@ -1,10 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Ferver::Configuration do
4
- subject { Ferver::Configuration.new }
4
+ subject { described_class.new }
5
5
 
6
6
  describe 'configured directory path' do
7
-
8
7
  context 'with no path set' do
9
8
  it 'should return default path' do
10
9
  expect(subject.directory_path).to eq(Ferver::DEFAULT_FILE_SERVER_DIR_PATH)
@@ -21,4 +20,20 @@ describe Ferver::Configuration do
21
20
  end
22
21
  end
23
22
  end
23
+
24
+ describe "serving all files" do
25
+ context "with no configuration set" do
26
+ it "is false by default" do
27
+ expect(subject.serve_hidden?).to be false
28
+ end
29
+ end
30
+
31
+ context "when configured to serve hidden" do
32
+ it "is true" do
33
+ subject.serve_hidden = true
34
+
35
+ expect(subject.serve_hidden?).to be true
36
+ end
37
+ end
38
+ end
24
39
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'ferver' do
4
- let(:file_list) { double('file-list') }
4
+ let(:file_list) { double('Ferver::FileList') }
5
5
 
6
6
  context 'given a request to the server root' do
7
7
  before do
@@ -22,7 +22,7 @@ describe 'ferver' do
22
22
 
23
23
  describe 'choosing directory to serve files from' do
24
24
  before do
25
- allow(file_list).to receive(:all).and_return(EMPTY_FILE_LIST)
25
+ allow(file_list).to receive(:each_with_index)
26
26
  allow(file_list).to receive(:size).and_return(0)
27
27
  end
28
28
 
@@ -63,7 +63,7 @@ describe 'ferver' do
63
63
 
64
64
  context 'given an empty list of files' do
65
65
  before do
66
- allow(file_list).to receive(:all).and_return(EMPTY_FILE_LIST)
66
+ allow(file_list).to receive(:each_with_index)
67
67
  allow(file_list).to receive(:size).and_return(0)
68
68
  allow(Ferver::FileList).to receive(:new).and_return(file_list)
69
69
  end
@@ -83,6 +83,8 @@ describe 'ferver' do
83
83
 
84
84
  context 'when json content-type is requested' do
85
85
  before do
86
+ allow(file_list).to receive(:map).and_return([])
87
+
86
88
  get '/files', {}, 'HTTP_ACCEPT' => 'application/json'
87
89
  end
88
90
 
@@ -99,8 +101,10 @@ describe 'ferver' do
99
101
  end
100
102
 
101
103
  context 'given a list of files' do
104
+ let(:file_1) { double('file', name: 'file1') }
105
+ let(:file_2) { double('file', name: 'file2') }
102
106
  before do
103
- allow(file_list).to receive(:all).and_return(%w(file1 file2))
107
+ allow(file_list).to receive(:each_with_index).and_yield(file_1, 1).and_yield(file_2, 2)
104
108
  allow(file_list).to receive(:size).and_return(2)
105
109
  allow(Ferver::FileList).to receive(:new).and_return(file_list)
106
110
  end
@@ -129,6 +133,8 @@ describe 'ferver' do
129
133
 
130
134
  context 'when json content-type is requested' do
131
135
  before do
136
+ allow(file_list).to receive(:map).and_return([file_1.name, file_2.name])
137
+
132
138
  get '/files', {}, 'HTTP_ACCEPT' => 'application/json'
133
139
  end
134
140
 
@@ -140,7 +146,7 @@ describe 'ferver' do
140
146
  it 'should contain no file list in response content' do
141
147
  list = JSON.parse last_response.body
142
148
  expect(list.count).to eq(2)
143
- expect(list).to match_array(%w(file1 file2))
149
+ expect(list).to match_array([file_1.name, file_2.name])
144
150
  end
145
151
  end
146
152
  end
@@ -149,7 +155,7 @@ describe 'ferver' do
149
155
 
150
156
  context 'when requesting a file out of range' do
151
157
  before do
152
- allow(file_list).to receive(:file_id_valid?).with(3).and_return(false)
158
+ allow(file_list).to receive(:file_by_id).with(3).and_raise(IndexError)
153
159
  get '/files/3'
154
160
  end
155
161
 
@@ -1,6 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Ferver::FileList do
4
+ let(:file_1) { double('file', name: 'file1') }
5
+ let(:file_2) { double('file', name: 'file2') }
6
+
4
7
  before { allow(Dir).to receive(:exist?).and_return(true) }
5
8
  subject { Ferver::FileList.new('/foo') }
6
9
 
@@ -47,14 +50,15 @@ describe Ferver::FileList do
47
50
  end
48
51
 
49
52
  it 'should return empty array of files' do
50
- expect(subject.all).to eq(EMPTY_FILE_LIST)
53
+ expect(subject.to_a).to eq(EMPTY_FILE_LIST)
51
54
  end
52
55
  end
53
56
 
54
57
  context 'when path directory contains current working dir and parent' do
55
58
  before(:each) do
56
- allow(Dir).to receive(:foreach).and_yield('.').and_yield('.').and_yield('file1')
59
+ allow(Dir).to receive(:foreach).and_yield('.').and_yield('.').and_yield(file_1.name)
57
60
  allow(File).to receive(:file?).and_return(true)
61
+ allow(File).to receive(:zero?).and_return(false)
58
62
  end
59
63
 
60
64
  it 'should not count current working dir and parent' do
@@ -62,14 +66,15 @@ describe Ferver::FileList do
62
66
  end
63
67
 
64
68
  it 'should not include current working dir and parent' do
65
- expect(subject.all).to eq(['file1'])
69
+ expect(subject.to_a.first.name).to eq(file_1.name)
66
70
  end
67
71
  end
68
72
 
69
73
  context 'when path directory contains file and directory' do
70
74
  before(:each) do
71
- allow(Dir).to receive(:foreach).and_yield('file1').and_yield('a_directory')
75
+ allow(Dir).to receive(:foreach).and_yield(file_1.name).and_yield('a_directory')
72
76
  allow(File).to receive(:file?).twice.and_return(true, false)
77
+ allow(File).to receive(:zero?).twice.and_return(false, true)
73
78
  end
74
79
 
75
80
  it 'should not count the directory' do
@@ -77,30 +82,30 @@ describe Ferver::FileList do
77
82
  end
78
83
 
79
84
  it 'should not include the directory' do
80
- expect(subject.all).to eq(['file1'])
85
+ expect(subject.to_a.first.name).to eq(file_1.name)
81
86
  end
82
87
  end
83
88
 
84
89
  context 'when path directory contains valid files' do
85
- let(:files) { %w(file1 file2) }
86
90
  before do
87
- allow(Dir).to receive(:foreach).and_yield(files[0]).and_yield(files[1])
91
+ allow(Dir).to receive(:foreach).and_yield(file_1.name).and_yield(file_2.name)
88
92
  allow(File).to receive(:file?).twice.and_return(true)
93
+ allow(File).to receive(:zero?).twice.and_return(false)
89
94
  end
90
95
 
91
96
  it 'should count all files' do
92
97
  expect(subject.size).to eq(2)
93
98
  end
94
99
 
95
- it 'should list all files' do
96
- expect(subject.all).to eq(files)
97
- end
100
+ describe "ordering" do
101
+ let(:file_2) { double('file', name: 'alpha') }
102
+ let(:file_1) { double('file', name: 'zeta') }
103
+ let(:ordered_files) { [file_2.name, file_1.name] }
98
104
 
99
- describe 'iterating over files list' do
100
105
  it 'should yield files in order' do
101
106
  i = 0
102
107
  subject.each do | file |
103
- expect(file).to eq(files[i])
108
+ expect(file.name).to eq(ordered_files[i])
104
109
  i += 1
105
110
  end
106
111
  end
@@ -109,35 +114,22 @@ describe Ferver::FileList do
109
114
 
110
115
  describe 'requesting files' do
111
116
  before(:each) do
112
- allow(Dir).to receive(:foreach).and_yield('file1').and_yield('file2')
117
+ allow(Dir).to receive(:foreach).and_yield(file_1.name).and_yield(file_2.name)
113
118
  allow(File).to receive(:file?).and_return(true)
119
+ allow(File).to receive(:zero?).and_return(false)
114
120
  end
115
121
 
116
122
  context 'when requesting valid file_id' do
117
- # TODO: possible to redesign this
118
-
119
- it '#file_id_valid? should return true for first file' do
120
- expect(subject.file_id_valid?(0)).to be_truthy
121
- end
122
-
123
- it '#file_id_valid? should return true for second file' do
124
- expect(subject.file_id_valid?(1)).to be_truthy
125
- end
126
-
127
123
  it '#file_by_id should return the correct file for the first file' do
128
- expect(subject.file_by_id(0)).to eq('file1')
124
+ expect(subject.file_by_id(0).name).to eq(file_1.name)
129
125
  end
130
126
 
131
127
  it '#file_by_id should return the correct file for the second file' do
132
- expect(subject.file_by_id(1)).to eq('file2')
128
+ expect(subject.file_by_id(1).name).to eq(file_2.name)
133
129
  end
134
130
  end
135
131
 
136
132
  context 'when requesting invalid file_id' do
137
- it 'should return false for invalid file_id' do
138
- expect(subject.file_id_valid?(2)).to be_falsey
139
- end
140
-
141
133
  it 'should raise_error if file_by_id is called' do
142
134
  expect { subject.file_by_id(2) }.to raise_error(IndexError)
143
135
  end
@@ -29,6 +29,7 @@ Spork.prefork do
29
29
 
30
30
  RSpec.configure do |config|
31
31
  config.include Rack::Test::Methods
32
+ config.include RSpecHtmlMatchers
32
33
  end
33
34
 
34
35
  def app
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ferver
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Murray
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-15 00:00:00.000000000 Z
11
+ date: 2015-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -163,6 +163,7 @@ files:
163
163
  - lib/ferver/directory_not_found_error.rb
164
164
  - lib/ferver/file_id_request.rb
165
165
  - lib/ferver/file_list.rb
166
+ - lib/ferver/found_file.rb
166
167
  - lib/ferver/version.rb
167
168
  - lib/ferver/views/index.erb
168
169
  - spec/configuration_spec.rb
@@ -190,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
191
  version: '0'
191
192
  requirements: []
192
193
  rubyforge_project:
193
- rubygems_version: 2.4.4
194
+ rubygems_version: 2.4.8
194
195
  signing_key:
195
196
  specification_version: 4
196
197
  summary: A simple web app to serve files over HTTP.