Skip to content

Commit

Permalink
[ARCH/DOC] Use Jeweler for building gems. Updated documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
hosh committed Apr 22, 2010
1 parent a1c3f98 commit 8b4fbc9
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 138 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ lib/remarkable-more.rb
*.diff
memory
*.tmproj
*gemspec
37 changes: 23 additions & 14 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@ constituted of three pieces:

* Remarkable: the framework with helpers, DSL, I18n and rspec features;

* Remarkable ActiveModel: a collection of matchers for ActiveModel compliant models. It
currently supports all ActiveModel validations. Future plan include testing for
ActiveModel API compliance and ActiveModel serialization.

* Remarkable ActiveRecord: a collection of matchers for ActiveRecord. It
supports all ActiveRecord validations, associations and some extra matchers.

* Remarkable Rails: a collection of matchers for ActionController. It also
includes MacroStubs, which is a clean DSL for stubbing your controller methods.

NOTE: Remarkable Rails is currently not available for version 4.0.0.alpha1
We are thinking of breaking this up into Remarkable Rack, and Remarkable ActionController
gems, along the lines of splitting off ActiveModel macros.

In each folder above, you can find a README more detailed description of each piece.

== Why use Remarkable for Rails?
Expand All @@ -30,11 +38,11 @@ In each folder above, you can find a README more detailed description of each pi
:through, :source, :source_type, :class_name, :foreign_key, :dependent,
:join_table, :uniq, :readonly, :validate, :autosave, :counter_cache, :polymorphic

Plus SQL options:
Plus Arel scopes:

:select, :conditions, :include, :group, :having, :order, :limit, :offset
:select, :where, :include, :group, :having, :order, :limit, :offset

Besides in Remarkable 3.0 matchers became much smarter. Whenever :join_table
Besides in Remarkable 4.0 matchers became much smarter. Whenever :join_table
or :through is given as option, it checks if the given table exists. Whenever
:foreign_key or :counter_cache is given, it checks if the given column exists;

Expand Down Expand Up @@ -64,7 +72,7 @@ In each folder above, you can find a README more detailed description of each pi
# Or: m.greater_than = 18
end

Remarkable Rails requires rspec >= 1.2.0 and rspec-rails >= 1.2.0.
Remarkable Rails requires rspec >= 2.0.0 and rspec-rails >= 2.0.0.

== Install on Rails

Expand All @@ -77,24 +85,25 @@ This will install remarkable, remarkable_activerecord and remarkable_rails gems.
Inside Rails you need to require just this gem. If you are using ActiveRecord,
it will automatically require the remarkable_activerecord gem.

== Rails 2.3
== Rails 3

In Rails 2.3, in order to rspec load properly, you have to use this configuration
on your config/environments/test.rb
In Rails 3, in order to rspec load properly, you have to use this configuration
on your Gemfile

config.gem "rspec", :lib => false
config.gem "rspec-rails", :lib => false
config.gem "remarkable_rails", :lib => false
gem "rspec"
gem "rspec-rails"
gem "remarkable_rails"

And then require remarkable inside your spec_helper.rb, after "spec/rails":

require 'spec/rails'
require 'rspec/rails'
require 'remarkable_rails'

This is the safest way to avoid conflicts.

Users who are upgrading to Remarkable 3.0, should not find any problem if their
tests are running without deprecation warnings.
Please note, due to the massive refactoring in Rails 3 and Rspec 2, we are not supporting
backwards compatibility with Rails 2 or Rspec 1. You will need to use the Remarkable 3.x series
if you are still using Rails 2.

== Developers

Expand Down Expand Up @@ -124,7 +133,7 @@ Remarkable Rails:
== More information

Google group: http://groups.google.com/group/remarkable-core
Bug tracking: http://github.com/carlosbrando/remarkable/issues
Bug tracking: http://github.com/remarkable/remarkable/issues

== LICENSE

Expand Down
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ REMARKABLE_GEMS = [
:remarkable,
:remarkable_activemodel,
:remarkable_activerecord,
# :remarkable_datamapper,
:remarkable_rails
#:remarkable_datamapper,
#:remarkable_rails
]

REMARKABLE_GEMS_PATHS = REMARKABLE_GEMS.map{|g| File.join(current_dir, g.to_s)}
Expand Down Expand Up @@ -47,7 +47,7 @@ end

unique_tasks :clobber_package
recursive_tasks :clobber_rdoc, :gem, :gemspec, :install, :package, :pre_commit,
:rdoc, :repackage, :rerdoc, :spec, :uninstall
:rdoc, :repackage, :rerdoc, :spec, :uninstall, :build

desc "Default Task"
task :default do
Expand Down
88 changes: 30 additions & 58 deletions rake_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,72 +15,44 @@
PACKAGE_DIR = File.join(File.dirname(__FILE__), 'pkg')
RELEASE_NAME = "REL #{GEM_VERSION}"

RSPEC_VERSION = '1.2.0'
RSPEC_VERSION = '2.0.0.alpha7'

def self.configure_gemspec!
$spec = Gem::Specification.new do |s|
s.rubyforge_project = RUBY_FORGE_PROJECT
s.name = GEM_NAME
s.version = GEM_VERSION
s.platform = Gem::Platform::RUBY
s.has_rdoc = true
s.extra_rdoc_files = EXTRA_RDOC_FILES
s.summary = PROJECT_SUMMARY
s.description = PROJECT_DESCRIPTION
s.authors = GEM_AUTHOR
s.email = GEM_EMAIL
s.homepage = PROJECT_URL
s.require_path = 'lib'
s.files = EXTRA_RDOC_FILES + Dir.glob("{lib,locale}/**/*") + Dir.glob("*.gemspec")
s.add_dependency('rspec', ">= #{RSPEC_VERSION}")
yield s if block_given?
end

Rake::GemPackageTask.new($spec) do |pkg|
pkg.package_dir = PACKAGE_DIR
pkg.gem_spec = $spec
pkg.need_zip = true
pkg.need_tar = true
end
end

desc "Create a gemspec file"
task :gemspec do
File.open("#{GEM_NAME}.gemspec", "w") do |file|
file.puts $spec.to_ruby
begin
require 'jeweler'
Jeweler::Tasks.new do |gemspec|
gemspec.rubyforge_project = RUBY_FORGE_PROJECT
gemspec.name = GEM_NAME
gemspec.version = GEM_VERSION
gemspec.platform = Gem::Platform::RUBY
gemspec.has_rdoc = true
gemspec.extra_rdoc_files = EXTRA_RDOC_FILES
gemspec.summary = PROJECT_SUMMARY
gemspec.description = PROJECT_DESCRIPTION
gemspec.authors = GEM_AUTHOR
gemspec.email = GEM_EMAIL
gemspec.homepage = PROJECT_URL
gemspec.require_path = 'lib'
gemspec.files = EXTRA_RDOC_FILES + Dir.glob("{lib,locale}/**/*") + Dir.glob("*.gemspec")
gemspec.add_dependency('rspec', ">= #{RSPEC_VERSION}")
yield gemspec if block_given?
end
Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler not available. Install it with: gem install jeweler"
end
end

desc "Build the gem and install it"
task :install => :gem do
system("sudo gem install #{PACKAGE_DIR}/#{GEM_NAME}-#{GEM_VERSION}.gem --local --ignore-dependencies --no-ri --no-rdoc")
end

desc "Uninstall the gem"
task :uninstall do
system("sudo gem uninstall #{GEM_NAME} --version #{GEM_VERSION}")
end

########### Common specs

gem 'rspec'
begin
# Rspec2
gem 'rspec-expectations'
require 'rspec/core/rake_task'
desc "Run the specs under spec"
Rspec::Core::RakeTask.new do |t|
#t.spec_opts = ['--options', "spec/spec.opts"]
#t.spec_files = FileList['spec/**/*_spec.rb']
end
rescue
# Rspec1
require 'spec/rake/spectask'
desc "Run the specs under spec"
Spec::Rake::SpecTask.new do |t|
t.spec_opts = ['--options', "spec/spec.opts"]
t.spec_files = FileList['spec/**/*_spec.rb']
end
gem 'rspec', ">= #{RSPEC_VERSION}"
# Rspec2
gem 'rspec-expectations'
require 'rspec/core/rake_task'
desc "Run the specs under spec"
Rspec::Core::RakeTask.new do |t|
# Stub
end


Expand Down
27 changes: 3 additions & 24 deletions remarkable/README
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,6 @@ And it will show in your specs output:

"Example disabled: require name to be set"

== Pending macros

In Rspec you can mark some examples as pending:

it "should have one manager" do
pending("create managers resource")
end

it "should validate associated manager" do
pending("create managers resource")
end

To allow this to work with macros, we created the pending group:

pending "create managers resource" do
should_have_one :manager
should_validate_associated :manager
end

This outputs the same as above.

== I18n

All matchers come with I18n support. You can find an example locale file under
Expand All @@ -85,9 +64,9 @@ Create a new matcher is easy. Let's create validate_inclusion_of matcher for
ActiveRecord as an example. A first matcher version would be:

module Remarkable
module ActiveRecord
module ActiveModel
module Matchers
class ValidateInclusionOfMatcher < Remarkable::ActiveRecord::Base
class ValidateInclusionOfMatcher < Remarkable::ActiveModel::Base
arguments :attribute
assertion :is_valid?

Expand Down Expand Up @@ -131,7 +110,7 @@ As you noticed, the matcher doesn't have any message on it. You add them on I18n
file. A file for this example would be:

remarkable:
active_record:
active_model:
validate_inclusion_of:
description: "validate inclusion of {{attribute}}"
expectations:
Expand Down
6 changes: 3 additions & 3 deletions remarkable/Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# encoding: utf-8
PROJECT_SUMMARY = "Remarkable: a framework for rspec matchers, with support to macros and I18n."
PROJECT_SUMMARY = "Remarkable: a framework for rspec matchers and macros, with support for I18n."
PROJECT_DESCRIPTION = PROJECT_SUMMARY

GEM_NAME = "remarkable"
GEM_AUTHOR = [ "Carlos Brando", "José Valim" ]
GEM_EMAIL = [ "eduardobrando@gmail.com", "jose.valim@gmail.com" ]
GEM_AUTHOR = [ "Ho-Sheng Hsiao", "Carlos Brando", "José Valim" ]
GEM_EMAIL = [ "hosh@sparkfly.com", "eduardobrando@gmail.com", "jose.valim@gmail.com" ]

EXTRA_RDOC_FILES = ["README", "LICENSE", "CHANGELOG"]

Expand Down
2 changes: 1 addition & 1 deletion remarkable/lib/remarkable/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Remarkable
VERSION = '3.1.12' unless self.const_defined?(:VERSION)
VERSION = '4.0.0.alpha1' unless self.const_defined?(:VERSION)
end
41 changes: 14 additions & 27 deletions remarkable_activemodel/README
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,39 @@ Remarkable?
exceptions are validate_format_of (which should be invoked as allow_values_for)
and the :on option;

* Matchers for all ActiveModel associations. The only one which supports all
these options:

:through, :source, :source_type, :class_name, :foreign_key, :dependent,
:join_table, :uniq, :readonly, :validate, :autosave, :counter_cache, :polymorphic

Plus SQL options:

:select, :conditions, :include, :group, :having, :order, :limit, :offset

Besides in Remarkable 3.0 matchers became much smarter. Whenever :join_table
or :through is given as option, it checks if the given table exists. Whenever
:foreign_key or :counter_cache is given, it checks if the given column exists;
This means you can test your validations any model that mixes-in ActiveModel::Validations

* Tests and more tests. We have a huge tests suite ready to run and tested in
ActiveModel 2.1.2, 2.2.2 and 2.3.2;
ActiveModel 3.0.0;

* Great documentation;

* I18n.

Upcoming features:
* Matchers wrapping ActiveModel::Lint for testing ActiveModel API compliance.
This means your custom models using RESTClient, for example, can play nice with
Rails.

* Matchers testing ActiveModel::Serialization
This allows you to test for compliance if you are using special serialization
methods, or require the use of Presenters in your application.


== Examples

All Remarkable macros can be accessed in two different ways. For those who prefer the Shoulda style, let’s look at some model tests:

describe Post do
should_belong_to :user
should_have_many :comments
should_have_and_belong_to_many :tags

should_validate_presence_of :body
should_validate_presence_of :title
should_validate_uniqueness_of :title, :allow_blank => true
end

For those who likes more the Rspec way can simply do:

describe Post do
it { should belong_to(:user) }
it { should have_many(:comments) }
it { should have_and_belong_to_many(:tags) }

it { should validate_presence_of(:body) }
it { should validate_presence_of(:title) }
it { should validate_uniqueness_of(:title, :allow_blank => true) }
end

== I18n
Expand All @@ -75,13 +63,12 @@ a few things:
1. Internationalization is powered by the I18n gem. If you are using it with Rails,
it will use the built in gem, otherwise you will have to install the gem by hand:

gem sources -a http://gems.github.com
sudo gem install svenfuchs-i18n
gem install i18n

2. Include the matchers. Remarkable Rails gem is the responsable to add
ActiveModel matchers to rspec. If you are not using it, you have to do:

Remarkable.include_matchers!(Remarkable::ActiveModel, Spec::Example::ExampleGroup)
Remarkable.include_matchers!(Remarkable::ActiveModel, Rspec::Core::ExampleGroup)

This will make ActiveModel matchers available in all rspec example groups.

6 changes: 3 additions & 3 deletions remarkable_activemodel/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
PROJECT_SUMMARY = "Remarkable ActiveModel: collection of matchers and macros with I18n for ActiveModel"
PROJECT_DESCRIPTION = PROJECT_SUMMARY

GEM_NAME = "remarkable_activerecord"
GEM_AUTHOR = [ "Carlos Brando", "José Valim", "Diego Carrion" ]
GEM_EMAIL = [ "eduardobrando@gmail.com", "jose.valim@gmail.com", "dc.rec1@gmail.com" ]
GEM_NAME = "remarkable_activemodel"
GEM_AUTHOR = [ "Ho-Sheng Hsiao", "Carlos Brando", "José Valim", "Diego Carrion" ]
GEM_EMAIL = [ "hosh@sparkfly.com", "eduardobrando@gmail.com", "jose.valim@gmail.com", "dc.rec1@gmail.com" ]

EXTRA_RDOC_FILES = ["README", "LICENSE", "CHANGELOG"]

Expand Down
6 changes: 3 additions & 3 deletions remarkable_activerecord/README
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Remarkable?
:through, :source, :source_type, :class_name, :foreign_key, :dependent,
:join_table, :uniq, :readonly, :validate, :autosave, :counter_cache, :polymorphic

Plus SQL options:
Plus Arel scopes:

:select, :conditions, :include, :group, :having, :order, :limit, :offset
:select, :where, :include, :group, :having, :order, :limit, :offset

Besides in Remarkable 3.0 matchers became much smarter. Whenever :join_table
or :through is given as option, it checks if the given table exists. Whenever
Expand Down Expand Up @@ -81,7 +81,7 @@ a few things:
2. Include the matchers. Remarkable Rails gem is the responsable to add
ActiveRecord matchers to rspec. If you are not using it, you have to do:

Remarkable.include_matchers!(Remarkable::ActiveRecord, Spec::Example::ExampleGroup)
Remarkable.include_matchers!(Remarkable::ActiveRecord, Rspec::Core::ExampleGroup)

This will make ActiveRecord matchers available in all rspec example groups.

Loading

0 comments on commit 8b4fbc9

Please sign in to comment.