Skip to content

Commit d4e4d91

Browse files
authored
dev: update readme and test-suite configuration (#690)
This pull request includes updates to the `README.md` file and improvements to the test suite, particularly focusing on the use of `ClimateControl` for environment variable management and some general cleanup. Updates to documentation: * [`README.md`](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L51-R52): Clarified and corrected the usage of environment variables, ensuring they are correctly quoted and formatted. [[1]](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L51-R52) [[2]](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L86-R87) [[3]](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L96-R97) [[4]](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L155-R157) * [`README.md`](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R9): Added a new feature description for providing stable URLs for feeds generated by automatic sourcing. Improvements to test suite: * [`spec/html2rss/web/app_spec.rb`](diffhunk://#diff-090562f30c41a91ba9b59502563d84d791cfb29c288708bd2acc51e7c33e8f10R4): Introduced `ClimateControl` to manage environment variables during tests, replacing direct `ENV` manipulation. [[1]](diffhunk://#diff-090562f30c41a91ba9b59502563d84d791cfb29c288708bd2acc51e7c33e8f10R4) [[2]](diffhunk://#diff-090562f30c41a91ba9b59502563d84d791cfb29c288708bd2acc51e7c33e8f10R43-R54) * [`spec/html2rss/web/helpers/auto_source_spec.rb`](diffhunk://#diff-1c878bb09df33c5882ccb5908063682ecd481c30c7a5d0bf97a8be65cb698548L4-R11): Added `ClimateControl` and corrected the RSpec description format. * [`spec/routes/auto_source_spec.rb`](diffhunk://#diff-c88fcacaf08dea9f6768c205b268876e4b05dc517724faacbc6215eafe37f543L7-R7): Updated to use `RSpec.describe` for consistency. General cleanup: * [`spec/spec_helper.rb`](diffhunk://#diff-89eebfcbc0f14b6d989517837ca1e94fce4e2ce9a03233641cd936f2b8d2ed94L14-L15): Removed the `EnvHelper` module and associated `ClimateControl` support file, as they are no longer needed. [[1]](diffhunk://#diff-89eebfcbc0f14b6d989517837ca1e94fce4e2ce9a03233641cd936f2b8d2ed94L14-L15) [[2]](diffhunk://#diff-89eebfcbc0f14b6d989517837ca1e94fce4e2ce9a03233641cd936f2b8d2ed94L121-L122) [[3]](diffhunk://#diff-77b0d409fb1eaea240996a5f235354d577c0624382f9e7c19fdd075636bfd2a9L1-L9)
2 parents 531dced + d0d9e66 commit d4e4d91

File tree

7 files changed

+22
-26
lines changed

7 files changed

+22
-26
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ tmp/*
22
!tmp/.keep
33
.yardoc
44
coverage
5+
spec/examples.txt

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This web application scrapes websites to build and deliver RSS 2.0 feeds.
66

77
**Features:**
88

9+
- Provides stable URLs for feeds generated by automatic sourcing.
910
- [Create your custom feeds](#how-to-build-your-rss-feeds)!
1011
- Comes with plenty of [included configs](https://github.com/html2rss/html2rss-configs) out of the box.
1112
- Handles request caching.
@@ -48,7 +49,7 @@ services:
4849
RACK_ENV: production
4950
HEALTH_CHECK_USERNAME: health
5051
HEALTH_CHECK_PASSWORD: please-set-YOUR-OWN-veeeeeery-l0ng-aNd-h4rd-to-gue55-Passw0rd!
51-
# AUTO_SOURCE_ENABLED: true
52+
# AUTO_SOURCE_ENABLED: 'true'
5253
# AUTO_SOURCE_USERNAME: foobar
5354
# AUTO_SOURCE_PASSWORD: A-Unique-And-Long-Password-For-Your-Own-Instance
5455
## to allow just requests originating from the local host
@@ -83,7 +84,7 @@ To enable the `auto_source` feature, comment in the env variables in the `docker
8384
```yaml
8485
environment:
8586
## … snip ✁
86-
AUTO_SOURCE_ENABLED: true
87+
AUTO_SOURCE_ENABLED: "true"
8788
AUTO_SOURCE_USERNAME: foobar
8889
AUTO_SOURCE_PASSWORD: A-Unique-And-Long-Password-For-Your-Own-Instance
8990
## to allow just requests originating from the local host
@@ -93,7 +94,7 @@ environment:
9394
## … snap ✃
9495
```
9596

96-
Restart the container and open <http://127.0.0.1:3000/auto_source>.
97+
Restart the container and open <http://127.0.0.1:3000/auto_source/>.
9798
When asked, enter your username and password.
9899

99100
Then enter the URL of a website and click on the _Generate_ button.
@@ -152,8 +153,8 @@ If you're going to host a public instance, _please, please, please_:
152153
| `HEALTH_CHECK_PASSWORD` | default: auto-generated on start |
153154
| | |
154155
| `AUTO_SOURCE_ENABLED` | default: false |
155-
| `AUTO_SOURCE_USERNAME | no default |
156-
| `AUTO_SOURCE_PASSWORD | no default |
156+
| `AUTO_SOURCE_USERNAME` | no default. |
157+
| `AUTO_SOURCE_PASSWORD` | no default. |
157158
| `AUTO_SOURCE_ALLOWED_ORIGINS` | no default. |
158159
| | |
159160
| `PORT` | default: 3000 |

spec/html2rss/web/app_spec.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require 'spec_helper'
4+
require 'climate_control'
45

56
require_relative '../../../app'
67

@@ -39,14 +40,18 @@ def app = described_class
3940
describe '.development?' do
4041
subject { described_class.development? }
4142

43+
around do |example|
44+
ClimateControl.modify(RACK_ENV: env) { example.run }
45+
end
46+
4247
context 'when RACK_ENV is development' do
43-
before { ENV['RACK_ENV'] = 'development' }
48+
let(:env) { 'development' }
4449

4550
it { is_expected.to be true }
4651
end
4752

4853
context 'when RACK_ENV is not development' do
49-
before { ENV['RACK_ENV'] = 'test' }
54+
let(:env) { 'test' }
5055

5156
it { is_expected.to be false }
5257
end

spec/html2rss/web/helpers/auto_source_spec.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# frozen_string_literal: true
22

33
require 'spec_helper'
4-
require 'rss'
5-
require 'roda'
64
require 'base64'
5+
require 'climate_control'
6+
require 'roda'
7+
require 'rss'
8+
79
require_relative '../../../../helpers/auto_source'
810

9-
describe Html2rss::Web::AutoSource do # rubocop:disable RSpec/SpecFilePathFormat
11+
RSpec.describe Html2rss::Web::AutoSource do # rubocop:disable RSpec/SpecFilePathFormat
1012
context 'when ENV variables are not set' do
1113
describe '.enabled?' do
1214
subject { described_class.enabled? }

spec/routes/auto_source_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
require 'rss'
55
require_relative '../../app'
66

7-
describe Html2rss::Web::App do # rubocop:disable RSpec/SpecFilePathFormat
7+
RSpec.describe Html2rss::Web::App do # rubocop:disable RSpec/SpecFilePathFormat
88
include Rack::Test::Methods
99
def app = described_class
1010

spec/spec_helper.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
end
1212
end
1313

14-
require_relative 'support/climate_control'
15-
1614
require 'rack/test'
1715
require 'vcr'
1816

@@ -79,14 +77,14 @@
7977
# # Allows RSpec to persist some state between runs in order to support
8078
# # the `--only-failures` and `--next-failure` CLI options. We recommend
8179
# # you configure your source control system to ignore this file.
82-
# config.example_status_persistence_file_path = "spec/examples.txt"
80+
config.example_status_persistence_file_path = 'spec/examples.txt'
8381
#
8482
# # Limits the available syntax to the non-monkey patched syntax that is
8583
# # recommended. For more details, see:
8684
# # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
8785
# # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
8886
# # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
89-
# config.disable_monkey_patching!
87+
config.disable_monkey_patching!
9088
#
9189
# # This setting enables warnings. It's recommended, but in some cases may
9290
# # be too noisy due to issues in dependencies.
@@ -118,6 +116,4 @@
118116
# # test failures related to randomization by passing the same `--seed` value
119117
# # as the one that triggered the failure.
120118
# Kernel.srand config.seed
121-
122-
config.include(EnvHelper)
123119
end

spec/support/climate_control.rb

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)