geo_pattern 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/README.md +46 -5
- data/lib/geo_pattern/color_generators/base_color_generator.rb +2 -9
- data/lib/geo_pattern/pattern_helpers.rb +22 -7
- data/lib/geo_pattern/roles/comparable_metadata.rb +1 -1
- data/lib/geo_pattern/roles/named_generator.rb +1 -1
- data/lib/geo_pattern/version.rb +1 -1
- metadata +55 -85
- data/.github/workflows/ruby.yml +0 -30
- data/.gitignore +0 -19
- data/.rspec +0 -3
- data/.simplecov +0 -26
- data/Gemfile +0 -24
- data/Rakefile +0 -82
- data/fixtures/generated_patterns/chevrons.svg +0 -1
- data/fixtures/generated_patterns/concentric_circles.svg +0 -1
- data/fixtures/generated_patterns/diamonds.svg +0 -1
- data/fixtures/generated_patterns/diamonds_with_base_color.svg +0 -1
- data/fixtures/generated_patterns/diamonds_with_color.svg +0 -1
- data/fixtures/generated_patterns/hexagons.svg +0 -1
- data/fixtures/generated_patterns/mosaic_squares.svg +0 -1
- data/fixtures/generated_patterns/nested_squares.svg +0 -1
- data/fixtures/generated_patterns/octagons.svg +0 -1
- data/fixtures/generated_patterns/overlapping_circles.svg +0 -1
- data/fixtures/generated_patterns/overlapping_rings.svg +0 -1
- data/fixtures/generated_patterns/plaid.svg +0 -1
- data/fixtures/generated_patterns/plus_signs.svg +0 -1
- data/fixtures/generated_patterns/sine_waves.svg +0 -1
- data/fixtures/generated_patterns/squares.svg +0 -1
- data/fixtures/generated_patterns/tessellation.svg +0 -1
- data/fixtures/generated_patterns/triangles.svg +0 -1
- data/fixtures/generated_patterns/xes.svg +0 -1
- data/geo_pattern.gemspec +0 -25
- data/script/bootstrap +0 -30
- data/script/console +0 -9
- data/script/test +0 -21
- data/spec/background_generators/solid_generator_spec.rb +0 -52
- data/spec/background_spec.rb +0 -27
- data/spec/color_generators/base_color_generator_spec.rb +0 -33
- data/spec/color_generators/simple_generator_spec.rb +0 -14
- data/spec/color_preset_spec.rb +0 -55
- data/spec/color_spec.rb +0 -17
- data/spec/geo_pattern_spec.rb +0 -116
- data/spec/helpers_spec.rb +0 -67
- data/spec/pattern_preset_spec.rb +0 -43
- data/spec/pattern_sieve_spec.rb +0 -68
- data/spec/pattern_spec.rb +0 -74
- data/spec/pattern_store_spec.rb +0 -49
- data/spec/pattern_validator_spec.rb +0 -30
- data/spec/seed_spec.rb +0 -16
- data/spec/spec_helper.rb +0 -19
- data/spec/structure_generators/chevrons_generator_spec.rb +0 -7
- data/spec/structure_generators/concentric_circles_generator_spec.rb +0 -7
- data/spec/structure_generators/diamonds_generator_spec.rb +0 -7
- data/spec/structure_generators/hexagons_generator_spec.rb +0 -7
- data/spec/structure_generators/mosaic_squares_generator_spec.rb +0 -7
- data/spec/structure_generators/nested_squares_generator_spec.rb +0 -7
- data/spec/structure_generators/octagons_generator_spec.rb +0 -7
- data/spec/structure_generators/overlapping_circles_generator_spec.rb +0 -7
- data/spec/structure_generators/overlapping_rings_generator_spec.rb +0 -7
- data/spec/structure_generators/plaid_generator_spec.rb +0 -7
- data/spec/structure_generators/plus_signs_generator_spec.rb +0 -7
- data/spec/structure_generators/sine_waves_generator_spec.rb +0 -7
- data/spec/structure_generators/squares_generator_spec.rb +0 -7
- data/spec/structure_generators/tessellation_generator_spec.rb +0 -7
- data/spec/structure_generators/triangles_generator_spec.rb +0 -7
- data/spec/structure_generators/xes_generator_spec.rb +0 -7
- data/spec/structure_spec.rb +0 -40
- data/spec/support/aruba.rb +0 -24
- data/spec/support/helpers/fixtures.rb +0 -14
- data/spec/support/kernel.rb +0 -46
- data/spec/support/matchers/image.rb +0 -19
- data/spec/support/matchers/name.rb +0 -17
- data/spec/support/rspec.rb +0 -26
- data/spec/support/shared_examples/generator.rb +0 -48
- data/spec/support/shared_examples/pattern.rb +0 -33
- data/spec/support/shared_examples/pattern_name.rb +0 -9
- data/spec/support/shared_examples/structure.rb +0 -50
- data/spec/support/string.rb +0 -3
- data/spec/svg_spec.rb +0 -14
data/spec/pattern_sieve_spec.rb
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.describe PatternSieve do
|
|
6
|
-
subject(:sieve) { PatternSieve.new(requested_patterns, seed, store) }
|
|
7
|
-
|
|
8
|
-
before :each do
|
|
9
|
-
stub_const("Pattern1", Class.new)
|
|
10
|
-
stub_const("Pattern2", Class.new)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
let(:store) { instance_double("GeoPattern::PatternStore") }
|
|
14
|
-
let(:available_patterns) { [Pattern1, Pattern2] }
|
|
15
|
-
let(:requested_patterns) { %i[pattern1 pattern2] }
|
|
16
|
-
let(:seed) { instance_double("GeoPattern::Seed") }
|
|
17
|
-
|
|
18
|
-
before :each do
|
|
19
|
-
allow(seed).to receive(:to_i).with(20, 1).and_return(1)
|
|
20
|
-
allow(store).to receive(:[])
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# Minimum valid object test
|
|
24
|
-
it { expect(sieve).not_to be_nil }
|
|
25
|
-
|
|
26
|
-
describe "#fetch" do
|
|
27
|
-
context "when requested_patterns is empty" do
|
|
28
|
-
let(:requested_patterns) { nil }
|
|
29
|
-
|
|
30
|
-
before :each do
|
|
31
|
-
expect(store).to receive(:all).and_return(available_patterns)
|
|
32
|
-
expect(store).not_to receive(:[])
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it { expect(sieve.fetch).to eq Pattern2 }
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
context "when a valid pattern is requested" do
|
|
39
|
-
let(:requested_patterns) { [:pattern1] }
|
|
40
|
-
|
|
41
|
-
before :each do
|
|
42
|
-
expect(store).to receive(:[]).with(:pattern1).and_return(Pattern1)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it { expect(sieve.fetch).to eq Pattern1 }
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
context "when an invalid pattern is requested" do
|
|
49
|
-
let(:requested_patterns) { [:patternX] }
|
|
50
|
-
|
|
51
|
-
before :each do
|
|
52
|
-
allow(store).to receive(:[]).with(:patternX).and_return(nil)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it { expect(sieve.fetch).to be nil }
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
context "when a requested pattern is nil" do
|
|
59
|
-
let(:requested_patterns) { [:pattern1, nil, :pattern2] }
|
|
60
|
-
|
|
61
|
-
before :each do
|
|
62
|
-
expect(store).not_to receive(:[]).with(nil)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
it { sieve.fetch }
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|
data/spec/pattern_spec.rb
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.describe Pattern do
|
|
6
|
-
subject(:pattern) { Pattern.new(svg_image) }
|
|
7
|
-
|
|
8
|
-
let(:svg_image) { instance_double("GeoPattern::SvgImage") }
|
|
9
|
-
let(:svg_image_content) { fixtures_path("generated_patterns/sine_waves.svg").read.chomp }
|
|
10
|
-
let(:background) { instance_double("GeoPattern::Background") }
|
|
11
|
-
let(:background_image) { instance_double("GeoPattern::SvgImage") }
|
|
12
|
-
let(:background_body) { %(<rect x="0" y="0" width="100%" height="100%" fill="rgb(121, 131, 76)" />) }
|
|
13
|
-
let(:structure) { instance_double("GeoPattern::Structure") }
|
|
14
|
-
let(:structure_image) { instance_double("GeoPattern::SvgImage") }
|
|
15
|
-
let(:structure_body) { %(<path d="M0 53 C 28.0 0, 52.0 0, 80 53 S 132.0 106, 160 53 S 212.0 0, 240.0, 53" fill="none" stroke="#222" style="opacity:0.046;stroke-width:6px;" transform="translate(-40, -79.5)" />) }
|
|
16
|
-
|
|
17
|
-
it { expect(pattern).not_to be_nil }
|
|
18
|
-
|
|
19
|
-
before :each do
|
|
20
|
-
allow(svg_image).to receive(:to_s).and_return svg_image_content
|
|
21
|
-
allow(svg_image).to receive(:height=).and_return 100
|
|
22
|
-
allow(svg_image).to receive(:width=).and_return 100
|
|
23
|
-
|
|
24
|
-
allow(background).to receive(:image).and_return background_image
|
|
25
|
-
|
|
26
|
-
allow(structure).to receive(:image).and_return structure_image
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
describe "#to_s" do
|
|
30
|
-
before :each do
|
|
31
|
-
allow(svg_image).to receive(:to_s).and_return(svg_image_content)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it { expect(pattern.to_s).to eq svg_image_content }
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
describe "#to_base64" do
|
|
38
|
-
before :each do
|
|
39
|
-
allow(svg_image).to receive(:to_s).and_return(svg_image_content)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it { expect(pattern.to_base64).to include "PHN2ZyB4bWxuc" }
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
describe "#to_data_uri" do
|
|
46
|
-
before :each do
|
|
47
|
-
allow(svg_image).to receive(:to_s).and_return(svg_image_content)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it { expect(pattern.to_data_uri).to include "PHN2ZyB4bWxuc" }
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
describe "#generate_me" do
|
|
54
|
-
context "when a background is added" do
|
|
55
|
-
let(:generator) { instance_double("GeoPattern::BackgroundGenerator") }
|
|
56
|
-
|
|
57
|
-
before :each do
|
|
58
|
-
expect(generator).to receive(:generate).with(pattern)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
it do
|
|
62
|
-
pattern.generate_me(generator)
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
describe "#include?" do
|
|
68
|
-
it do
|
|
69
|
-
expect(svg_image).to receive(:include?)
|
|
70
|
-
|
|
71
|
-
pattern.include? ""
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
data/spec/pattern_store_spec.rb
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.describe PatternStore do
|
|
6
|
-
subject(:pattern_store) { PatternStore.new }
|
|
7
|
-
|
|
8
|
-
it { expect(pattern_store).not_to be_nil }
|
|
9
|
-
|
|
10
|
-
describe "#[]" do
|
|
11
|
-
context "when a known pattern is requested" do
|
|
12
|
-
context "as string" do
|
|
13
|
-
let(:pattern_name) { "xes" }
|
|
14
|
-
it_behaves_like "a known pattern name"
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
context "as klass" do
|
|
18
|
-
let(:pattern_name) { XesPattern }
|
|
19
|
-
it_behaves_like "a known pattern name"
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
context "as symbol" do
|
|
23
|
-
let(:pattern_name) { :xes }
|
|
24
|
-
it_behaves_like "a known pattern name"
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
context "when an unknown pattern is requested" do
|
|
29
|
-
context "as string" do
|
|
30
|
-
let(:pattern_name) { "unknown" }
|
|
31
|
-
it_behaves_like "an unknown pattern name"
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
context "as klass" do
|
|
35
|
-
let(:pattern_name) do
|
|
36
|
-
stub_const("UnknownPattern", Class.new)
|
|
37
|
-
UnknownPattern
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it_behaves_like "an unknown pattern name"
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
context "as symbol" do
|
|
44
|
-
let(:pattern_name) { :unknown }
|
|
45
|
-
it_behaves_like "an unknown pattern name"
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.describe PatternValidator do
|
|
6
|
-
subject(:validator) { PatternValidator.new(store) }
|
|
7
|
-
let(:store) { instance_double("GeoPattern::PatternStore") }
|
|
8
|
-
let(:patterns) { [] }
|
|
9
|
-
|
|
10
|
-
# Minimum valid object test
|
|
11
|
-
it { expect(validator).not_to be_nil }
|
|
12
|
-
|
|
13
|
-
describe "#validate" do
|
|
14
|
-
context "when valid pattern is validated" do
|
|
15
|
-
before :each do
|
|
16
|
-
allow(store).to receive(:known?).with("pattern1").and_return(true)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it { expect { validator.validate(%w[pattern1]) }.not_to raise_error }
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
context "when invalid pattern is validated" do
|
|
23
|
-
before :each do
|
|
24
|
-
allow(store).to receive(:known?).with("pattern1").and_return(false)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it { expect { validator.validate(%w[pattern1]) }.to raise_error InvalidPatternError }
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
data/spec/seed_spec.rb
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.describe Seed do
|
|
6
|
-
subject(:seed) { Seed.new(input) }
|
|
7
|
-
let(:input) { "string" }
|
|
8
|
-
|
|
9
|
-
it { expect(seed).not_to be_nil }
|
|
10
|
-
|
|
11
|
-
describe "#[]" do
|
|
12
|
-
context "when use an integer" do
|
|
13
|
-
it { expect(seed[1]).to be_kind_of String }
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
$LOAD_PATH << File.expand_path("../lib", __dir__)
|
|
4
|
-
|
|
5
|
-
require "simplecov"
|
|
6
|
-
SimpleCov.command_name "rspec"
|
|
7
|
-
SimpleCov.start
|
|
8
|
-
|
|
9
|
-
# Pull in all of the gems including those in the `test` group
|
|
10
|
-
require "bundler"
|
|
11
|
-
Bundler.require :default, :test, :development
|
|
12
|
-
|
|
13
|
-
require "geo_pattern"
|
|
14
|
-
|
|
15
|
-
# Loading support files
|
|
16
|
-
GeoPattern::Helpers.require_files_matching_pattern ::File.expand_path("support/**/*.rb", __dir__)
|
|
17
|
-
|
|
18
|
-
# No need to add the namespace to every class tested
|
|
19
|
-
include GeoPattern # rubocop:disable Style/MixinUsage
|
data/spec/structure_spec.rb
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.describe Structure do
|
|
6
|
-
subject(:metadata) { described_class.new(image: svg_image, preset: preset, generator: generator, name: name) }
|
|
7
|
-
|
|
8
|
-
let(:svg_image) { instance_double("GeoPattern::SvgImage") }
|
|
9
|
-
let(:svg_image_content) { fixtures_path("generated_patterns/sine_waves.svg").read.chomp }
|
|
10
|
-
let(:preset) { instance_double("GeoPattern::PatternPreset") }
|
|
11
|
-
let(:generator) { stub_const("GeoPattern::StructureGenerators::ChevronGenerator", Class.new) }
|
|
12
|
-
|
|
13
|
-
let(:name) { :chevron }
|
|
14
|
-
let(:fill_color_dark) { "#222" }
|
|
15
|
-
let(:fill_color_light) { "#ddd" }
|
|
16
|
-
let(:stroke_color) { "#000" }
|
|
17
|
-
let(:stroke_opacity) { 0.02 }
|
|
18
|
-
let(:opacity_min) { 0.02 }
|
|
19
|
-
let(:opacity_max) { 0.15 }
|
|
20
|
-
|
|
21
|
-
it { is_expected.not_to be_nil }
|
|
22
|
-
|
|
23
|
-
before :each do
|
|
24
|
-
allow(preset).to receive(:fill_color_dark).and_return(fill_color_dark)
|
|
25
|
-
allow(preset).to receive(:fill_color_light).and_return(fill_color_light)
|
|
26
|
-
allow(preset).to receive(:stroke_color).and_return(stroke_color)
|
|
27
|
-
allow(preset).to receive(:stroke_opacity).and_return(stroke_opacity)
|
|
28
|
-
allow(preset).to receive(:opacity_min).and_return(opacity_min)
|
|
29
|
-
allow(preset).to receive(:opacity_max).and_return(opacity_max)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it_behaves_like "a metadata argument", :name
|
|
33
|
-
it_behaves_like "a metadata argument", :generator
|
|
34
|
-
it_behaves_like "a forwarded metadata argument", :fill_color_dark
|
|
35
|
-
it_behaves_like "a forwarded metadata argument", :fill_color_light
|
|
36
|
-
it_behaves_like "a forwarded metadata argument", :stroke_color
|
|
37
|
-
it_behaves_like "a forwarded metadata argument", :stroke_opacity
|
|
38
|
-
it_behaves_like "a forwarded metadata argument", :opacity_min
|
|
39
|
-
it_behaves_like "a forwarded metadata argument", :opacity_max
|
|
40
|
-
end
|
data/spec/support/aruba.rb
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "aruba/rspec"
|
|
4
|
-
require "aruba/api"
|
|
5
|
-
|
|
6
|
-
# Spec Helpers
|
|
7
|
-
module SpecHelper
|
|
8
|
-
# Helpers for aruba
|
|
9
|
-
module Aruba
|
|
10
|
-
include ::Aruba::Api
|
|
11
|
-
|
|
12
|
-
def dirs
|
|
13
|
-
@dirs ||= %w[tmp rspec]
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
RSpec.configure do |c|
|
|
19
|
-
c.include SpecHelper::Aruba
|
|
20
|
-
|
|
21
|
-
c.before :each do
|
|
22
|
-
setup_aruba
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module SpecHelper
|
|
4
|
-
module Fixtures
|
|
5
|
-
def fixtures_path(name)
|
|
6
|
-
base_path = Pathname.new(File.expand_path("../../../fixtures", __dir__))
|
|
7
|
-
base_path + Pathname.new(name)
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
RSpec.configure do |c|
|
|
13
|
-
c.include SpecHelper::Fixtures
|
|
14
|
-
end
|
data/spec/support/kernel.rb
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# rubocop:disable Style/EvalWithLocation
|
|
4
|
-
|
|
5
|
-
module Kernel
|
|
6
|
-
# Captures the given stream and returns it:
|
|
7
|
-
#
|
|
8
|
-
# @param [String] stream
|
|
9
|
-
#
|
|
10
|
-
# The name of the stream to be captured
|
|
11
|
-
#
|
|
12
|
-
# @example Capture output
|
|
13
|
-
#
|
|
14
|
-
# stream = capture(:stdout) { puts 'notice' }
|
|
15
|
-
# stream # => "notice\n"
|
|
16
|
-
#
|
|
17
|
-
# stream = capture(:stderr) { warn 'error' }
|
|
18
|
-
# stream # => "error\n"
|
|
19
|
-
#
|
|
20
|
-
# @example Capture output for subprocesses
|
|
21
|
-
#
|
|
22
|
-
# stream = capture(:stdout) { system('echo notice') }
|
|
23
|
-
# stream # => "notice\n"
|
|
24
|
-
#
|
|
25
|
-
# stream = capture(:stderr) { system('echo error 1>&2') }
|
|
26
|
-
# stream # => "error\n"
|
|
27
|
-
def capture(stream)
|
|
28
|
-
stream = stream.to_s
|
|
29
|
-
captured_stream = Tempfile.new(stream)
|
|
30
|
-
stream_io = eval("$#{stream}") # rubocop:disable Security/Eval
|
|
31
|
-
origin_stream = stream_io.dup
|
|
32
|
-
stream_io.reopen(captured_stream)
|
|
33
|
-
|
|
34
|
-
yield
|
|
35
|
-
|
|
36
|
-
stream_io.rewind
|
|
37
|
-
captured_stream.read
|
|
38
|
-
ensure
|
|
39
|
-
captured_stream.close
|
|
40
|
-
captured_stream.unlink
|
|
41
|
-
stream_io.reopen(origin_stream)
|
|
42
|
-
end
|
|
43
|
-
alias_method :silence, :capture
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
# rubocop:enable Style/EvalWithLocation
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "rspec/expectations"
|
|
4
|
-
|
|
5
|
-
RSpec::Matchers.define :have_image_with_rgb_color do |*expected|
|
|
6
|
-
expected = format("rgb(%s, %s, %s)", *expected.flatten) # rubocop:disable Style/FormatStringToken
|
|
7
|
-
|
|
8
|
-
match do |actual|
|
|
9
|
-
actual.image.include? expected
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
failure_message_when_negated do |actual|
|
|
13
|
-
"expected that #{actual} includes color #{expected}"
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
failure_message do |actual|
|
|
17
|
-
"expected that #{actual} not includes color #{expected}"
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "rspec/expectations"
|
|
4
|
-
|
|
5
|
-
RSpec::Matchers.define :have_name do |expected|
|
|
6
|
-
match do |actual|
|
|
7
|
-
actual.name? expected
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
failure_message_when_negated do |actual|
|
|
11
|
-
"expected that #{actual} does not nave name \"#{expected}\""
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
failure_message do |actual|
|
|
15
|
-
"expected that #{actual} has name \"#{expected}\""
|
|
16
|
-
end
|
|
17
|
-
end
|
data/spec/support/rspec.rb
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.configure do |config|
|
|
4
|
-
config.expect_with :rspec do |expectations|
|
|
5
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
config.mock_with :rspec do |mocks|
|
|
9
|
-
mocks.verify_partial_doubles = true
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
config.filter_run :focus
|
|
13
|
-
config.run_all_when_everything_filtered = true
|
|
14
|
-
|
|
15
|
-
config.disable_monkey_patching!
|
|
16
|
-
config.warnings = false
|
|
17
|
-
|
|
18
|
-
if config.files_to_run.one?
|
|
19
|
-
config.default_formatter = "doc"
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
config.profile_examples = 10 if ENV.key? "RSPEC_PROFILE"
|
|
23
|
-
|
|
24
|
-
config.order = :random
|
|
25
|
-
Kernel.srand config.seed
|
|
26
|
-
end
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.shared_examples "a structure generator" do |name|
|
|
4
|
-
subject { described_class.new(seed, preset, svg_image) }
|
|
5
|
-
|
|
6
|
-
let(:seed) { instance_double("GeoPattern::Seed") }
|
|
7
|
-
let(:preset) { instance_double("GeoPattern::PatternPreset") }
|
|
8
|
-
let(:svg_image) { SvgImage.new }
|
|
9
|
-
let(:pattern) { instance_double("GeoPattern::Pattern") }
|
|
10
|
-
|
|
11
|
-
let(:name) { name }
|
|
12
|
-
|
|
13
|
-
let(:fill_color_dark) { "#222" }
|
|
14
|
-
let(:fill_color_light) { "#ddd" }
|
|
15
|
-
let(:stroke_color) { "#000" }
|
|
16
|
-
let(:stroke_opacity) { 0.02 }
|
|
17
|
-
let(:opacity_min) { 0.02 }
|
|
18
|
-
let(:opacity_max) { 0.15 }
|
|
19
|
-
|
|
20
|
-
before :each do
|
|
21
|
-
allow(preset).to receive(:fill_color_dark).and_return(fill_color_dark)
|
|
22
|
-
allow(preset).to receive(:fill_color_light).and_return(fill_color_light)
|
|
23
|
-
allow(preset).to receive(:stroke_color).and_return(stroke_color)
|
|
24
|
-
allow(preset).to receive(:stroke_opacity).and_return(stroke_opacity)
|
|
25
|
-
allow(preset).to receive(:opacity_min).and_return(opacity_min)
|
|
26
|
-
allow(preset).to receive(:opacity_max).and_return(opacity_max)
|
|
27
|
-
|
|
28
|
-
allow(seed).to receive(:to_i).and_return(1)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it { is_expected.not_to be_nil }
|
|
32
|
-
it { is_expected.to respond_to(:generate) }
|
|
33
|
-
|
|
34
|
-
it do
|
|
35
|
-
expect(pattern).to receive(:structure=).with(kind_of(Structure))
|
|
36
|
-
expect(pattern).to receive(:height=).with(kind_of(Numeric))
|
|
37
|
-
expect(pattern).to receive(:width=).with(kind_of(Numeric))
|
|
38
|
-
|
|
39
|
-
subject.generate(pattern)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it_behaves_like "a named generator", name
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
RSpec.shared_examples "a named generator" do |name|
|
|
46
|
-
it { is_expected.to have_name name }
|
|
47
|
-
it { is_expected.to have_name name.to_s }
|
|
48
|
-
end
|