redd 0.6.5 → 0.7.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 +4 -4
- data/.gitignore +34 -33
- data/.rspec +3 -4
- data/.rubocop.yml +5 -5
- data/.travis.yml +9 -7
- data/{LICENSE.md → LICENSE.txt} +22 -22
- data/README.md +126 -241
- data/Rakefile +5 -6
- data/{RedditKit.LICENSE.md → RedditKit.LICENSE.txt} +13 -13
- data/lib/redd.rb +50 -4
- data/lib/redd/access.rb +76 -0
- data/lib/redd/clients/base.rb +178 -0
- data/lib/redd/clients/base/account.rb +20 -0
- data/lib/redd/clients/base/identity.rb +22 -0
- data/lib/redd/clients/base/none.rb +27 -0
- data/lib/redd/clients/base/privatemessages.rb +28 -0
- data/lib/redd/clients/base/read.rb +66 -0
- data/lib/redd/clients/base/stream.rb +74 -0
- data/lib/redd/clients/base/submit.rb +54 -0
- data/lib/redd/clients/base/utilities.rb +80 -0
- data/lib/redd/clients/base/wikiread.rb +33 -0
- data/lib/redd/clients/installed.rb +55 -0
- data/lib/redd/clients/script.rb +37 -0
- data/lib/redd/clients/userless.rb +31 -0
- data/lib/redd/clients/web.rb +57 -0
- data/lib/redd/error.rb +138 -153
- data/lib/redd/objects/base.rb +36 -0
- data/lib/redd/objects/comment.rb +22 -0
- data/lib/redd/objects/listing.rb +29 -0
- data/lib/redd/objects/more_comments.rb +10 -0
- data/lib/redd/objects/private_message.rb +18 -0
- data/lib/redd/objects/submission.rb +72 -0
- data/lib/redd/objects/subreddit.rb +152 -0
- data/lib/redd/objects/thing.rb +33 -0
- data/lib/redd/objects/thing/editable.rb +22 -0
- data/lib/redd/objects/thing/hideable.rb +18 -0
- data/lib/redd/objects/thing/inboxable.rb +25 -0
- data/lib/redd/objects/thing/messageable.rb +34 -0
- data/lib/redd/objects/thing/moderatable.rb +43 -0
- data/lib/redd/objects/thing/refreshable.rb +14 -0
- data/lib/redd/objects/thing/saveable.rb +21 -0
- data/lib/redd/objects/thing/votable.rb +33 -0
- data/lib/redd/objects/user.rb +52 -0
- data/lib/redd/objects/wiki_page.rb +15 -0
- data/lib/redd/rate_limit.rb +50 -49
- data/lib/redd/response/parse_json.rb +17 -33
- data/lib/redd/response/raise_error.rb +16 -25
- data/lib/redd/version.rb +4 -5
- data/redd.gemspec +30 -31
- data/spec/redd/objects/base_spec.rb +1 -0
- data/spec/redd/rate_limit_spec.rb +29 -29
- data/spec/redd/response/parse_json_spec.rb +12 -0
- data/spec/redd/response/raise_error_spec.rb +11 -0
- data/spec/redd_spec.rb +7 -5
- data/spec/spec_helper.rb +69 -50
- metadata +73 -136
- data/.yardopts +0 -1
- data/lib/redd/base.rb +0 -56
- data/lib/redd/client/authenticated.rb +0 -83
- data/lib/redd/client/authenticated/account.rb +0 -13
- data/lib/redd/client/authenticated/apps.rb +0 -13
- data/lib/redd/client/authenticated/flair.rb +0 -71
- data/lib/redd/client/authenticated/gold.rb +0 -13
- data/lib/redd/client/authenticated/links_comments.rb +0 -189
- data/lib/redd/client/authenticated/live.rb +0 -13
- data/lib/redd/client/authenticated/moderation.rb +0 -126
- data/lib/redd/client/authenticated/multis.rb +0 -9
- data/lib/redd/client/authenticated/private_messages.rb +0 -73
- data/lib/redd/client/authenticated/subreddits.rb +0 -172
- data/lib/redd/client/authenticated/users.rb +0 -9
- data/lib/redd/client/authenticated/wiki.rb +0 -9
- data/lib/redd/client/oauth2.rb +0 -71
- data/lib/redd/client/oauth2/authorization.rb +0 -108
- data/lib/redd/client/oauth2/identity.rb +0 -16
- data/lib/redd/client/oauth2_script.rb +0 -24
- data/lib/redd/client/oauth2_script/authorization.rb +0 -21
- data/lib/redd/client/unauthenticated.rb +0 -118
- data/lib/redd/client/unauthenticated/account.rb +0 -30
- data/lib/redd/client/unauthenticated/captcha.rb +0 -27
- data/lib/redd/client/unauthenticated/links_comments.rb +0 -60
- data/lib/redd/client/unauthenticated/listing.rb +0 -65
- data/lib/redd/client/unauthenticated/live.rb +0 -9
- data/lib/redd/client/unauthenticated/moderation.rb +0 -26
- data/lib/redd/client/unauthenticated/subreddits.rb +0 -49
- data/lib/redd/client/unauthenticated/users.rb +0 -67
- data/lib/redd/client/unauthenticated/utilities.rb +0 -109
- data/lib/redd/client/unauthenticated/wiki.rb +0 -33
- data/lib/redd/oauth2_access.rb +0 -70
- data/lib/redd/object/comment.rb +0 -74
- data/lib/redd/object/listing.rb +0 -29
- data/lib/redd/object/more_comments.rb +0 -14
- data/lib/redd/object/private_message.rb +0 -35
- data/lib/redd/object/submission.rb +0 -94
- data/lib/redd/object/subreddit.rb +0 -74
- data/lib/redd/object/user.rb +0 -34
- data/lib/redd/object/wiki_page.rb +0 -27
- data/lib/redd/thing.rb +0 -27
- data/lib/redd/thing/commentable.rb +0 -27
- data/lib/redd/thing/editable.rb +0 -16
- data/lib/redd/thing/hideable.rb +0 -16
- data/lib/redd/thing/inboxable.rb +0 -20
- data/lib/redd/thing/messageable.rb +0 -12
- data/lib/redd/thing/moderatable.rb +0 -32
- data/lib/redd/thing/reportable.rb +0 -12
- data/lib/redd/thing/saveable.rb +0 -16
- data/lib/redd/thing/voteable.rb +0 -22
- data/spec/README.md +0 -18
- data/spec/redd/base_spec.rb +0 -36
- data/spec/redd/client/authenticated/account_spec.rb +0 -5
- data/spec/redd/client/authenticated/apps_spec.rb +0 -2
- data/spec/redd/client/authenticated/flair_spec.rb +0 -26
- data/spec/redd/client/authenticated/gold_spec.rb +0 -2
- data/spec/redd/client/authenticated/links_comments_spec.rb +0 -231
- data/spec/redd/client/authenticated/live_spec.rb +0 -2
- data/spec/redd/client/unauthenticated/account_spec.rb +0 -15
- data/spec/redd/client/unauthenticated/captcha_spec.rb +0 -23
- data/spec/redd/client/unauthenticated/links_comments_spec.rb +0 -28
- data/spec/redd/client/unauthenticated/listing_spec.rb +0 -23
- data/spec/redd/client/unauthenticated/live_spec.rb +0 -2
- data/spec/redd/client/unauthenticated/moderation_spec.rb +0 -14
- data/spec/redd/client/unauthenticated/subreddits_spec.rb +0 -35
- data/spec/redd/client/unauthenticated/users_spec.rb +0 -34
- data/spec/redd/client/unauthenticated/wiki_spec.rb +0 -18
- data/spec/redd/oauth2_access_spec.rb +0 -83
- data/spec/redd/thing_spec.rb +0 -22
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require_relative "thing"
|
|
2
|
+
|
|
3
|
+
module Redd
|
|
4
|
+
module Objects
|
|
5
|
+
# A submission made in a subreddit.
|
|
6
|
+
class WikiPage < Thing
|
|
7
|
+
alias_property :content, :content_md
|
|
8
|
+
alias_property :body, :content_md
|
|
9
|
+
|
|
10
|
+
def revision_user
|
|
11
|
+
@revision_by ||= client.object_from_body(revision_by)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/lib/redd/rate_limit.rb
CHANGED
|
@@ -1,49 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
#
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
end
|
|
1
|
+
# The main Redd module.
|
|
2
|
+
module Redd
|
|
3
|
+
# The class that handles rate limiting for reddit. reddit does supply
|
|
4
|
+
# X-Ratelimit headers but using those headers instead would just lead to
|
|
5
|
+
# short bursts, so it's better to go at a constant speed and space out
|
|
6
|
+
# requests every second.
|
|
7
|
+
#
|
|
8
|
+
# If you'd rather have short bursts or no rate limiting at all, it's easy to
|
|
9
|
+
# write one yourself. A rate limiting class is any class that has an
|
|
10
|
+
# {#after_limit} method. The block returns a Faraday::Response object, so you
|
|
11
|
+
# can also extract the headers from the response and use those instead. To
|
|
12
|
+
# remove rate limiting entirely, follow the example below.
|
|
13
|
+
#
|
|
14
|
+
# @example No Rate Limiting
|
|
15
|
+
# class IWantToGetIPBanned
|
|
16
|
+
# def after_limit
|
|
17
|
+
# yield
|
|
18
|
+
# end
|
|
19
|
+
# end
|
|
20
|
+
#
|
|
21
|
+
# client = Redd.it(..., rate_limit: IWantToGetIPBanned.new)
|
|
22
|
+
class RateLimit
|
|
23
|
+
# @!attribute [r] last_request_time
|
|
24
|
+
# @return [Time] The time when the last request took place.
|
|
25
|
+
attr_reader :last_request_time
|
|
26
|
+
|
|
27
|
+
# @!attribute [rw] gap
|
|
28
|
+
# @return [Integer, Float] The minimum time between requests.
|
|
29
|
+
attr_accessor :gap
|
|
30
|
+
|
|
31
|
+
# @param [Float, Integer] gap The minimum time between each request.
|
|
32
|
+
def initialize(gap)
|
|
33
|
+
# Some time ages ago, because we never made a request.
|
|
34
|
+
@last_request_time = Time.at(0)
|
|
35
|
+
@gap = gap
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Sleep until 2 seconds have passed since the last request and perform the
|
|
39
|
+
# given request.
|
|
40
|
+
#
|
|
41
|
+
# @yield A block.
|
|
42
|
+
# @return The return value of the block.
|
|
43
|
+
def after_limit
|
|
44
|
+
wait_time = @last_request_time + @gap - Time.now
|
|
45
|
+
sleep(wait_time) if wait_time > 0
|
|
46
|
+
@last_request_time = Time.now
|
|
47
|
+
yield
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -1,33 +1,17 @@
|
|
|
1
|
-
require "
|
|
2
|
-
|
|
3
|
-
module Redd
|
|
4
|
-
# The module that contains middleware that alters the Faraday response.
|
|
5
|
-
module Response
|
|
6
|
-
# Faraday Middleware that parses JSON using
|
|
7
|
-
class ParseJson < Faraday::Middleware
|
|
8
|
-
dependency
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
private
|
|
21
|
-
|
|
22
|
-
# Parse a JSON string and return a symbolized hash.
|
|
23
|
-
#
|
|
24
|
-
# @param [String] body The JSON string to parse.
|
|
25
|
-
# @return [Hash] A symbolized parsed JSON hash.
|
|
26
|
-
def parse(body)
|
|
27
|
-
MultiJson.load(body, symbolize_keys: true)
|
|
28
|
-
rescue MultiJson::ParseError
|
|
29
|
-
body
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
1
|
+
require "faraday/response"
|
|
2
|
+
|
|
3
|
+
module Redd
|
|
4
|
+
# The module that contains middleware that alters the Faraday response.
|
|
5
|
+
module Response
|
|
6
|
+
# Faraday Middleware that parses JSON using OJ, via MultiJson.
|
|
7
|
+
class ParseJson < Faraday::Response::Middleware
|
|
8
|
+
dependency "multi_json"
|
|
9
|
+
|
|
10
|
+
def parse(body)
|
|
11
|
+
MultiJson.load(body, symbolize_keys: true)
|
|
12
|
+
rescue MultiJson::ParseError
|
|
13
|
+
body
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
require "
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
module Redd
|
|
5
|
-
module
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
else
|
|
18
|
-
fail error.new(env)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
1
|
+
require "faraday/response"
|
|
2
|
+
require_relative "../error"
|
|
3
|
+
|
|
4
|
+
module Redd
|
|
5
|
+
# The module that contains middleware that alters the Faraday response.
|
|
6
|
+
module Response
|
|
7
|
+
# Faraday Middleware that raises an error if there's one.
|
|
8
|
+
# @see Error
|
|
9
|
+
class RaiseError < Faraday::Response::Middleware
|
|
10
|
+
def on_complete(env)
|
|
11
|
+
error = Redd::Error.from_response(env)
|
|
12
|
+
fail error.new(env), env[:body] if error
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/redd/version.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
end
|
|
1
|
+
module Redd # rubocop:disable Style/Documentation
|
|
2
|
+
# The semantic version number.
|
|
3
|
+
VERSION = "0.7.0"
|
|
4
|
+
end
|
data/redd.gemspec
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require "redd/version"
|
|
5
|
-
|
|
6
|
-
Gem::Specification.new do |
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
end
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "redd/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "redd"
|
|
8
|
+
spec.version = Redd::VERSION
|
|
9
|
+
spec.authors = ["Avinash Dwarapu"]
|
|
10
|
+
spec.email = ["avinash@dwarapu.me"]
|
|
11
|
+
spec.summary = "A Reddit API Wrapper for Ruby."
|
|
12
|
+
spec.homepage = "https://github.com/avidw/redd"
|
|
13
|
+
spec.license = "MIT"
|
|
14
|
+
spec.required_ruby_version = ">= 2.1.0"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.8.1"
|
|
22
|
+
spec.add_development_dependency "rake", "~> 10.4.2"
|
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.2.0"
|
|
24
|
+
spec.add_development_dependency "vcr", "~> 2.9.3"
|
|
25
|
+
spec.add_development_dependency "webmock", "~> 1.20.4"
|
|
26
|
+
|
|
27
|
+
spec.add_dependency "hashie", "~> 3.4.0"
|
|
28
|
+
spec.add_dependency "faraday", "~> 0.9.1"
|
|
29
|
+
spec.add_dependency "multi_json", "~> 1.10.1"
|
|
30
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# There's no point in testing Base, since we'd basically be testing Hashie.
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
describe Redd::RateLimit do
|
|
2
|
-
let(:rate_limit) { Redd::RateLimit.new }
|
|
3
|
-
|
|
4
|
-
it "waits two seconds between consecutive requests" do
|
|
5
|
-
rate_limit.after_limit {}
|
|
6
|
-
start_time = Time.now
|
|
7
|
-
rate_limit.after_limit {}
|
|
8
|
-
end_time = Time.now
|
|
9
|
-
|
|
10
|
-
expect(end_time - start_time).to be_within(0.1).of(2)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it "doesn't wait if two seconds have passed since last request" do
|
|
14
|
-
rate_limit.after_limit {}
|
|
15
|
-
sleep(2)
|
|
16
|
-
start_time = Time.now
|
|
17
|
-
rate_limit.after_limit {}
|
|
18
|
-
end_time = Time.now
|
|
19
|
-
|
|
20
|
-
expect(end_time - start_time).to be_within(0.1).of(0)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "stores the time the last request was made" do
|
|
24
|
-
time = Time.now
|
|
25
|
-
rate_limit.after_limit {}
|
|
26
|
-
|
|
27
|
-
expect(rate_limit.last_request_time).to be_within(0.1).of(time)
|
|
28
|
-
end
|
|
29
|
-
end
|
|
1
|
+
RSpec.describe Redd::RateLimit do
|
|
2
|
+
let(:rate_limit) { Redd::RateLimit.new(2) }
|
|
3
|
+
|
|
4
|
+
it "waits two seconds between consecutive requests" do
|
|
5
|
+
rate_limit.after_limit {}
|
|
6
|
+
start_time = Time.now
|
|
7
|
+
rate_limit.after_limit {}
|
|
8
|
+
end_time = Time.now
|
|
9
|
+
|
|
10
|
+
expect(end_time - start_time).to be_within(0.1).of(2)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "doesn't wait if two seconds have passed since last request" do
|
|
14
|
+
rate_limit.after_limit {}
|
|
15
|
+
sleep(2)
|
|
16
|
+
start_time = Time.now
|
|
17
|
+
rate_limit.after_limit {}
|
|
18
|
+
end_time = Time.now
|
|
19
|
+
|
|
20
|
+
expect(end_time - start_time).to be_within(0.1).of(0)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "stores the time the last request was made" do
|
|
24
|
+
time = Time.now
|
|
25
|
+
rate_limit.after_limit {}
|
|
26
|
+
|
|
27
|
+
expect(rate_limit.last_request_time).to be_within(0.1).of(time)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
RSpec.describe Redd::Response::ParseJson do
|
|
2
|
+
it "parses valid JSON" do
|
|
3
|
+
parsed = subject.parse('{"hello": "world", "foo": {"bar": 2}}')
|
|
4
|
+
expect(parsed).to eq(hello: "world", foo: {bar: 2})
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
it "returns the JSON string if it's invalid" do
|
|
8
|
+
error = "comparision with banana failed."
|
|
9
|
+
parsed = subject.parse(error)
|
|
10
|
+
expect(parsed).to eq(error)
|
|
11
|
+
end
|
|
12
|
+
end
|
data/spec/redd_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
|
@@ -1,50 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
require "
|
|
3
|
-
require "
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
config.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
|
2
|
+
require "vcr"
|
|
3
|
+
require "redd"
|
|
4
|
+
|
|
5
|
+
VCR.configure do |config|
|
|
6
|
+
config.cassette_library_dir = "spec/cassettes"
|
|
7
|
+
config.hook_into :webmock
|
|
8
|
+
config.default_cassette_options = {record: :new_episodes}
|
|
9
|
+
config.configure_rspec_metadata!
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
RSpec.configure do |config|
|
|
13
|
+
# rspec-expectations config goes here. You can use an alternate
|
|
14
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
|
15
|
+
# assertions if you prefer.
|
|
16
|
+
config.expect_with :rspec do |expectations|
|
|
17
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
|
18
|
+
# and `failure_message` of custom matchers include text for helper methods
|
|
19
|
+
# defined using `chain`, e.g.:
|
|
20
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
|
21
|
+
# # => "be bigger than 2 and smaller than 4"
|
|
22
|
+
# ...rather than:
|
|
23
|
+
# # => "be bigger than 2"
|
|
24
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
|
28
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
|
29
|
+
config.mock_with :rspec do |mocks|
|
|
30
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
|
31
|
+
# a real object. This is generally recommended, and will default to
|
|
32
|
+
# `true` in RSpec 4.
|
|
33
|
+
mocks.verify_partial_doubles = true
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# These two settings work together to allow you to limit a spec run
|
|
37
|
+
# to individual examples or groups you care about by tagging them with
|
|
38
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
|
39
|
+
# get run.
|
|
40
|
+
config.filter_run_including :focus
|
|
41
|
+
config.run_all_when_everything_filtered = true
|
|
42
|
+
|
|
43
|
+
if ENV["TRAVIS_SECURE_ENV_VARS"] == "false"
|
|
44
|
+
config.filter_run_excluding :secure
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
|
48
|
+
# recommended. For more details, see:
|
|
49
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
|
50
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
|
51
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
|
52
|
+
config.disable_monkey_patching!
|
|
53
|
+
|
|
54
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
|
55
|
+
# be too noisy due to issues in dependencies.
|
|
56
|
+
config.warnings = true
|
|
57
|
+
|
|
58
|
+
# Run specs in random order to surface order dependencies. If you find an
|
|
59
|
+
# order dependency and want to debug it, you can fix the order by providing
|
|
60
|
+
# the seed, which is printed after each run.
|
|
61
|
+
# --seed 1234
|
|
62
|
+
config.order = :random
|
|
63
|
+
|
|
64
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
|
65
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
|
66
|
+
# test failures related to randomization by passing the same `--seed` value
|
|
67
|
+
# as the one that triggered the failure.
|
|
68
|
+
Kernel.srand config.seed
|
|
69
|
+
end
|