0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Simple Table is a gem that enables the developer to create some examples in a table, making the job of writing specs easier
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

samples_table is a gem that helps the job of writing tests and specs. Based on cucumber's tables, you can create simple test cases easily. Since it 'embed' the table into ruby code, it avoids the need of configurations, and/or the creation and use of third test files for the examples.


Default Configuration:

# Gemfile (you may just need to add the samples table line)
group :development, :test do
  gem 'samples_table'
end

Configuration(with RSpec):

# spec_helper.rb
RSpec.configure do |config|
	#your old config here
	config.extend SamplesTable, :type => :model
end

Example(with RSpec):

#sale_spec.rb
require 'spec_helper'
describe Sale do
  describe "selling fruits" do
    (samples [ :fruit , :quantity , :total ],
             [ :apple ,     1     ,   1.0  ],
             [ :apple ,     2     ,   2.0  ],
             [ :apple ,    10     ,   9.5  ],#should apply discount when sells 10+
             [ :orange,     1     ,   2.0  ],
             [ :orange,     2     ,   4.0  ],
             [ :orange,    10     ,  19.0  ]).each_sample do |sample|
      describe "when selling #{sample.fruit}" do
        before{subject.fruit = sample.fruit}
        describe "and the customer wants to buy #{sample.quantity}" do
          before{subject.quantity = sample.quantity}
          it "should totalize #{sample.total} bucks" do
            subject.total.should eql sample.total
          end
        end
      end
    end
  end
end

Feel free to comment/help.


License:

samples_table is released under the MIT license.