Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hash argument matching with rspec-mocks 3.10.3 and Ruby 3+. #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion spec/lib/notiffany/notifier/detected_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Notifier
context "when not available" do
before do
allow(foo_mod).to receive(:new).
with(foo: :bar).
with({ foo: :bar }).
and_raise(Notifier::Base::UnavailableError, "something failed")
allow(logger).to receive(:warning)
end
Expand Down
12 changes: 7 additions & 5 deletions spec/lib/notiffany/notifier/growl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,13 @@ def self.switches
it "passes options only Growl can handle" do
expect(growl).to receive(:notify).with(
"Foo",
sticky: true,
priority: 2,
name: "Notiffany",
title: "Waiting",
image: "/tmp/wait.png"
{
sticky: true,
priority: 2,
name: "Notiffany",
title: "Waiting",
image: "/tmp/wait.png"
}
)

subject.notify(
Expand Down
66 changes: 36 additions & 30 deletions spec/lib/notiffany/notifier/rb_notifu_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@ class Notifier
context "with options passed at initialization" do
it "uses these options by default" do
expect(::Notifu).to receive(:show).with(
time: 3,
icon: false,
baloon: false,
nosound: false,
noquiet: false,
xp: false,
title: "Hello",
type: :info,
image: "/tmp/welcome.png",
message: "Welcome to Guard"
{
time: 3,
icon: false,
baloon: false,
nosound: false,
noquiet: false,
xp: false,
title: "Hello",
type: :info,
image: "/tmp/welcome.png",
message: "Welcome to Guard"
}
)

subject.notify("Welcome to Guard", image: "/tmp/welcome.png")
Expand Down Expand Up @@ -79,16 +81,18 @@ class Notifier
context "without additional options" do
it "shows the notification with the default options" do
expect(::Notifu).to receive(:show).with(
time: 3,
icon: false,
baloon: false,
nosound: false,
noquiet: false,
xp: false,
title: "Welcome",
type: :info,
image: "/tmp/welcome.png",
message: "Welcome to Guard"
{
time: 3,
icon: false,
baloon: false,
nosound: false,
noquiet: false,
xp: false,
title: "Welcome",
type: :info,
image: "/tmp/welcome.png",
message: "Welcome to Guard"
}
)

subject.notify("Welcome to Guard",
Expand All @@ -100,16 +104,18 @@ class Notifier
context "with additional options" do
it "can override the default options" do
expect(::Notifu).to receive(:show).with(
time: 5,
icon: true,
baloon: true,
nosound: true,
noquiet: true,
xp: true,
title: "Waiting",
type: :warn,
image: "/tmp/wait.png",
message: "Waiting for something"
{
time: 5,
icon: true,
baloon: true,
nosound: true,
noquiet: true,
xp: true,
title: "Waiting",
type: :warn,
image: "/tmp/wait.png",
message: "Waiting for something"
}
)

subject.notify("Waiting for something",
Expand Down
47 changes: 31 additions & 16 deletions spec/lib/notiffany/notifier/terminal_notifier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module Notiffany

it "uses these options by default" do
expect(TerminalNotifier::Guard).to receive(:execute).
with(false, title: "Hello", type: :success, message: "any message")
with(false, { title: "Hello", type: :success, message: "any message" })

subject.notify("any message")
end
Expand All @@ -46,41 +46,56 @@ module Notiffany
expect(::TerminalNotifier::Guard).to receive(:execute).
with(
false,
title: "Welcome",
type: :success,
message: "any message")
{
title: "Welcome",
type: :success,
message: "any message"
}
)

subject.notify("any message", title: "Welcome")
end
end

it "should call the notifier." do
expect(::TerminalNotifier::Guard).to receive(:execute).
with(false,
title: "any title",
type: :success,
message: "any message")
with(
false,
{
title: "any title",
type: :success,
message: "any message"
}
)

subject.notify("any message", title: "any title")
end

it "should allow the title to be customized" do
expect(::TerminalNotifier::Guard).to receive(:execute).
with(false,
title: "any title",
message: "any message",
type: :error)
with(
false,
{
title: "any title",
message: "any message",
type: :error
}
)

subject.notify("any message", type: :error, title: "any title")
end

context "without a title set" do
it "should show the app name in the title" do
expect(::TerminalNotifier::Guard).to receive(:execute).
with(false,
title: "FooBar Success",
type: :success,
message: "any message")
with(
false,
{
title: "FooBar Success",
type: :success,
message: "any message"
}
)

# TODO: why would anyone set the title explicitly to nil? and also
# expect it to be set to a default value?
Expand Down