Sha256: 4d48555a725479ec24d6a7e852fe21c09d208cea477f6c0385bf7c8135e58e00

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

require "spec_helper"

describe Docks::Languages::Less do
  subject { Docks::Languages::Less.instance }

  describe ".extensions" do
    let(:extensions) { [subject.class.extensions].flatten }

    it "includes .less as an extension" do
      expect(extensions).to include "less"
    end
  end

  describe "#signature_for" do
    let(:name) { "foo" }

    let(:mixin_no_params) { Docks::Containers::Mixin.new(name: name) }
    let(:mixin_with_params) { Docks::Containers::Mixin.new(name: name, params: [OpenStruct.new(name: "bar"), OpenStruct.new(name: "baz", default: "'qux'")]) }

    let(:something_else) { Docks::Containers::Component.new(name: name) }

    it "gives a signature to mixins with no params" do
      expect(subject.signature_for(mixin_no_params)).to eq ".#{name}() { /* ... */ }"
    end

    it "gives a signature to mixins with params, including default values" do
      expect(subject.signature_for(mixin_with_params)).to eq ".#{name}(@bar, @baz: 'qux') { /* ... */ }"
    end

    it "only prefixes variable names with @ if they don't already have it" do
      mixin_with_params.params.first.name = "@bar"
      expect(subject.signature_for(mixin_with_params)).to eq ".#{name}(@bar, @baz: 'qux') { /* ... */ }"
    end

    it "returns nil if the symbol is not a function/ mixin" do
      expect(subject.signature_for(something_else)).to be nil
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
docks_app-0.0.3 spec/lib/languages/less_language_spec.rb
docks_app-0.0.2 spec/lib/languages/less_language_spec.rb
docks_app-0.0.1 spec/lib/languages/less_language_spec.rb