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

Remove pretend-nils #843

Merged
merged 3 commits into from
Nov 13, 2021
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
2 changes: 1 addition & 1 deletion lib/aruba/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def initialize
end

def inspect
"nil"
"aruba console"
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/aruba/cucumber/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
end

Then(/^the exit status should( not)? be (\d+)$/) do |negated, exit_status|
last_command_started.stop if last_command_stopped.nil?
last_command_started.stop if last_command_stopped.empty?

if negated
expect(last_command_stopped).not_to have_exit_status exit_status.to_i
Expand Down
20 changes: 7 additions & 13 deletions lib/aruba/matchers/command/have_exit_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,27 @@
# end
RSpec::Matchers.define :have_exit_status do |expected|
match do |actual|
@old_actual = actual
actual.stop
@actual_exit_status = actual.exit_status

@old_actual.stop
@actual = actual.exit_status

unless @old_actual.respond_to? :exit_status
raise "Expected #{@old_actual} to respond to #exit_status"
end

values_match? expected, @actual
values_match? expected, @actual_exit_status
end

failure_message do |actual|
format(
%(expected that command "%s" has exit status of "%s", but has "%s".),
@old_actual.commandline,
actual.commandline,
expected.to_s,
actual.to_s
@actual_exit_status.to_s
)
end

failure_message_when_negated do |actual|
format(
%(expected that command "%s" does not have exit status of "%s", but has "%s".),
@old_actual.commandline,
actual.commandline,
expected.to_s,
actual.to_s
@actual_exit_status.to_s
)
end
end
4 changes: 2 additions & 2 deletions lib/aruba/platforms/command_monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CommandMonitor
attr_reader :registered_commands, :last_command_started, :last_command_stopped

class DefaultLastCommandStopped
def nil?
def empty?
true
end

Expand All @@ -29,7 +29,7 @@ def respond_to_missing?(*)
end

class DefaultLastCommandStarted
def nil?
def empty?
true
end

Expand Down
4 changes: 4 additions & 0 deletions lib/aruba/processes/basic_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ def arguments
[]
end

def empty?
false
end

private

def truncate(string, max_length)
Expand Down