Sha256: 44d266de9e2a1117825606750847afc35042d850a26ec0e4adbef9dd0ab62aae

Contents?: true

Size: 1.18 KB

Versions: 8

Compression:

Stored size: 1.18 KB

Contents

require_relative '../../../spec_helper'
require 'tailor/lexer/token'

describe Tailor::Lexer::Token do
  before do
    Tailor::Logger.stub(:log)
  end

  describe "#modifier_keyword?" do
    subject do
      options = { full_line_of_text: full_line_of_text }
      Tailor::Lexer::Token.new("if", options)
    end

    context "the current line has a keyword that is also a modifier" do
      context "the keyword is acting as a modifier" do
        let!(:full_line_of_text) { %q{puts "hi" if true == true} }

        it "returns true" do
          subject.modifier_keyword?.should be_true
        end
      end

      context "they keyword is NOT acting as a modifier" do
        let!(:full_line_of_text) { %q{if true == true; puts "hi"; end} }

        it "returns false" do
          subject.modifier_keyword?.should be_false
        end
      end
    end

    context "the current line doesn't have a keyword" do
      let!(:full_line_of_text) { %q{puts true} }

      subject do
        options = { full_line_of_text: full_line_of_text }
        Tailor::Lexer::Token.new("puts", options)
      end

      it "returns false" do
        subject.modifier_keyword?.should be_false
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
tailor-1.2.1 spec/unit/tailor/lexer/token_spec.rb
tailor-1.2.0 spec/unit/tailor/lexer/token_spec.rb
tailor-1.1.5 spec/unit/tailor/lexer/token_spec.rb
tailor-1.1.4 spec/unit/tailor/lexer/token_spec.rb
tailor-1.1.3 spec/unit/tailor/lexer/token_spec.rb
tailor-1.1.2 spec/unit/tailor/lexer/token_spec.rb
tailor-1.1.1 spec/unit/tailor/lexer/token_spec.rb
tailor-1.1.0 spec/unit/tailor/lexer/token_spec.rb