redd 0.6.5 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +34 -33
  3. data/.rspec +3 -4
  4. data/.rubocop.yml +5 -5
  5. data/.travis.yml +9 -7
  6. data/{LICENSE.md → LICENSE.txt} +22 -22
  7. data/README.md +126 -241
  8. data/Rakefile +5 -6
  9. data/{RedditKit.LICENSE.md → RedditKit.LICENSE.txt} +13 -13
  10. data/lib/redd.rb +50 -4
  11. data/lib/redd/access.rb +76 -0
  12. data/lib/redd/clients/base.rb +178 -0
  13. data/lib/redd/clients/base/account.rb +20 -0
  14. data/lib/redd/clients/base/identity.rb +22 -0
  15. data/lib/redd/clients/base/none.rb +27 -0
  16. data/lib/redd/clients/base/privatemessages.rb +28 -0
  17. data/lib/redd/clients/base/read.rb +66 -0
  18. data/lib/redd/clients/base/stream.rb +74 -0
  19. data/lib/redd/clients/base/submit.rb +54 -0
  20. data/lib/redd/clients/base/utilities.rb +80 -0
  21. data/lib/redd/clients/base/wikiread.rb +33 -0
  22. data/lib/redd/clients/installed.rb +55 -0
  23. data/lib/redd/clients/script.rb +37 -0
  24. data/lib/redd/clients/userless.rb +31 -0
  25. data/lib/redd/clients/web.rb +57 -0
  26. data/lib/redd/error.rb +138 -153
  27. data/lib/redd/objects/base.rb +36 -0
  28. data/lib/redd/objects/comment.rb +22 -0
  29. data/lib/redd/objects/listing.rb +29 -0
  30. data/lib/redd/objects/more_comments.rb +10 -0
  31. data/lib/redd/objects/private_message.rb +18 -0
  32. data/lib/redd/objects/submission.rb +72 -0
  33. data/lib/redd/objects/subreddit.rb +152 -0
  34. data/lib/redd/objects/thing.rb +33 -0
  35. data/lib/redd/objects/thing/editable.rb +22 -0
  36. data/lib/redd/objects/thing/hideable.rb +18 -0
  37. data/lib/redd/objects/thing/inboxable.rb +25 -0
  38. data/lib/redd/objects/thing/messageable.rb +34 -0
  39. data/lib/redd/objects/thing/moderatable.rb +43 -0
  40. data/lib/redd/objects/thing/refreshable.rb +14 -0
  41. data/lib/redd/objects/thing/saveable.rb +21 -0
  42. data/lib/redd/objects/thing/votable.rb +33 -0
  43. data/lib/redd/objects/user.rb +52 -0
  44. data/lib/redd/objects/wiki_page.rb +15 -0
  45. data/lib/redd/rate_limit.rb +50 -49
  46. data/lib/redd/response/parse_json.rb +17 -33
  47. data/lib/redd/response/raise_error.rb +16 -25
  48. data/lib/redd/version.rb +4 -5
  49. data/redd.gemspec +30 -31
  50. data/spec/redd/objects/base_spec.rb +1 -0
  51. data/spec/redd/rate_limit_spec.rb +29 -29
  52. data/spec/redd/response/parse_json_spec.rb +12 -0
  53. data/spec/redd/response/raise_error_spec.rb +11 -0
  54. data/spec/redd_spec.rb +7 -5
  55. data/spec/spec_helper.rb +69 -50
  56. metadata +73 -136
  57. data/.yardopts +0 -1
  58. data/lib/redd/base.rb +0 -56
  59. data/lib/redd/client/authenticated.rb +0 -83
  60. data/lib/redd/client/authenticated/account.rb +0 -13
  61. data/lib/redd/client/authenticated/apps.rb +0 -13
  62. data/lib/redd/client/authenticated/flair.rb +0 -71
  63. data/lib/redd/client/authenticated/gold.rb +0 -13
  64. data/lib/redd/client/authenticated/links_comments.rb +0 -189
  65. data/lib/redd/client/authenticated/live.rb +0 -13
  66. data/lib/redd/client/authenticated/moderation.rb +0 -126
  67. data/lib/redd/client/authenticated/multis.rb +0 -9
  68. data/lib/redd/client/authenticated/private_messages.rb +0 -73
  69. data/lib/redd/client/authenticated/subreddits.rb +0 -172
  70. data/lib/redd/client/authenticated/users.rb +0 -9
  71. data/lib/redd/client/authenticated/wiki.rb +0 -9
  72. data/lib/redd/client/oauth2.rb +0 -71
  73. data/lib/redd/client/oauth2/authorization.rb +0 -108
  74. data/lib/redd/client/oauth2/identity.rb +0 -16
  75. data/lib/redd/client/oauth2_script.rb +0 -24
  76. data/lib/redd/client/oauth2_script/authorization.rb +0 -21
  77. data/lib/redd/client/unauthenticated.rb +0 -118
  78. data/lib/redd/client/unauthenticated/account.rb +0 -30
  79. data/lib/redd/client/unauthenticated/captcha.rb +0 -27
  80. data/lib/redd/client/unauthenticated/links_comments.rb +0 -60
  81. data/lib/redd/client/unauthenticated/listing.rb +0 -65
  82. data/lib/redd/client/unauthenticated/live.rb +0 -9
  83. data/lib/redd/client/unauthenticated/moderation.rb +0 -26
  84. data/lib/redd/client/unauthenticated/subreddits.rb +0 -49
  85. data/lib/redd/client/unauthenticated/users.rb +0 -67
  86. data/lib/redd/client/unauthenticated/utilities.rb +0 -109
  87. data/lib/redd/client/unauthenticated/wiki.rb +0 -33
  88. data/lib/redd/oauth2_access.rb +0 -70
  89. data/lib/redd/object/comment.rb +0 -74
  90. data/lib/redd/object/listing.rb +0 -29
  91. data/lib/redd/object/more_comments.rb +0 -14
  92. data/lib/redd/object/private_message.rb +0 -35
  93. data/lib/redd/object/submission.rb +0 -94
  94. data/lib/redd/object/subreddit.rb +0 -74
  95. data/lib/redd/object/user.rb +0 -34
  96. data/lib/redd/object/wiki_page.rb +0 -27
  97. data/lib/redd/thing.rb +0 -27
  98. data/lib/redd/thing/commentable.rb +0 -27
  99. data/lib/redd/thing/editable.rb +0 -16
  100. data/lib/redd/thing/hideable.rb +0 -16
  101. data/lib/redd/thing/inboxable.rb +0 -20
  102. data/lib/redd/thing/messageable.rb +0 -12
  103. data/lib/redd/thing/moderatable.rb +0 -32
  104. data/lib/redd/thing/reportable.rb +0 -12
  105. data/lib/redd/thing/saveable.rb +0 -16
  106. data/lib/redd/thing/voteable.rb +0 -22
  107. data/spec/README.md +0 -18
  108. data/spec/redd/base_spec.rb +0 -36
  109. data/spec/redd/client/authenticated/account_spec.rb +0 -5
  110. data/spec/redd/client/authenticated/apps_spec.rb +0 -2
  111. data/spec/redd/client/authenticated/flair_spec.rb +0 -26
  112. data/spec/redd/client/authenticated/gold_spec.rb +0 -2
  113. data/spec/redd/client/authenticated/links_comments_spec.rb +0 -231
  114. data/spec/redd/client/authenticated/live_spec.rb +0 -2
  115. data/spec/redd/client/unauthenticated/account_spec.rb +0 -15
  116. data/spec/redd/client/unauthenticated/captcha_spec.rb +0 -23
  117. data/spec/redd/client/unauthenticated/links_comments_spec.rb +0 -28
  118. data/spec/redd/client/unauthenticated/listing_spec.rb +0 -23
  119. data/spec/redd/client/unauthenticated/live_spec.rb +0 -2
  120. data/spec/redd/client/unauthenticated/moderation_spec.rb +0 -14
  121. data/spec/redd/client/unauthenticated/subreddits_spec.rb +0 -35
  122. data/spec/redd/client/unauthenticated/users_spec.rb +0 -34
  123. data/spec/redd/client/unauthenticated/wiki_spec.rb +0 -18
  124. data/spec/redd/oauth2_access_spec.rb +0 -83
  125. 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
@@ -1,49 +1,50 @@
1
- module Redd
2
- # The class that handles rate limiting for reddit. reddit does supply
3
- # X-Ratelimit headers but only when logged in and using those headers instead
4
- # would just lead to short bursts, so it's better to go at a constant speed
5
- # and space out requests every 2 seconds.
6
- #
7
- # If you'd rather have short bursts or no rate limiting at all, it's easy to
8
- # write one yourself. A rate limiting class is any class that has an
9
- # {#after_limit} method. The block returns a Faraday::Response object, so you
10
- # can also extract the headers from the response and use those instead. To
11
- # remove rate limiting entirely, follow the example below.
12
- #
13
- # @example No Rate Limiting
14
- # class IWantToGetIPBanned
15
- # def after_limit
16
- # yield
17
- # end
18
- # end
19
- #
20
- # client = Redd::Unauthenticated.new(rate_limit: IWantToGetIPBanned.new)
21
- #
22
- # @note The class itself doesn't perform the rate limiting but only acts
23
- # as an updatable container for the values.
24
- class RateLimit
25
- # @!attribute [r] last_request_time
26
- # @return [String] The time when the last request took place.
27
- attr_reader :last_request_time
28
-
29
- # @param [Float, Integer] gap The minimum time between each request.
30
- def initialize(gap = 2)
31
- # Some time ages ago, because we never made a request.
32
- @last_request_time = Time.at(0)
33
- @gap = gap
34
- end
35
-
36
- # Sleep until 2 seconds have passed since the last request and perform the
37
- # given request.
38
- #
39
- # @yield A block.
40
- # @return The return value of the block.
41
- def after_limit
42
- seconds_passed = Time.now - @last_request_time
43
- wait_time = @gap - seconds_passed
44
- sleep(wait_time) if wait_time > 0
45
- @last_request_time = Time.now
46
- yield
47
- end
48
- end
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 "faraday_middleware"
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.
7
- class ParseJson < Faraday::Middleware
8
- dependency do
9
- require "multi_json" unless defined?(::MultiJson)
10
- end
11
-
12
- # Call the middleware.
13
- # @param faraday
14
- def call(faraday)
15
- @app.call(faraday).on_complete do |env|
16
- env[:body] = parse(env[:body])
17
- end
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 "faraday_middleware"
2
- require "redd/error"
3
-
4
- module Redd
5
- module Response
6
- # Raises the appropriate error when one comes up.
7
- class RaiseError < Faraday::Middleware
8
- # Call the middleware.
9
- # @param faraday
10
- def call(faraday)
11
- @app.call(faraday).on_complete do |env|
12
- error = Redd::Error.from_response(env)
13
- if error
14
- if error == Redd::Error::RateLimited
15
- time = env.body[:json][:ratelimit]
16
- fail error.new(env, time)
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
- # The main Redd module.
2
- module Redd
3
- # The semantic version number for Redd.
4
- VERSION = "0.6.5"
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 |s|
7
- s.name = "redd"
8
- s.version = Redd::VERSION
9
- s.authors = ["Avinash Dwarapu"]
10
- s.email = ["d.nash.avi@gmail.com"]
11
- s.summary = "A Reddit API Wrapper for Ruby."
12
- s.description = "A Reddit API Wrapper for Ruby."
13
- s.homepage = ""
14
- s.license = "MIT"
15
-
16
- s.files = `git ls-files -z`.split("\x0")
17
- s.executables = s.files.grep(/^bin\//) { |f| File.basename(f) }
18
- s.test_files = s.files.grep(/^(test|spec|features)\//)
19
- s.require_paths = ["lib"]
20
-
21
- s.add_development_dependency "bundler"
22
- s.add_development_dependency "rake"
23
- s.add_development_dependency "rspec"
24
- s.add_development_dependency "vcr"
25
- s.add_development_dependency "webmock"
26
-
27
- s.add_dependency "faraday", "~> 0.9.0"
28
- s.add_dependency "faraday_middleware", "~> 0.9.1"
29
- s.add_dependency "multi_json", "~> 1.10"
30
- s.add_dependency "memoizable"
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
@@ -0,0 +1,11 @@
1
+ RSpec.describe Redd::Response::RaiseError do
2
+ it "return nil if there's no error" do
3
+ error = subject.on_complete(
4
+ status: 200,
5
+ body: {success: true},
6
+ response_headers: {}
7
+ )
8
+
9
+ expect(error).to be(nil)
10
+ end
11
+ end
data/spec/redd_spec.rb CHANGED
@@ -1,5 +1,7 @@
1
- describe Redd do
2
- it "has a semantic version number" do
3
- expect(Redd::VERSION).to match(/\d\.\d\.\d/)
4
- end
5
- end
1
+ require "redd/version"
2
+
3
+ RSpec.describe Redd do
4
+ it "has a version number" do
5
+ expect(Redd::VERSION).to be_a(String)
6
+ end
7
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,50 +1,69 @@
1
- require "rspec"
2
- require "webmock"
3
- require "vcr"
4
-
5
- require "redd"
6
-
7
- def test_username; ENV["REDDIT_USERNAME"]; end
8
- def test_password; ENV["REDDIT_PASSWORD"]; end
9
- def test_subreddit; ENV["REDDIT_SUBREDDIT"]; end
10
-
11
- def test_link_id; ENV["REDDIT_LINKID"] || "t3_2gngbm"; end
12
- def test_wikipage; ENV["REDDIT_WIKIPAGE"] || "redd_wiki_test"; end
13
-
14
- def unauthenticated_client
15
- $unauthenticated_client ||= Redd::Client::Unauthenticated.new
16
- end
17
-
18
- def authenticated_client
19
- $authenticated_client ||= Redd::Client::Authenticated.new_from_credentials(test_username, test_password)
20
- end
21
-
22
- VCR.configure do |config|
23
- config.cassette_library_dir = "spec/cassettes"
24
- config.default_cassette_options = {record: :new_episodes}
25
- config.hook_into :webmock
26
- config.filter_sensitive_data("<PASSWORD>") { test_password }
27
- end
28
-
29
- RSpec.configure do |config|
30
- config.filter_run :focus
31
- config.run_all_when_everything_filtered = true
32
- config.profile_examples = 10
33
- config.order = :random
34
- Kernel.srand config.seed
35
-
36
- config.expect_with :rspec do |expectations|
37
- expectations.syntax = :expect
38
- end
39
-
40
- config.mock_with :rspec do |mocks|
41
- mocks.syntax = :expect
42
- mocks.verify_partial_doubles = true
43
- end
44
-
45
- config.around :each do |example|
46
- VCR.use_cassette example.metadata[:full_description] do
47
- example.run
48
- end
49
- end
50
- end
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