sorting_service_books 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1213f8ad6f4d80696b17ccbd5c72c485ce654da
4
- data.tar.gz: b8edbaaf8af596eb5e541dc525e357b3c6d14297
3
+ metadata.gz: 50cf00ef383a5e93cdc68f83d4651cb91a542cd2
4
+ data.tar.gz: 5336d33c190b31202768a7875e6263f7de1c9a39
5
5
  SHA512:
6
- metadata.gz: 8bb2bf7bfe3ecb543f3561068430bc6f774cd043dcd02947b843e642e28c2526d13fd9eb9aaad6d628b174be25ce0657853f6d4a729fe9b9201e9a6913a0b73d
7
- data.tar.gz: ff12d078bfc89bf5bc8054eee05e8118d055f20e64075bf3f41f9d6ca4821329574836ce5cd209469fba413a92fbb319007649214cc15b14395f0aa4bf0d05dc
6
+ metadata.gz: 19896eae6c581a736949a3a2caada789e3ea3cc031869cb0cad1c6282f8e97dc91c9c454fe957571ad460af1a0ee18ac2ad8d46a7a46cd127be38920bb9be7f5
7
+ data.tar.gz: 4c3c1eddabca86e2a72dc8809069259cc1225e2622cfe426106e0208c85e23475afd19eb10dffef349146e5ef34c852b42640cd9f1cf77dddeb4f109e2b0cac5
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ source "http://rubygems.org"
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
  group :development do
9
- gem "rspec", "~> 2.8.0"
9
+ gem "rspec"
10
10
  gem "rdoc", "~> 3.12"
11
11
  gem "bundler", "~> 1.0"
12
12
  gem "jeweler", "~> 2.0.1"
data/Gemfile.lock CHANGED
@@ -5,7 +5,7 @@ GEM
5
5
  builder (3.2.2)
6
6
  descendants_tracker (0.0.4)
7
7
  thread_safe (~> 0.3, >= 0.3.1)
8
- diff-lcs (1.1.3)
8
+ diff-lcs (1.2.5)
9
9
  docile (1.1.3)
10
10
  faraday (0.9.0)
11
11
  multipart-post (>= 1.2, < 3)
@@ -47,14 +47,18 @@ GEM
47
47
  rake (10.3.2)
48
48
  rdoc (3.12.2)
49
49
  json (~> 1.4)
50
- rspec (2.8.0)
51
- rspec-core (~> 2.8.0)
52
- rspec-expectations (~> 2.8.0)
53
- rspec-mocks (~> 2.8.0)
54
- rspec-core (2.8.0)
55
- rspec-expectations (2.8.0)
56
- diff-lcs (~> 1.1.2)
57
- rspec-mocks (2.8.0)
50
+ rspec (3.0.0)
51
+ rspec-core (~> 3.0.0)
52
+ rspec-expectations (~> 3.0.0)
53
+ rspec-mocks (~> 3.0.0)
54
+ rspec-core (3.0.0)
55
+ rspec-support (~> 3.0.0)
56
+ rspec-expectations (3.0.0)
57
+ diff-lcs (>= 1.2.0, < 2.0)
58
+ rspec-support (~> 3.0.0)
59
+ rspec-mocks (3.0.0)
60
+ rspec-support (~> 3.0.0)
61
+ rspec-support (3.0.0)
58
62
  simplecov (0.8.2)
59
63
  docile (~> 1.1.0)
60
64
  multi_json
@@ -69,5 +73,5 @@ DEPENDENCIES
69
73
  bundler (~> 1.0)
70
74
  jeweler (~> 2.0.1)
71
75
  rdoc (~> 3.12)
72
- rspec (~> 2.8.0)
76
+ rspec
73
77
  simplecov
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/bin/test.rb ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require "sorting_service_books"
5
+
6
+
7
+ client = Client.new("../config_one_condition.yml")
8
+ puts "*"*50
9
+ puts client.books
10
+ puts client.sort
11
+ puts "*"*50
12
+
13
+ client = Client.new("../config_two_conditions.yml")
14
+ puts "*"*50
15
+ puts client.books
16
+ puts client.sort
17
+ puts "*"*50
18
+
19
+ client = Client.new("../config_three_conditions.yml")
20
+ puts "*"*50
21
+ puts client.books
22
+ puts client.sort
23
+ puts "*"*50
24
+
@@ -0,0 +1,22 @@
1
+ conditions:
2
+ -
3
+ key: !ruby/symbol title
4
+ value: !ruby/symbol asc
5
+
6
+ books:
7
+ -
8
+ title: 'Java How to Program'
9
+ author: 'Deitel & Deitel'
10
+ edition: '2007'
11
+ -
12
+ title: 'Patterns of Enterprise Application Architecture'
13
+ author: 'Martin Fowler'
14
+ edition: '2002'
15
+ -
16
+ title: 'Head First Design Patterns'
17
+ author: 'Elisabeth Freeman'
18
+ edition: '2004'
19
+ -
20
+ title: 'Internet & World Wide Web: How to Program'
21
+ author: 'Deitel & Deitel'
22
+ edition: '2007'
@@ -0,0 +1,28 @@
1
+ conditions:
2
+ -
3
+ key: !ruby/symbol edition
4
+ value: !ruby/symbol desc
5
+ -
6
+ key: !ruby/symbol author
7
+ value: !ruby/symbol desc
8
+ -
9
+ key: !ruby/symbol title
10
+ value: !ruby/symbol asc
11
+
12
+ books:
13
+ -
14
+ title: 'Java How to Program'
15
+ author: 'Deitel & Deitel'
16
+ edition: '2007'
17
+ -
18
+ title: 'Patterns of Enterprise Application Architecture'
19
+ author: 'Martin Fowler'
20
+ edition: '2002'
21
+ -
22
+ title: 'Head First Design Patterns'
23
+ author: 'Elisabeth Freeman'
24
+ edition: '2004'
25
+ -
26
+ title: 'Internet & World Wide Web: How to Program'
27
+ author: 'Deitel & Deitel'
28
+ edition: '2007'
@@ -0,0 +1,26 @@
1
+ conditions:
2
+ -
3
+ key: !ruby/symbol author
4
+ value: !ruby/symbol asc
5
+
6
+ -
7
+ key: !ruby/symbol title
8
+ value: !ruby/symbol desc
9
+
10
+ books:
11
+ -
12
+ title: 'Java How to Program'
13
+ author: 'Deitel & Deitel'
14
+ edition: '2007'
15
+ -
16
+ title: 'Patterns of Enterprise Application Architecture'
17
+ author: 'Martin Fowler'
18
+ edition: '2002'
19
+ -
20
+ title: 'Head First Design Patterns'
21
+ author: 'Elisabeth Freeman'
22
+ edition: '2004'
23
+ -
24
+ title: 'Internet & World Wide Web: How to Program'
25
+ author: 'Deitel & Deitel'
26
+ edition: '2007'
@@ -0,0 +1 @@
1
+ conditions:
@@ -0,0 +1,12 @@
1
+
2
+ module SortingServiceBooks
3
+ class Book
4
+ attr_accessor :title, :author, :edition
5
+
6
+ def initialize(title, author, edition)
7
+ @title = title
8
+ @author = author
9
+ @edition = edition
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ module SortingServiceBooks
2
+ class Client
3
+ attr_accessor :books
4
+
5
+ def initialize(file)
6
+ @config = LoadConfig.new(file)
7
+ @books = @config.books
8
+ @conditions = @config.orders
9
+ @sort_books = SortBooks.new(@books, @conditions)
10
+ end
11
+
12
+ def sort
13
+ @sort_books.sort
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,33 @@
1
+ require "yaml"
2
+ module SortingServiceBooks
3
+ class LoadConfig
4
+ attr_accessor :file_config, :orders, :books
5
+
6
+ def initialize(file_config)
7
+ @file_config = file_config
8
+ @orders = get_conditions || []
9
+ @books = get_books || []
10
+ end
11
+
12
+ private
13
+ def get_conditions
14
+ orders = []
15
+ config = YAML::load_file @file_config
16
+ config["conditions"].each do |condition|
17
+ order = Order.new(condition["key"].to_sym, condition["value"].to_sym)
18
+ orders << order if order != nil
19
+ end if config["conditions"]
20
+ orders
21
+ end
22
+
23
+ def get_books
24
+ books = []
25
+ config = YAML::load_file @file_config
26
+ config["books"].each do |b|
27
+ book = Book.new(b["title"], b["author"], b["edition"])
28
+ books << book if book != nil
29
+ end if config["books"]
30
+ books
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,11 @@
1
+
2
+ module SortingServiceBooks
3
+ class Order
4
+ attr_accessor :key, :value
5
+
6
+ def initialize(key, value)
7
+ @key = key
8
+ @value = value
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ module SortingServiceBooks
2
+ class OrderingException < Exception
3
+
4
+ end
5
+ end
@@ -0,0 +1,36 @@
1
+
2
+ module SortingServiceBooks
3
+
4
+ class SortBooks
5
+
6
+ attr_accessor :books, :conditions
7
+
8
+ def initialize(books, conditions)
9
+ @books = books
10
+ @conditions = conditions
11
+ end
12
+
13
+ def sort
14
+ raise OrderingException if @conditions.nil?
15
+
16
+ collection = @books.sort do |a, b|
17
+ methods_call_first = []
18
+ methods_call_second = []
19
+ @conditions.each do |order|
20
+ if order.value == :asc
21
+ methods_call_first << a.send(order.key)
22
+ methods_call_second << b.send(order.key)
23
+ else
24
+ methods_call_second << a.send(order.key)
25
+ methods_call_first << b.send(order.key)
26
+ end
27
+ end
28
+
29
+ methods_call_first <=> methods_call_second
30
+ end
31
+
32
+ collection
33
+ end
34
+ end
35
+
36
+ end
@@ -0,0 +1,6 @@
1
+
2
+ module SortingServiceBooks
3
+
4
+ VERSION = File.read('VERSION')
5
+
6
+ end
@@ -0,0 +1,11 @@
1
+ require "sorting_service_books/sort_books"
2
+ require "sorting_service_books/version"
3
+ require "sorting_service_books/order"
4
+ require "sorting_service_books/book"
5
+ require "sorting_service_books/ordering_exception"
6
+ require "sorting_service_books/load_config"
7
+ require "sorting_service_books/client"
8
+
9
+ module SortingServiceBooks
10
+
11
+ end
@@ -0,0 +1,81 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "sorting_service_books"
8
+ s.version = "0.2.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Douglas Petronilio"]
12
+ s.date = "2014-06-02"
13
+ s.description = "Gem to sorting a collection of the books by any atributes."
14
+ s.email = "dougpetronilio@gmail.com"
15
+ s.executables = ["test.rb"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".rspec",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "bin/test.rb",
30
+ "config_one_condition.yml",
31
+ "config_three_conditions.yml",
32
+ "config_two_conditions.yml",
33
+ "config_without_condition.yml",
34
+ "lib/sorting_service_books.rb",
35
+ "lib/sorting_service_books/book.rb",
36
+ "lib/sorting_service_books/client.rb",
37
+ "lib/sorting_service_books/load_config.rb",
38
+ "lib/sorting_service_books/order.rb",
39
+ "lib/sorting_service_books/ordering_exception.rb",
40
+ "lib/sorting_service_books/sort_books.rb",
41
+ "lib/sorting_service_books/version.rb",
42
+ "sorting_service_books.gemspec",
43
+ "spec/book_spec.rb",
44
+ "spec/client_spec.rb",
45
+ "spec/load_config_spec.rb",
46
+ "spec/order_spec.rb",
47
+ "spec/sort_books_spec.rb",
48
+ "spec/sorting_service_books_spec.rb",
49
+ "spec/spec_helper.rb"
50
+ ]
51
+ s.homepage = "http://github.com/dougpetronilio/sorting_service_books"
52
+ s.licenses = ["MIT"]
53
+ s.require_paths = ["lib"]
54
+ s.rubygems_version = "2.0.3"
55
+ s.summary = "Gem to sorting a collection of the books."
56
+
57
+ if s.respond_to? :specification_version then
58
+ s.specification_version = 4
59
+
60
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
61
+ s.add_development_dependency(%q<rspec>, [">= 0"])
62
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
63
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
64
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
65
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
66
+ else
67
+ s.add_dependency(%q<rspec>, [">= 0"])
68
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
69
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
70
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
71
+ s.add_dependency(%q<simplecov>, [">= 0"])
72
+ end
73
+ else
74
+ s.add_dependency(%q<rspec>, [">= 0"])
75
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
76
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
77
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
78
+ s.add_dependency(%q<simplecov>, [">= 0"])
79
+ end
80
+ end
81
+
data/spec/book_spec.rb ADDED
@@ -0,0 +1,16 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ module SortingServiceBooks
4
+
5
+ describe "Book" do
6
+ describe "#new" do
7
+ it "create the book with params" do
8
+ book = Book.new("java", "deitel", "2007")
9
+
10
+ expect(book.title).to eq "java"
11
+ expect(book.author).to eq "deitel"
12
+ expect(book.edition).to eq "2007"
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,47 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ module SortingServiceBooks
4
+
5
+ describe "Client" do
6
+
7
+ before(:each) do
8
+ @book1 = Book.new("Java How to Program", "Deitel & Deitel", "2007")
9
+ @book2 = Book.new("Patterns of Enterprise Application Architecture", "Martin Fowler", "2002")
10
+ @book3 = Book.new("Head First Design Patterns", "Elisabeth Freeman", "2004")
11
+ @book4 = Book.new("Internet & World Wide Web: How to Program", "Deitel & Deitel", "2007")
12
+ end
13
+
14
+ context "Client start with path to file correct" do
15
+ it "return list books and sort books to one condition" do
16
+ file = "config_one_condition.yml"
17
+ client = Client.new(file)
18
+
19
+ expect(client.books[0].title).to eq(@book1.title)
20
+ expect(client.sort[0].title).to eq(@book3.title)
21
+ end
22
+
23
+ it "return list books and sort books to two conditions" do
24
+ file = "config_two_conditions.yml"
25
+ client = Client.new(file)
26
+
27
+ expect(client.books[0].title).to eq(@book1.title)
28
+ expect(client.sort[0].title).to eq(@book1.title)
29
+ end
30
+
31
+ it "return list books and sort books to two conditions" do
32
+ file = "config_three_conditions.yml"
33
+ client = Client.new(file)
34
+
35
+ expect(client.books[0].title).to eq(@book1.title)
36
+ expect(client.sort[0].title).to eq(@book4.title)
37
+ end
38
+
39
+ it "return empty to books and conditions empty" do
40
+ file = "config_without_condition.yml"
41
+
42
+ client = Client.new(file)
43
+ expect(client.sort).to eq([])
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,82 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ module SortingServiceBooks
4
+ describe "LoadConfig" do
5
+
6
+ before(:each) do
7
+ @book1 = Book.new("Java How to Program", "Deitel & Deitel", "2007")
8
+ @book2 = Book.new("Patterns of Enterprise Application Architecture", "Martin Fowler", "2002")
9
+ @book3 = Book.new("Head First Design Patterns", "Elisabeth Freeman", "2004")
10
+ @book4 = Book.new("Internet & World Wide Web: How to Program", "Deitel & Deitel", "2007")
11
+ end
12
+
13
+ context "load config with one condition" do
14
+ it "return configurations to one condition" do
15
+ file = "config_one_condition.yml"
16
+ order = Order.new(:title, :asc)
17
+ config = LoadConfig.new(file)
18
+
19
+ expect(config.file_config).to eq(file)
20
+ expect(config.orders[0].key).to eq(order.key)
21
+ expect(config.orders[0].value).to eq(order.value)
22
+ end
23
+ end
24
+
25
+ context "load config with two conditions" do
26
+ it "return configurations to two conditions" do
27
+ file = "config_two_conditions.yml"
28
+ order1 = Order.new(:author, :asc)
29
+ order2 = Order.new(:title, :desc)
30
+ config = LoadConfig.new(file)
31
+
32
+ expect(config.orders[0].key).to eq(order1.key)
33
+ expect(config.orders[0].value).to eq(order1.value)
34
+
35
+ expect(config.orders[1].key).to eq(order2.key)
36
+ expect(config.orders[1].value).to eq(order2.value)
37
+ end
38
+ end
39
+
40
+ context "load config with three conditions" do
41
+ it "return configurations to three conditions" do
42
+ file = "config_three_conditions.yml"
43
+ order1 = Order.new(:edition, :desc)
44
+ order2 = Order.new(:author, :desc)
45
+ order3 = Order.new(:title, :asc)
46
+ config = LoadConfig.new(file)
47
+
48
+ expect(config.orders[0].key).to eq(order1.key)
49
+ expect(config.orders[0].value).to eq(order1.value)
50
+
51
+ expect(config.orders[1].key).to eq(order2.key)
52
+ expect(config.orders[1].value).to eq(order2.value)
53
+
54
+ expect(config.orders[2].key).to eq(order3.key)
55
+ expect(config.orders[2].value).to eq(order3.value)
56
+ end
57
+ end
58
+
59
+ context "loag config without conditions" do
60
+ it "return a message to configuration conditions" do
61
+ file = "config_without_condition.yml"
62
+ config = LoadConfig.new(file)
63
+
64
+ expect(config.orders.length).to eq(0)
65
+ end
66
+ end
67
+
68
+ context "load config books" do
69
+ it "return list of books" do
70
+ file = "config_two_conditions.yml"
71
+
72
+ config = LoadConfig.new(file)
73
+
74
+ expect(config.books.length).to eq(4)
75
+ expect(config.books[0].title).to eq(@book1.title)
76
+ expect(config.books[1].title).to eq(@book2.title)
77
+ expect(config.books[2].title).to eq(@book3.title)
78
+ expect(config.books[3].title).to eq(@book4.title)
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,15 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ module SortingServiceBooks
4
+
5
+ describe "Order" do
6
+ describe "#new" do
7
+ it "create the order with params" do
8
+ order = Order.new(:title, :asc)
9
+
10
+ expect(order.key).to eq :title
11
+ expect(order.value).to eq :asc
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,92 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ module SortingServiceBooks
4
+
5
+ describe "SortBooks" do
6
+ let(:java) { double("java", :id => 1, :title => "Java How to Program", :author => "Deitel & Deitel", :edition => "2007").as_null_object }
7
+ let(:patterns) { double("patterns", :id => 2, :title => "Patterns of Enterprise Application Architecture", :author => "Martin Fowler", :edition => "2002").as_null_object }
8
+ let(:head) { double("head", :id => 3, :title => "Head First Design Patterns", :author => "Elisabeth Freeman", :edition => "2004").as_null_object }
9
+ let(:internet) { double("internet", :id => 4, :title => "Internet & World Wide Web: How to Program", :author => "Deitel & Deitel", :edition => "2007").as_null_object }
10
+
11
+ let(:title_asc) { double("title_asc", :key => :title, :value => :asc).as_null_object}
12
+ let(:title_desc) { double("title_desc", :key => :title, :value => :desc).as_null_object}
13
+ let(:author_asc) { double("author_asc", :key => :author, :value => :asc).as_null_object}
14
+ let(:author_desc) { double("author_desc", :key => :author, :value => :desc).as_null_object}
15
+ let(:edition_asc) { double("edition_asc", :key => :edition, :value => :asc).as_null_object}
16
+ let(:edition_desc) { double("edition_desc", :key => :edition, :value => :desc).as_null_object}
17
+
18
+ before(:each) do
19
+ @books = []
20
+ @books << java << patterns << head << internet
21
+
22
+ @conditions = []
23
+ end
24
+
25
+ after(:each) do
26
+ @books = []
27
+ @conditions = []
28
+ end
29
+
30
+ describe "#new" do
31
+ it "should params to SortBooks is correct" do
32
+ @conditions << title_asc
33
+ @conditions << author_asc
34
+ sort_books = SortBooks.new(@books, @conditions)
35
+
36
+ expect(sort_books.books).to match_array([java, patterns, head, internet])
37
+ expect(sort_books.conditions).to match_array([title_asc, author_asc])
38
+ end
39
+ end
40
+
41
+ describe "#sort" do
42
+ context "when title asc" do
43
+ it "return in order head, internet, java and patterns" do
44
+ @conditions << title_asc
45
+ sort_books = SortBooks.new(@books, @conditions)
46
+
47
+ expect(sort_books.sort).to eql([head, internet, java, patterns])
48
+ end
49
+ end
50
+
51
+ context "when author asc and title desc" do
52
+ it "return in order java, internet, head, patterns" do
53
+ @conditions << author_asc
54
+ @conditions << title_desc
55
+ sort_books = SortBooks.new(@books, @conditions)
56
+
57
+ expect(sort_books.sort).to eql([java, internet, head, patterns])
58
+ end
59
+ end
60
+
61
+ context "when edition desc, author desc, title asc" do
62
+ it "return in order internet, java, head, patterns" do
63
+ @conditions << edition_desc
64
+ @conditions << author_desc
65
+ @conditions << title_asc
66
+ sort_books = SortBooks.new(@books, @conditions)
67
+
68
+ expect(sort_books.sort).to eql([internet, java, head, patterns])
69
+ end
70
+ end
71
+
72
+ context "when conditions is nil" do
73
+ it "return OrderingException if conditions is nil" do
74
+ @conditions = nil
75
+ sort_books = SortBooks.new(@books, @conditions)
76
+ expect { sort_books.sort }.to raise_error OrderingException
77
+ end
78
+ end
79
+
80
+ context "when conditions or books is empty" do
81
+ it "return empty array" do
82
+ @conditions = []
83
+ @books = []
84
+ sort_books = SortBooks.new(@books, @conditions)
85
+ expect(sort_books.sort).to eq([])
86
+ end
87
+ end
88
+ end
89
+
90
+ end
91
+
92
+ end
@@ -1,7 +1,13 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe "SortingServiceBooks" do
4
- it "fails" do
5
- fail "hey buddy, you should probably rename this file and start specing for real"
3
+ module SortingServiceBooks
4
+
5
+ describe "SortingServiceBooks" do
6
+
7
+ it "should have a version" do
8
+ expect(SortingServiceBooks.const_defined?('VERSION')).to eq(true)
9
+ end
10
+
6
11
  end
12
+
7
13
  end
data/spec/spec_helper.rb CHANGED
@@ -25,5 +25,7 @@ require 'sorting_service_books'
25
25
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
26
26
 
27
27
  RSpec.configure do |config|
28
-
28
+ config.expect_with :rspec do |c|
29
+ c.syntax = :expect
30
+ end
29
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sorting_service_books
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Douglas Petronilio
@@ -14,16 +14,16 @@ dependencies:
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.8.0
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.8.0
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rdoc
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +82,8 @@ dependencies:
82
82
  version: '0'
83
83
  description: Gem to sorting a collection of the books by any atributes.
84
84
  email: dougpetronilio@gmail.com
85
- executables: []
85
+ executables:
86
+ - test.rb
86
87
  extensions: []
87
88
  extra_rdoc_files:
88
89
  - LICENSE.txt
@@ -96,7 +97,25 @@ files:
96
97
  - README.rdoc
97
98
  - Rakefile
98
99
  - VERSION
100
+ - bin/test.rb
101
+ - config_one_condition.yml
102
+ - config_three_conditions.yml
103
+ - config_two_conditions.yml
104
+ - config_without_condition.yml
99
105
  - lib/sorting_service_books.rb
106
+ - lib/sorting_service_books/book.rb
107
+ - lib/sorting_service_books/client.rb
108
+ - lib/sorting_service_books/load_config.rb
109
+ - lib/sorting_service_books/order.rb
110
+ - lib/sorting_service_books/ordering_exception.rb
111
+ - lib/sorting_service_books/sort_books.rb
112
+ - lib/sorting_service_books/version.rb
113
+ - sorting_service_books.gemspec
114
+ - spec/book_spec.rb
115
+ - spec/client_spec.rb
116
+ - spec/load_config_spec.rb
117
+ - spec/order_spec.rb
118
+ - spec/sort_books_spec.rb
100
119
  - spec/sorting_service_books_spec.rb
101
120
  - spec/spec_helper.rb
102
121
  homepage: http://github.com/dougpetronilio/sorting_service_books