Skip to content

Commit

Permalink
Avoid be_truthy / be_falsey
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed Jun 4, 2020
1 parent 183b391 commit 16bb232
Show file tree
Hide file tree
Showing 16 changed files with 111 additions and 110 deletions.
4 changes: 2 additions & 2 deletions features/clear_examples.feature
Expand Up @@ -34,7 +34,7 @@ Feature: Running specs multiple times with different runner options in the same
RSpec.describe "truth" do
describe true do
it "is truthy" do
expect(true).to be_truthy
expect(true).to be(true)
end
it "is not falsy" do
Expand All @@ -48,7 +48,7 @@ Feature: Running specs multiple times with different runner options in the same
end
it "is truthy" do
expect(false).not_to be_truthy
expect(false).not_to be(true)
end
end
end
Expand Down
20 changes: 10 additions & 10 deletions features/configuration/custom_settings.feature
Expand Up @@ -15,17 +15,17 @@ Feature: custom settings
end
it "acts false by default" do
expect(RSpec.configuration.custom_setting).to be_falsey
expect(RSpec.configuration.custom_setting).to be(false)
end
it "is exposed as a predicate" do
expect(RSpec.configuration.custom_setting?).to be_falsey
expect(RSpec.configuration.custom_setting?).to be(false)
end
it "can be overridden" do
RSpec.configuration.custom_setting = true
expect(RSpec.configuration.custom_setting).to be_truthy
expect(RSpec.configuration.custom_setting?).to be_truthy
expect(RSpec.configuration.custom_setting).to be(true)
expect(RSpec.configuration.custom_setting?).to be(true)
end
end
"""
Expand All @@ -41,17 +41,17 @@ Feature: custom settings
RSpec.describe "custom setting" do
it "is true by default" do
expect(RSpec.configuration.custom_setting).to be_truthy
expect(RSpec.configuration.custom_setting).to be(true)
end
it "is exposed as a predicate" do
expect(RSpec.configuration.custom_setting?).to be_truthy
expect(RSpec.configuration.custom_setting?).to be(true)
end
it "can be overridden" do
RSpec.configuration.custom_setting = false
expect(RSpec.configuration.custom_setting).to be_falsey
expect(RSpec.configuration.custom_setting?).to be_falsey
expect(RSpec.configuration.custom_setting).to be(false)
expect(RSpec.configuration.custom_setting?).to be(false)
end
end
"""
Expand All @@ -71,11 +71,11 @@ Feature: custom settings
RSpec.describe "custom setting" do
it "returns the value set in the last cofigure block to get eval'd" do
expect(RSpec.configuration.custom_setting).to be_truthy
expect(RSpec.configuration.custom_setting).to be(true)
end
it "is exposed as a predicate" do
expect(RSpec.configuration.custom_setting?).to be_truthy
expect(RSpec.configuration.custom_setting?).to be(true)
end
end
"""
Expand Down
4 changes: 2 additions & 2 deletions features/example_groups/shared_examples.feature
Expand Up @@ -106,13 +106,13 @@ Feature: shared examples
describe "#include?" do
context "with an item that is in the collection" do
it "returns true" do
expect(collection.include?(7)).to be_truthy
expect(collection.include?(7)).to be(true)
end
end
context "with an item that is not in the collection" do
it "returns false" do
expect(collection.include?(9)).to be_falsey
expect(collection.include?(9)).to be(false)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion features/hooks/around_hooks.feature
Expand Up @@ -219,7 +219,7 @@ Feature: `around` hooks
end
it "runs the example in the correct context" do
expect(included_in_configure_block).to be_truthy
expect(included_in_configure_block).to be(true)
end
end
"""
Expand Down
1 change: 1 addition & 0 deletions lib/rspec/core/world.rb
Expand Up @@ -17,6 +17,7 @@ class World
attr_accessor :non_example_failure

def initialize(configuration=RSpec.configuration)
@wants_to_quit = false
@configuration = configuration
configuration.world = self
@example_groups = []
Expand Down
20 changes: 10 additions & 10 deletions spec/rspec/core/configuration_options_spec.rb
Expand Up @@ -296,16 +296,16 @@
end

describe "--fail-fast" do
it "defaults to false" do
expect(parse_options[:fail_fast]).to be_falsey
it "defaults to nil" do
expect(parse_options[:fail_fast]).to be(nil)
end

it "sets fail_fast on config" do
expect(parse_options("--fail-fast")[:fail_fast]).to be_truthy
it "sets fail_fast to 1 on config" do
expect(parse_options("--fail-fast")[:fail_fast]).to be(1)
end

it "sets fail_fast on config" do
expect(parse_options("--no-fail-fast")[:fail_fast]).to be_falsey
it "sets fail_fast to false on config" do
expect(parse_options("--no-fail-fast")[:fail_fast]).to be(false)
end
end

Expand All @@ -322,12 +322,12 @@
end

describe "--dry-run" do
it "defaults to false" do
expect(parse_options[:dry_run]).to be_falsey
it "defaults to nil" do
expect(parse_options[:dry_run]).to be(nil)
end

it "sets dry_run on config" do
expect(parse_options("--dry-run")[:dry_run]).to be_truthy
expect(parse_options("--dry-run")[:dry_run]).to be(true)
end
end

Expand Down Expand Up @@ -464,7 +464,7 @@ def expect_parsing_to_fail_mentioning_source(source, options=[])

expect(options[:requires]).to eq(["some_file"])
expect(options[:full_description]).to eq([/foo\ bar/])
expect(options[:drb]).to be_truthy
expect(options[:drb]).to be(true)
expect(options[:formatters]).to eq([['global']])
end
end
Expand Down
26 changes: 13 additions & 13 deletions spec/rspec/core/configuration_spec.rb
Expand Up @@ -293,7 +293,7 @@ def mod.configuration; @config ||= Struct.new(:custom_setting).new; end
mod_config.custom_setting = true
end

expect(mod.configuration.custom_setting).to be_truthy
expect(mod.configuration.custom_setting).to be(true)
end

it "raises if framework module doesn't support configuration" do
Expand Down Expand Up @@ -1301,13 +1301,13 @@ def metadata_hash(*args)

describe "#run_all_when_everything_filtered?" do

it "defaults to false" do
expect(config.run_all_when_everything_filtered?).to be_falsey
it "defaults to nil" do
expect(config.run_all_when_everything_filtered?).to be(false)
end

it "can be queried with question method" do
config.run_all_when_everything_filtered = true
expect(config.run_all_when_everything_filtered?).to be_truthy
expect(config.run_all_when_everything_filtered?).to be(true)
end
end

Expand Down Expand Up @@ -1779,14 +1779,14 @@ def metadata_hash(*args)
config_2 = Configuration.new

config_1.full_backtrace = true
expect(config_2.full_backtrace?).to be_falsey
expect(config_2.full_backtrace?).to be(false)
end
end

describe "#backtrace_exclusion_patterns=" do
it "actually receives the new filter values" do
config.backtrace_exclusion_patterns = [/.*/]
expect(config.backtrace_formatter.exclude? "this").to be_truthy
expect(config.backtrace_formatter.exclude? "this").to be(true)
end
end

Expand All @@ -1805,7 +1805,7 @@ def metadata_hash(*args)
describe "#backtrace_exclusion_patterns" do
it "can be appended to" do
config.backtrace_exclusion_patterns << /.*/
expect(config.backtrace_formatter.exclude? "this").to be_truthy
expect(config.backtrace_formatter.exclude? "this").to be(true)
end
end

Expand Down Expand Up @@ -2213,7 +2213,7 @@ def exclude?(line)
end

it "adds a predicate" do
expect(config.custom_option?).to be_falsey
expect(config.custom_option?).to be(false)
end

it "can be overridden" do
Expand All @@ -2232,7 +2232,7 @@ def exclude?(line)
end

it "returns true for the predicate" do
expect(config.custom_option?).to be_truthy
expect(config.custom_option?).to be(true)
end

it "can be overridden with a truthy value" do
Expand Down Expand Up @@ -2269,7 +2269,7 @@ def exclude?(line)

it "delegates the predicate to the other option" do
config.custom_option = true
expect(config.another_custom_option?).to be_truthy
expect(config.another_custom_option?).to be(true)
end
end
end
Expand Down Expand Up @@ -2526,11 +2526,11 @@ def example_numbered(num)
it "forces 'false' value" do
config.add_setting :custom_option
config.custom_option = true
expect(config.custom_option?).to be_truthy
expect(config.custom_option?).to be(true)
config.force :custom_option => false
expect(config.custom_option?).to be_falsey
expect(config.custom_option?).to be(false)
config.custom_option = true
expect(config.custom_option?).to be_falsey
expect(config.custom_option?).to be(false)
end
end

Expand Down

0 comments on commit 16bb232

Please sign in to comment.