module Ammeter::RSpec::Rails::GeneratorExampleHelpers
Delegates to Rails::Generators::TestCase to work with RSpec
.
Public Instance Methods
Source
# File lib/ammeter/rspec/generator/example/generator_example_helpers.rb, line 21 def set_shell_prompt_responses(generator, command_args={}) command_args.each do |k,v| allow(generator.shell).to receive(k.to_sym).and_return(*v) end end
Sets return values for basic shell commands (ex. ask, yes?, no?). Does this by mocking return values using RSpec’s ‘and_return` method
Parameters =====¶ ↑
Generator w/ @shell attribute Hash { command_name: input_value, ask: “Testing”, yes?: true } The values for each element in the hash can be set as an array as well. This will allow for different return values upon each call.
ex. set_shell_prompt_responses
(generator, { yes?: [true, false] }) would respond with true to the first yes? call, but false to the second