Skip to content

Commit

Permalink
Created unit test for Code#translated_code
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmenezesds committed Aug 27, 2023
1 parent b6a2678 commit 424d3b3
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions spec/lrama/grammar/code_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
RSpec.describe Lrama::Grammar::Code do
let(:token_class) { Lrama::Lexer::Token }
let(:user_code_token) { token_class.new(type: T::User_code, s_value: "{ code 1 }") }
let(:initial_act_token) { token_class.new(type: T::P_initial_action, s_value: "%initial-action") }

describe "#translated_code" do
context "when the code type is :user_code" do
it "calls #translated_user_code" do
code = described_class.new(type: :user_code, token_code: user_code_token)

expect(code).to receive(:translated_user_code)

code.translated_code
end
end

context "when the code type is :initial_action" do
it "calls #translated_initial_action_code" do
code = described_class.new(type: :initial_action, token_code: initial_act_token)

expect(code).to receive(:translated_initial_action_code)

code.translated_code
end
end
end
end

0 comments on commit 424d3b3

Please sign in to comment.