Skip to content

Commit 50e93e0

Browse files
test: Start a spec to exercise the code in the README (#40)
1 parent 89d3678 commit 50e93e0

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ GEM
1010
concurrent-ruby (1.2.2)
1111
diff-lcs (1.5.0)
1212
json (2.6.2)
13+
markly (0.7.0)
1314
parallel (1.22.1)
1415
parser (3.1.2.1)
1516
ast (~> 2.4.1)
@@ -57,6 +58,7 @@ PLATFORMS
5758

5859
DEPENDENCIES
5960
concurrent-ruby
61+
markly
6062
openfeature-sdk!
6163
rake (~> 13.0)
6264
rspec (~> 3.12.0)

openfeature-sdk.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
3131
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
3232
spec.require_paths = ["lib"]
3333

34+
spec.add_development_dependency "markly"
3435
spec.add_development_dependency "rake", "~> 13.0"
3536
spec.add_development_dependency "rspec", "~> 3.12.0"
3637
spec.add_development_dependency "rubocop", "~> 1.37.1"

spec/openfeature/example_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# frozen_string_literal: true
2+
3+
RSpec.describe "README example" do
4+
before do
5+
@readme_md = Pathname.new("../../../README.md").expand_path(__FILE__)
6+
7+
doc = Markly.parse(@readme_md.read)
8+
doc.walk do |node|
9+
if node.type == :code_block && node.fence_info == "ruby"
10+
@example_codeblock = node
11+
break
12+
end
13+
end
14+
end
15+
16+
it "works" do
17+
expect do
18+
eval @example_codeblock.string_content, # rubocop:disable Security/Eval
19+
binding,
20+
@readme_md.to_s,
21+
@example_codeblock.source_position[:start_line] + 1
22+
end.not_to raise_error
23+
end
24+
end

spec/spec_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
require "openfeature/sdk"
44

5+
require "markly"
6+
57
RSpec.configure do |config|
68
# Enable flags like --only-failures and --next-failure
79
config.example_status_persistence_file_path = ".rspec_status"

0 commit comments

Comments
 (0)