Skip to content

Commit ddbed4c

Browse files
committed
Replace mock with double
1 parent b1bc0cf commit ddbed4c

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

.rspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
--color
2-
--fail-fast
32
--order random

Thorfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ class Default < Thor
2525

2626
desc "spec", "Run RSpec code examples"
2727
def spec
28-
exec "rspec --color --format=documentation spec"
28+
exec "rspec spec"
2929
end
3030
end

spec/command_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ def command(options={})
4141
end
4242

4343
it "does not invoke an existing method" do
44-
mock = mock()
45-
expect(mock.class).to receive(:handle_no_command_error).with("to_s")
46-
Thor::DynamicCommand.new('to_s').run(mock)
44+
double = double()
45+
expect(double.class).to receive(:handle_no_command_error).with("to_s")
46+
Thor::DynamicCommand.new('to_s').run(double)
4747
end
4848
end
4949

@@ -57,9 +57,9 @@ def command(options={})
5757

5858
describe "#run" do
5959
it "runs a command by calling a method in the given instance" do
60-
mock = mock()
61-
expect(mock).to receive(:can_has).and_return {|*args| args }
62-
expect(command.run(mock, [1, 2, 3])).to eq([1, 2, 3])
60+
double = double()
61+
expect(double).to receive(:can_has).and_return {|*args| args }
62+
expect(command.run(double, [1, 2, 3])).to eq([1, 2, 3])
6363
end
6464

6565
it "raises an error if the method to be invoked is private" do

spec/thor_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ def boring(*args)
136136
stop_on_unknown_option! :foo, :bar
137137
end
138138
it "affects all specified commands" do
139-
expect(klass.stop_on_unknown_option?(mock :name => "foo")).to be_true
140-
expect(klass.stop_on_unknown_option?(mock :name => "bar")).to be_true
141-
expect(klass.stop_on_unknown_option?(mock :name => "baz")).to be_false
139+
expect(klass.stop_on_unknown_option?(double(:name => "foo"))).to be_true
140+
expect(klass.stop_on_unknown_option?(double(:name => "bar"))).to be_true
141+
expect(klass.stop_on_unknown_option?(double(:name => "baz"))).to be_false
142142
end
143143
end
144144

@@ -148,9 +148,9 @@ def boring(*args)
148148
stop_on_unknown_option! :bar
149149
end
150150
it "affects all specified commands" do
151-
expect(klass.stop_on_unknown_option?(mock :name => "foo")).to be_true
152-
expect(klass.stop_on_unknown_option?(mock :name => "bar")).to be_true
153-
expect(klass.stop_on_unknown_option?(mock :name => "baz")).to be_false
151+
expect(klass.stop_on_unknown_option?(double(:name => "foo"))).to be_true
152+
expect(klass.stop_on_unknown_option?(double(:name => "bar"))).to be_true
153+
expect(klass.stop_on_unknown_option?(double(:name => "baz"))).to be_false
154154
end
155155
end
156156

0 commit comments

Comments
 (0)