Skip to content

Commit

Permalink
Improve tests organization
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Sep 12, 2017
1 parent a45286e commit 00dfe65
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 97 deletions.
7 changes: 3 additions & 4 deletions test/Makefile.am
Expand Up @@ -3,11 +3,10 @@
#

TESTS = \
snapper_dbus_escape_test.rb \
snapper_dbus_unescape_test.rb \
snapper_test.rb \
snapper_dbus_test.rb \
snapper_string_to_userdata_test.rb \
snapper_tree_test.rb \
snapper_userdata_to_string_test.rb
snapper_tree_test.rb

TEST_EXTENSIONS = .rb
RB_LOG_COMPILER = rspec
Expand Down
26 changes: 0 additions & 26 deletions test/snapper_dbus_escape_test.rb

This file was deleted.

50 changes: 50 additions & 0 deletions test/snapper_dbus_test.rb
@@ -0,0 +1,50 @@
#!/usr/bin/env rspec

require_relative "test_helper"

Yast.import "SnapperDbus"

describe "SnapperDbus" do
describe "#escape" do
it "call with nothing special" do
expect(Yast::SnapperDbus.send(:escape, "hello")).to eq("hello")
end


it "call with UTF-8" do
expect(Yast::SnapperDbus.send(:escape, "schön")).to eq("sch\\xc3\\xb6n".force_encoding(Encoding::ASCII_8BIT))
end


it "call with slash" do
expect(Yast::SnapperDbus.send(:escape, "\\")).to eq("\\\\")
end


it "call with a hash" do
expect(Yast::SnapperDbus.send(:escape, { "schön" => "hier" }))
.to eq({ "sch\\xc3\\xb6n".force_encoding(Encoding::ASCII_8BIT) => "hier" })
end
end

describe "#unescape" do
it "call with nothing special" do
expect(Yast::SnapperDbus.send(:unescape, "hello")).to eq("hello")
expect(Yast::SnapperDbus.send(:unescape, "world").encoding).to eq(Encoding::ASCII_8BIT)
end


it "call with escaped UTF-8" do
expect(Yast::SnapperDbus.send(:unescape, "sch\\xc3\\xb6n")).to eq("schön".force_encoding(Encoding::ASCII_8BIT))
end

it "call with slash" do
expect(Yast::SnapperDbus.send(:unescape, "\\\\")).to eq("\\")
end

it "call with a hash" do
expect(Yast::SnapperDbus.send(:unescape, { "sch\\xc3\\xb6n" => "hier" }))
.to eq({ "schön".force_encoding(Encoding::ASCII_8BIT) => "hier" })
end
end
end
25 changes: 0 additions & 25 deletions test/snapper_dbus_unescape_test.rb

This file was deleted.

23 changes: 0 additions & 23 deletions test/snapper_string_to_userdata_test.rb

This file was deleted.

39 changes: 39 additions & 0 deletions test/snapper_test.rb
@@ -0,0 +1,39 @@
#!/usr/bin/env rspec

require_relative "test_helper"

Yast.import "Snapper"

describe Yast::Snapper do
describe "#userdata_to_string" do
it "call with empty userdata" do
expect(Yast::Snapper.userdata_to_string({ })).to eq("")
end

it "call with simple userdata" do
expect(Yast::Snapper.userdata_to_string({ "hello" => "world" })).to eq("hello=world")
end

it "call with complex userdata" do
expect(Yast::Snapper.userdata_to_string({ "a" => "1", "b" => "2" })).to eq("a=1, b=2")
end
end

describe "#string_to_userdata" do
it "call with empty string" do
expect(Yast::Snapper.string_to_userdata("")).to eq({ })
end

it "call with simple string" do
expect(Yast::Snapper.string_to_userdata("hello=world")).to eq({ "hello" => "world" })
end

it "call with complex string" do
expect(Yast::Snapper.string_to_userdata("a=1,b=2")).to eq({ "a" => "1", "b" => "2" })
end

it "call with complex string and space after comma" do
expect(Yast::Snapper.string_to_userdata("a=1, b=2")).to eq({ "a" => "1", "b" => "2" })
end
end
end
19 changes: 0 additions & 19 deletions test/snapper_userdata_to_string_test.rb

This file was deleted.

0 comments on commit 00dfe65

Please sign in to comment.