Skip to content

Commit

Permalink
Change the way we build the test and its expected results to accomoda…
Browse files Browse the repository at this point in the history
…te for internal changes in ruby 3.3 evaluation of __FILE__ within the eval() call
  • Loading branch information
lacostej committed Dec 1, 2023
1 parent 8f69244 commit b74dc53
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions fastlane/spec/plugins_specs/plugin_generator_spec.rb
Expand Up @@ -111,7 +111,9 @@
end

it "creates a plugin.rb file for the plugin" do
plugin_rb_file = File.join(tmp_dir, gem_name, 'lib', 'fastlane', 'plugin', "#{plugin_name}.rb")
relative_path = File.join('lib', 'fastlane', 'plugin', "#{plugin_name}.rb")
plugin_rb_file = File.join(tmp_dir, gem_name, relative_path)

expect(File.exist?(plugin_rb_file)).to be(true)

plugin_rb_contents = File.read(plugin_rb_file)
Expand All @@ -122,7 +124,10 @@
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

# rubocop:disable Security/Eval
eval(plugin_rb_contents)
# starting with ruby 3.3 we must pass the __FILE__ of the actual file location for the all_class method implementation to work
# also we expand the relative_path within the chdir, as Dir.chdir on Mac will make it so tmp paths will always be under /private,
# while expand_path called from outside of the chdir will not prefix by /private
eval(plugin_rb_contents, binding, File.expand_path(relative_path), __LINE__)
# rubocop:enable Security/Eval

# If we evaluate the contents of the generated plugin.rb file,
Expand Down

0 comments on commit b74dc53

Please sign in to comment.