spec/svgen/svg_spec.rb in svgen-0.0.2 vs spec/svgen/svg_spec.rb in svgen-0.0.3

- old
+ new

@@ -1,48 +1,49 @@ require "spec_helper" describe SVGen::SVG do describe "#generate" do + let(:fixtures_path) { Pathname.new("spec/fixtures") } after do data = @svg.generate expect(data).to eq @sample.read end it "returns simple SVG data" do - @sample = Pathname.new("spec/support/sample.svg") + @sample = fixtures_path.join("sample.svg") @svg = SVGen::SVG.new(width: 600, height: 300) end it "returns SVG data with rect" do - @sample = Pathname.new("spec/support/rect.svg") + @sample = fixtures_path.join("rect.svg") @svg = SVGen::SVG.new(width: 600, height: 300) do |svg| svg.rect(width: 400, height: 300, fill: "red") end end it "returns SVG data with circle" do - @sample = Pathname.new("spec/support/circle.svg") + @sample = fixtures_path.join("circle.svg") @svg = SVGen::SVG.new(width: 600, height: 300) do |svg| svg.circle(cx: 100, cy: 100, r: 50, fill: "red") end end it "returns SVG data with text" do - @sample = Pathname.new("spec/support/text.svg") + @sample = fixtures_path.join("text.svg") @svg = SVGen::SVG.new(width: 600, height: 300) do |svg| svg.text("Sample Text", x: 20, y: 20) end end it "returns SVG data with line" do - @sample = Pathname.new("spec/support/line.svg") + @sample = fixtures_path.join("line.svg") @svg = SVGen::SVG.new(width: 600, height: 300) do |svg| svg.line(x1: 10, y1: 10, x2: 50, y2: 50, stroke: "black", :"stroke-width" => "5") end end it "returns SVG data with group" do - @sample = Pathname.new("spec/support/group.svg") + @sample = fixtures_path.join("group.svg") @svg = SVGen::SVG.new(width: 600, height: 300) do |svg| svg.g(stroke: "red", "stroke-width" => 5) do |g| g.rect(width: "300", height: "200", fill: "red") g.circle(cx: "50", cy: "50", r: "10", fill: "blue") end