Skip to content

Commit

Permalink
Fixes: #10
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertDober committed Feb 6, 2022
1 parent 05da2fc commit 79833a9
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 9 deletions.
7 changes: 4 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
speculate_about (1.0.0)
speculate_about (1.0.1)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -29,12 +29,12 @@ GEM
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-core (3.10.2)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
rspec-mocks (3.10.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.3)
Expand All @@ -48,6 +48,7 @@ GEM

PLATFORMS
x86_64-darwin-21
x86_64-linux

DEPENDENCIES
debug
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[![Gem Version](https://badge.fury.io/rb/speculate_about.svg)](http://badge.fury.io/rb/speculate_about)
[![CI](https://github.com/robertdober/speculate_about/workflows/CI/badge.svg)](https://github.com/robertdober/speculate_about/actions)
[![Coverage Status](https://coveralls.io/repos/github/RobertDober/speculate_about/badge.svg?branch=master)](https://coveralls.io/github/RobertDober/speculate_about?branch=master)
[![Gem Downloads](https://img.shields.io/gem/dt/speculate_about.svg)](https://rubygems.org/gems/speculate_about)

# Speculate About

Expand Down
13 changes: 11 additions & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@

# v0.6.2 2022-??-??
# v1.0.2 2022-??-??

Make triggers pluggable (translations and syntax customisations)


# v1.0.1 2022-02-06

Fix ws in empty lines

# v1.0.0 2022-

Make `And` trigger setup code or examples depending on its context


# v0.6.1 2022-01-22

Add `Or` as an example trigger
Expand Down
2 changes: 1 addition & 1 deletion lib/speculations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def compile(infile, outfile=nil)
raise ArgumentError, "#{infile} not found" unless File.readable? infile
outfile ||= _speculation_path(infile)
if _out_of_date?(outfile, infile)
ast = Speculations::Parser.new.parse_from_file(infile)
ast = p Speculations::Parser.new.parse_from_file(infile)
code = _decorated_ast_code ast, infile
File.write(outfile, code.join("\n"))
end
Expand Down
2 changes: 1 addition & 1 deletion lib/speculations/parser/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def includes

def map_lines(*lines, indent: 0)
prefix = " " * (tree_level + indent).succ
lines.flatten.map{ |line| "#{prefix}#{line.strip}" }
lines.flatten.map{ |line| "#{prefix}#{line.strip}".rstrip }
end

def to_code
Expand Down
2 changes: 1 addition & 1 deletion lib/speculations/parser/context/include.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Speculations::Parser::Context::Include

attr_reader :lnb, :parent

def add_line line
def add_line line
lines << line
self
end
Expand Down
2 changes: 1 addition & 1 deletion lib/speculations/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Speculations
VERSION = "1.0.0"
VERSION = "1.0.1"
end
10 changes: 10 additions & 0 deletions spec/fixtures/EMPTY_WS_LINES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# No ws in empty lines

## Context: Level 2

Given two lets
```ruby
let(:one) { 42 }

let(:two) { 54 }
```
7 changes: 7 additions & 0 deletions spec/fixtures/EMPTY_WS_LINES_spec.rb.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# spec/fixtures/EMPTY_WS_LINES.md:3
context "Level 2" do
# spec/fixtures/EMPTY_WS_LINES.md:6
let(:one) { 42 }

let(:two) { 54 }
end
1 change: 1 addition & 0 deletions spec/parser/context_sensitive_and_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
end

end
# SPDX-License-Identifier: Apache-2.0
24 changes: 24 additions & 0 deletions spec/parser/empty_ws_lines_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'speculations/parser'
RSpec.describe Speculations::Parser do

let(:fixture){ fixtures_path("EMPTY_WS_LINES.md") }
let(:parser) { described_class.new }
let(:ast) { parser.parse_from_file(fixture) }

context "rendered code" do
let(:expected_code) { File.readlines(fixtures_path("EMPTY_WS_LINES_spec.rb.expected"), chomp: true) }
let(:actual_code) { ast.to_code }

it "has no superflous lines" do
expect( actual_code.size ).to eq(expected_code.size)
end

it "they have the same lines" do
actual_code.zip(expected_code).each_with_index do |(actual_line, expected_line), idx|
expect( "#{idx.succ}: #{actual_line}" ).to eq("#{idx.succ}: #{expected_line}")
end
end
end

end
# SPDX-License-Identifier: Apache-2.0

0 comments on commit 79833a9

Please sign in to comment.