This repository has been archived by the owner on Apr 13, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit eabb69b
Showing
9 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.gem | ||
.bundle | ||
Gemfile.lock | ||
pkg/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--colour |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source "http://rubygems.org" | ||
|
||
# Specify your gem's dependencies in samples_table.gemspec | ||
gemspec |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require 'bundler' | ||
Bundler::GemHelper.install_tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module SamplesTable | ||
class Table < Array | ||
alias :each_sample :each | ||
|
||
def initialize(*values) | ||
@header = values.shift | ||
values.each do |sample_values| | ||
self.<< sample_values | ||
end | ||
end | ||
|
||
def <<(sample_values) | ||
super(Sample.new(@header, sample_values)) | ||
end | ||
|
||
end | ||
|
||
class Sample | ||
def initialize(keys, sample_values) | ||
@sample_properties = Hash.new | ||
keys.each do |key| | ||
@sample_properties[key] = sample_values.shift | ||
end | ||
end | ||
def method_missing(m, *args, &block) | ||
@sample_properties[m] | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module SamplesTable | ||
VERSION = "0.0.1" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- encoding: utf-8 -*- | ||
$:.push File.expand_path("../lib", __FILE__) | ||
require "samples_table/version" | ||
|
||
Gem::Specification.new do |s| | ||
s.name = "samples_table" | ||
s.version = SamplesTable::VERSION | ||
s.platform = Gem::Platform::RUBY | ||
|
||
s.authors = ["Gregório Chalinski Kusowski"] | ||
s.email = ["gregorio.kusowski@gmail.com"] | ||
s.homepage = "http://github.com/gregoriokusowski" | ||
s.summary = %q{Helper to create examples table for testing} | ||
s.description = %q{Simple Table is a gem that enables the developer to create some examples in a table, making the job of writing specs easier} | ||
|
||
s.add_development_dependency 'rspec' | ||
|
||
s.rubyforge_project = "samples_table" | ||
|
||
s.files = `git ls-files`.split("\n") | ||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | ||
s.require_paths = ["lib"] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'rspec' | ||
require 'samples_table' | ||
|
||
describe SamplesTable do | ||
|
||
subject do | ||
SamplesTable::Table.new [:valor_teste , :nenhum_valor , :algo_legal , :esqueceram_de_mim ], | ||
[ 66 , 10 , 20 , 66 ], | ||
[ 15 , 30 , 20 , 30 ] | ||
end | ||
|
||
let(:first_sample){subject[0]} | ||
let(:second_sample){subject[1]} | ||
|
||
it {first_sample.valor_teste.should eql 66} | ||
it {first_sample.nenhum_valor.should eql 10} | ||
it {first_sample.algo_legal.should eql 20} | ||
it {first_sample.esqueceram_de_mim.should eql 66} | ||
|
||
it {second_sample.valor_teste.should eql 15} | ||
it {second_sample.nenhum_valor.should eql 30} | ||
it {second_sample.algo_legal.should eql 20} | ||
it {second_sample.esqueceram_de_mim.should eql 30} | ||
|
||
it {subject.size.should eql 2} | ||
|
||
it {subject.should be_a_kind_of(Array)} | ||
|
||
it {subject.should respond_to(:each_sample)} | ||
|
||
end |