Skip to content

Commit

Permalink
Add basic end-to-end rendering.
Browse files Browse the repository at this point in the history
  • Loading branch information
evdevdev committed Aug 28, 2024
1 parent 6448228 commit ef24f73
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/action_prompt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
require "action_prompt/engine"

module ActionPrompt
# Your code goes here...
def self.render(template_name, locals: {})
controller = ApplicationController.new
controller.prepend_view_path(Rails.root.join("app", "prompts"))
controller.render_to_string(template: template_name, locals: locals)
end
end
8 changes: 8 additions & 0 deletions test/action_prompt/base_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require "test_helper"

class ActionPrompt::BaseTest < ActiveSupport::TestCase
test "hello world" do
result = ActionPrompt.render("hello_world")
assert_equal "You are a helpful assistant who replies with, \"Hello, world!\"", result
end
end
1 change: 1 addition & 0 deletions test/dummy/app/prompts/hello_world.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
You are a helpful assistant who replies with, "Hello, world!"

0 comments on commit ef24f73

Please sign in to comment.