Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ end
namespace :clobber do
desc "remove generated rbc files"
task :rbc do
Dir['**/*.rbc'].each {|f| File.delete(f)}
Dir['**/*.rbc'].each { |f| File.delete(f) }
end
end

Expand All @@ -40,7 +40,7 @@ with_changelog_in_features = lambda do |&block|
end

desc "Push docs/cukes to relishapp using the relish-client-gem"
task :relish, :version do |t, args|
task :relish, :version do |_t, args|
raise "rake relish[VERSION]" unless args[:version]

with_changelog_in_features.call do
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/allocations/1_object_1000_mocks.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require_relative "helper"
symbols = (1..1000).map {|x| :"#{x}"}
symbols = (1..1000).map { |x| :"#{x}" }

benchmark_allocations do
o = Object.new
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/allocations/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'rspec/mocks/standalone'

def benchmark_allocations(burn: 1)
stats = AllocationStats.new(burn: burn).trace do
stats = AllocationStats.new(:burn => burn).trace do
yield
end

Expand All @@ -13,5 +13,5 @@ def benchmark_allocations(burn: 1)
[:class_plus]
end

puts stats.allocations(alias_paths: true).group_by(*columns).from_pwd.sort_by_size.to_text
puts stats.allocations(:alias_paths => true).group_by(*columns).from_pwd.sort_by_size.to_text
end
9 changes: 4 additions & 5 deletions benchmarks/each_value_v_values_each.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'benchmark'

n = 10000
n = 10_000

m = 1.upto(1000).reduce({}) {|m, i| m[i] = i; m}
m = 1.upto(1000).inject({}) { |m, i| m[i] = i; m }

Benchmark.benchmark do |bm|
puts "#{n} times - ruby #{RUBY_VERSION}"
Expand All @@ -13,7 +13,7 @@
3.times do
bm.report do
n.times do
m.each_value {|v|}
m.each_value {}
end
end
end
Expand All @@ -24,7 +24,7 @@
3.times do
bm.report do
n.times do
m.values.each{|v|}
m.values.each {}
end
end
end
Expand All @@ -43,7 +43,6 @@
# 0.910000 0.010000 0.920000 ( 0.909319)
# 0.910000 0.000000 0.910000 ( 0.911225)


# $ ruby benchmarks/values_each_v_each_value.rb
# 10000 times - ruby 2.0.0
#
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/find_original_method_early.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

require 'benchmark'

n = 10000
n = 10_000

Foo = Class.new(Object) do
n.times do |i|
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/method_defined_at_any_visibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

Foo = Class.new do
1.upto(n) do |i|
define_method(:"public_method_#{i}") { }
define_method(:"protected_method_#{i}") { }
define_method(:"public_method_#{i}") {}
define_method(:"protected_method_#{i}") {}
protected :"protected_method_#{i}"
define_method(:"private_method_#{i}") { }
define_method(:"private_method_#{i}") {}
private :"protected_method_#{i}"
end
end
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/thread_safety.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
bm.report("fetching a proxy") do
RSpec::Mocks.with_temporary_scope do
o = Object.new
100000.times {
100_000.times {
RSpec::Mocks.space.proxy_for(o)
}
end
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/transfer_nested_constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'benchmark'
require 'rspec/mocks'

N = ENV.fetch('N', 10000).to_i
N = ENV.fetch('N', 10_000).to_i
M = ENV.fetch('M', 5).to_i

puts "#{N} times, #{M} constants - ruby #{RUBY_VERSION}"
Expand Down
8 changes: 4 additions & 4 deletions features/step_definitions/additional_cli_steps.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Then /^the example(?:s)? should(?: all)? pass$/ do
step %q{the output should contain "0 failures"}
step %q{the exit status should be 0}
step %q(the output should contain "0 failures")
step %q(the exit status should be 0)
end

Then /^the examples should all fail, producing the following output:$/ do |table|
step %q{the exit status should be 1}
step %q(the exit status should be 1)
examples, failures = all_output.match(/(\d+) examples?, (\d+) failures?/).captures.map(&:to_i)

expect(examples).to be > 0
Expand All @@ -15,7 +15,7 @@
end

Then /^it should fail with the following output:$/ do |table|
step %q{the exit status should be 1}
step %q(the exit status should be 1)
lines = table.raw.flatten.reject(&:empty?)
expect(all_output).to include(*lines)
end
4 changes: 2 additions & 2 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
end

Aruba.configure do |config|
config.before_cmd do |cmd|
config.before_cmd do
set_env('JRUBY_OPTS', "-X-C #{ENV['JRUBY_OPTS']}") # disable JIT since these processes are so short lived
end
end if RUBY_PLATFORM == 'java'

Aruba.configure do |config|
config.before_cmd do |cmd|
config.before_cmd do
set_env('RBXOPT', "-Xint=true #{ENV['RBXOPT']}") # disable JIT since these processes are so short lived
end
end if defined?(Rubinius)
2 changes: 1 addition & 1 deletion features/support/rubinius.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Required until https://github.com/rubinius/rubinius/issues/2430 is resolved
ENV['RBXOPT'] = "#{ENV["RBXOPT"]} -Xcompiler.no_rbc"

Around "@unsupported-on-rbx" do |scenario, block|
Around "@unsupported-on-rbx" do |_scenario, block|
block.call unless defined?(Rubinius)
end
4 changes: 2 additions & 2 deletions spec/rspec/mocks/and_call_original_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def inst.foo; :bar; end
expect(sub_sub_klass.foo).to eq(:bar)
end

it "finds the method on the most direct ancestor even if the method " +
it "finds the method on the most direct ancestor even if the method " \
"is available on more distant ancestors" do
klass.extend Module.new { def foo; :klass_bar; end }
sub_klass = Class.new(klass)
Expand All @@ -110,7 +110,7 @@ def inst.foo; :bar; end
expect(sub_klass.foo).to eq(:sub_klass_bar)
end

it "finds the method on the most direct singleton class ancestors even if the method " +
it "finds the method on the most direct singleton class ancestors even if the method " \
"is available on more distant ancestors" do
klass.extend Module.new { def foo; :klass_bar; end }
sub_klass = Class.new(klass) { def self.foo; :sub_klass_bar; end }
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/mocks/and_wrap_original_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def results
it "can be constrained by specific arguments" do
allow_it.to receive(:results) { :all }
allow_it.to receive(:results).with(5).and_wrap_original { |m, n| m.call.first(n) }
expect(instance.results 5).to eq [1,2,3,4,5]
expect(instance.results 5).to eq [1, 2, 3, 4, 5]
expect(instance.results).to eq :all
end
end
Expand Down
8 changes: 3 additions & 5 deletions spec/rspec/mocks/and_yield_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

it "evaluates the supplied block as it is read" do
evaluated = false
allow(obj).to receive(:method_that_accepts_a_block).and_yield do |eval_context|
allow(obj).to receive(:method_that_accepts_a_block).and_yield do |_eval_context|
evaluated = true
end
expect(evaluated).to be_truthy
Expand Down Expand Up @@ -145,17 +145,15 @@
expect(yielded_arg).to receive(:bar)
end

obj.method_that_accepts_a_block do |obj|
# obj.bar is not called here
obj.method_that_accepts_a_block do |_obj|
# _obj.bar is not called here
# foo is not called here
end

expect { verify configured_eval_context }.to fail
expect { verify yielded_arg }.to fail
end

end

end
end
end
14 changes: 7 additions & 7 deletions spec/rspec/mocks/any_instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
module RSpec
module Mocks
RSpec.describe "#any_instance" do
class CustomErrorForAnyInstanceSpec < StandardError;end
class CustomErrorForAnyInstanceSpec < StandardError; end

let(:klass) do
Class.new do
def existing_method; :existing_method_return_value; end
def existing_method_with_arguments(arg_one, arg_two = nil); :existing_method_with_arguments_return_value; end
def existing_method_with_arguments(_a, _b=nil); :existing_method_with_arguments_return_value; end
def another_existing_method; end
private
private
def private_method; :private_method_return_value; end
end
end
let(:existing_method_return_value){ :existing_method_return_value }
let(:existing_method_return_value) { :existing_method_return_value }

context "invocation order" do
context "when stubbing" do
Expand Down Expand Up @@ -310,13 +310,13 @@ def private_method; :private_method_return_value; end

it "works with the non-standard constructor module" do
allow_any_instance_of(Module).to receive(:foo).and_return(1)
module RSpec::SampleRspecTestModule;end
module RSpec::SampleRspecTestModule; end
expect(RSpec::SampleRspecTestModule.foo).to eq(1)
end

it "works with the non-standard constructor class" do
allow_any_instance_of(Class).to receive(:foo).and_return(1)
class RSpec::SampleRspecTestClass;end
class RSpec::SampleRspecTestClass; end
expect(RSpec::SampleRspecTestClass.foo).to eq(1)
end
end
Expand Down Expand Up @@ -1170,7 +1170,7 @@ def call(*args)

it "doesn't fail when dup accepts parameters" do
klazz = Class.new do
def dup(funky_option)
def dup(_)
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/rspec/mocks/argument_matchers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,14 @@ module Mocks
it "fails array_including when args aren't array", :reset => true do
expect(a_double).to receive(:msg).with(array_including(1, 2, 3))
expect {
a_double.msg(1, 2, 3)
a_double.msg(1, 2, 3)
}.to fail_including "expected: (array_including(1, 2, 3))"
end

it "fails array_including when arg doesn't contain all elements", :reset => true do
expect(a_double).to receive(:msg).with(array_including(1, 2, 3))
expect {
a_double.msg([1, 2])
a_double.msg([1, 2])
}.to fail_including "expected: (array_including(1, 2, 3))"
end
end
Expand Down Expand Up @@ -429,7 +429,7 @@ def ==(other)

it "fails with zero arguments", :reset => true do
expect do
expect(a_double).to receive(:msg).with {|arg| expect(arg).to eq :received }
expect(a_double).to receive(:msg).with { |arg| expect(arg).to eq :received }
end.to raise_error(ArgumentError, /must have at least one argument/)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/mocks/array_including_matcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module ArgumentMatchers

context "failing" do
it "fails when not all the entries in the expected are present" do
expect(array_including(1,2,3,4,5)).not_to be === [1,2]
expect(array_including(1, 2, 3, 4, 5)).not_to be === [1, 2]
end

it "fails when passed a composed matcher is pased and not satisfied" do
Expand Down
4 changes: 2 additions & 2 deletions spec/rspec/mocks/block_return_value_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
it 'forwards all given args to the block, even when it receives a block' do
obj = Object.new
yielded_args = []
allow(obj).to receive(:foo) { |*args, &bl| yielded_args << args }
allow(obj).to receive(:foo) { |*args, &_| yielded_args << args }
obj.foo(1, 2, 3)

expect(yielded_args).to eq([[1, 2, 3]])
Expand All @@ -43,7 +43,7 @@

it "returns the value of executing the block with given argument" do
obj = Object.new
allow(obj).to receive(:foo).with('baz') {|x| 'bar' + x }
allow(obj).to receive(:foo).with('baz') { |x| 'bar' + x }
expect(obj.foo('baz')).to eq('barbaz')
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def verify_combined_implementation
expect(dbl).to receive(:foo).twice { @block_called = true }
end

the_double.foo { |a| } # to ensure it is called twice
the_double.foo { |_| } # to ensure it is called twice
end

it 'works when passing a block to `ordered`' do
Expand Down Expand Up @@ -166,7 +166,7 @@ def verify_combined_implementation
expect(RSpec).not_to receive(:warning)

obj = Object.new
stub = allow(obj).to receive(:foo) { }
stub = allow(obj).to receive(:foo) {}
stub.with(1)
end

Expand All @@ -191,7 +191,7 @@ def verify_combined_implementation
expect { stubbed.and_raise("a") }.to raise_error(msg_fragment)
expect { stubbed.and_throw(:bar) }.to raise_error(msg_fragment)

expect { stubbed.once { } }.to raise_error(msg_fragment)
expect { stubbed.once {} }.to raise_error(msg_fragment)

expect(dbl.size).to eq(3)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/mocks/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Mocks
let(:mod_1) { Module.new }
let(:mod_2) { Module.new }

def instance_methods_of(mod)
def instance_methods_of(_mod)
mod_1.instance_methods.map(&:to_sym)
end

Expand Down
Loading