Permalink
Browse files

Initial release.

  • Loading branch information...
0 parents commit ac23ee834368ff6f727db7a40a40f3b2c4b40cda @ZenCocoon committed Jul 1, 2011
@@ -0,0 +1,15 @@
+*.rbc
+*.sw?
+.DS_Store
+.bundle
+.rvmrc
+.yardoc
+Gemfile.lock
+bin
+coverage*
+doc
+pkg
+rdoc
+rerun.txt
+tags
+tmp
@@ -0,0 +1,8 @@
+script: "bin/rake --trace 2>&1"
+bundler_args: "--binstubs --without development"
+rvm:
+ - 1.8.6
+ - 1.8.7
+ - 1.9.1
+ - 1.9.2
+ - ree
@@ -0,0 +1,8 @@
+--no-document
+--no-private
+--exclude features
+--title 'Rspec Subject Extensions Documentation'
+-
+README.md
+Changelog.md
+License.txt
@@ -0,0 +1,7 @@
+appraise "3.0" do
+ gem "activesupport", "~> 3.0"
+end
+
+appraise "3.1.0.rc" do
+ gem "activesupport", "~> 3.1.0.rc4"
+end
@@ -0,0 +1,3 @@
+### 0.1.0 / 2011-07-01
+
+* Initial release.
49 Gemfile
@@ -0,0 +1,49 @@
+source "http://rubygems.org"
+
+### rspec libs
+%w[rspec rspec-core rspec-expectations rspec-mocks].each do |lib|
+ library_path = File.expand_path("../../#{lib}", __FILE__)
+ if File.exist?(library_path)
+ gem lib, :path => library_path
+ else
+ gem lib, :git => "git://github.com/rspec/#{lib}.git"
+ end
+end
+
+### runtime dependencies
+gem "i18n", "~> 0.6.0"
+gem "activesupport", ">= 3.0"
+
+### dev dependencies
+gem "rake", "~> 0.9"
+gem "cucumber", "1.0.0"
+gem "aruba", "0.4.2"
+gem "nokogiri", "1.4.4"
+
+platforms :jruby do
+ gem "jruby-openssl"
+end
+
+group :development do
+ gem "rcov", "0.9.9", :platforms => :mri
+ gem "relish", "0.4.0"
+ gem 'yard', "~> 0.7.2"
+ gem "guard-rspec", "0.1.9"
+ gem "growl", "1.0.3"
+ gem "appraisal", :git => "git://github.com/thoughtbot/appraisal.git"
+
+ platforms :mri_18 do
+ gem 'ruby-debug'
+ end
+
+ platforms :mri_19 do
+ gem 'linecache19', '0.5.11' # 0.5.12 cannot install on 1.9.1, and 0.5.11 appears to work with both 1.9.1 & 1.9.2
+ gem 'ruby-debug19'
+ gem 'ruby-debug-base19', RUBY_VERSION == '1.9.1' ? '0.11.23' : '~> 0.11.24'
+ end
+
+ platforms :mri_18, :mri_19 do
+ gem "rb-fsevent", "~> 0.3.9"
+ gem "ruby-prof", "~> 0.9.2"
+ end
+end
@@ -0,0 +1,5 @@
+guard 'rspec', :version => 2 do
+ watch(/^spec\/(.*)_spec.rb/)
+ watch(/^lib\/(.*)\.rb/) { |m| "spec/#{m[1]}_spec.rb" }
+ watch(/^spec\/spec_helper.rb/) { "spec" }
+end
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2011 Sébastien Grosjean
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,55 @@
+# RSpec Subject Extensions
+
+rspec-subject-extensions adds `each` short-hand to generate a nested example group with
+a single example that specifies the expected value of each attribute of the subject.
+
+[![build status](http://travis-ci.org/ZenCocoon/rspec-subject-extensions.png)](http://travis-ci.org/ZenCocoon/rspec-subject-extensions)
+
+## Documentation
+
+The [Cucumber features](http://relishapp.com/ZenCocoon/rspec-subject-extensions)
+are the most comprehensive and up-to-date docs for end-users.
+
+The [RDoc](http://rubydoc.info/gems/rspec-subject-extensions/0.1.0/frames) provides
+additional information for contributors and/or extenders.
+
+All of the documentation is open source and a work in progress. If you find it
+lacking or confusing, you can help improve it by submitting requests and
+patches to the [rspec-subject-extensions issue
+tracker](https://github.com/ZenCocoon/rspec-subject-extensions/issues).
+
+## Install
+
+ gem install rspec-subject-extensions
+
+## Usage
+
+### Each
+
+Creates a nested example group named by `each` and the submitted `attribute`,
+and then generates an example for each attribute using the submitted block.
+
+ # This ...
+ describe Object do
+ each(:item) { should be_an(Integer) }
+ end
+
+ # ... generates the same runtime structure as this:
+ describe Object do
+ describe "each item"
+ it "should be an Integer" do
+ subject.items.each do |item|
+ item.should be_an(Integer)
+ end
+ end
+ end
+ end
+
+The `attribute` can be a `Symbol` or a `String`.
+
+## Also see
+
+* [http://github.com/rspec/rspec](http://github.com/rspec/rspec)
+* [http://github.com/rspec/rspec-core](http://github.com/rspec/rspec-core)
+* [http://github.com/rspec/rspec-expectations](http://github.com/rspec/rspec-expectations)
+* [http://github.com/rspec/rspec-mocks](http://github.com/rspec/rspec-mocks)
@@ -0,0 +1,66 @@
+require 'bundler'
+Bundler.setup
+Bundler::GemHelper.install_tasks
+
+# require 'appraisal'
+
+require 'rake'
+require 'rspec/core/rake_task'
+require 'rspec/subject/extensions/version'
+
+require 'cucumber/rake/task'
+Cucumber::Rake::Task.new(:cucumber)
+
+desc "Run all examples"
+RSpec::Core::RakeTask.new(:spec) do |t|
+ t.rspec_opts = %w[--color]
+end
+
+if RUBY_VERSION.to_f == 1.8
+ namespace :rcov do
+ desc "Run all examples using rcov"
+ RSpec::Core::RakeTask.new :spec => :cleanup_rcov_files do |t|
+ t.rcov = true
+ t.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,features"]
+ t.rcov_opts << %[--text-report --sort coverage --no-html --aggregate coverage.data]
+ end
+
+ desc "Run cucumber features using rcov"
+ Cucumber::Rake::Task.new :cucumber => :cleanup_rcov_files do |t|
+ t.cucumber_opts = %w{--format progress}
+ t.rcov = true
+ t.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,features"]
+ t.rcov_opts << %[--text-report --sort coverage --aggregate coverage.data]
+ end
+
+ task :cleanup do
+ rm_rf 'coverage.data'
+ end
+ end
+end
+
+desc "run specs and cukes with rcov"
+task :rcov => ["rcov:cleanup", "rcov:spec", "rcov:cucumber"]
+
+desc "Push docs/cukes to relishapp using the relish-client-gem"
+task :relish, :version do |t, args|
+ raise "rake relish[VERSION]" unless args[:version]
+ sh "cp Changelog.md features/"
+ sh "relish push ZenCocoon/rspec-subject-extensions:#{args[:version]}"
+ sh "rm features/Changelog.md"
+end
+
+task :clobber do
+ rm_rf 'pkg'
+ rm_rf 'tmp'
+ rm_rf 'coverage'
+end
+
+namespace :clobber do
+ desc "remove generated rbc files"
+ task :rbc do
+ Dir['**/*.rbc'].each {|f| File.delete(f)}
+ end
+end
+
+task :default => [:spec, :cucumber]
@@ -0,0 +1,2 @@
+default: --require features --tags ~@wip features --format progress
+wip: --require features --tags @wip:3 --wip features
@@ -0,0 +1,3 @@
+- Changelog.md
+- Extensions
+ - each_attribute_of_subject.feature
@@ -0,0 +1,35 @@
+rspec-subject-extensions adds `each` short-hand to generate a nested example group with
+a single example that specifies the expected value of each attribute of the subject.
+
+## Each
+
+Creates a nested example group named by +each+ and the submitted +attribute+,
+and then generates an example for each attribute using the submitted block.
+
+ # This ...
+ describe Object do
+ each(:item) { should be_an(Integer) }
+ end
+
+ # ... generates the same runtime structure as this:
+ describe Object do
+ describe "each item"
+ it "should be an Integer" do
+ subject.items.each do |item|
+ item.should be_an(Integer)
+ end
+ end
+ end
+ end
+
+The +attribute+ can be a +Symbol+ or a +String+.
+
+## Issues
+
+The documentation for rspec-subject-extensions is a work in progress. We'll be adding
+Cucumber features over time, and clarifying existing ones. If you have
+specific features you'd like to see added, find the existing documentation
+incomplete or confusing, or, better yet, wish to write a missing Cucumber
+feature yourself, please [submit an
+issue](http://github.com/ZenCocoon/rspec-subject-extensions/issues) or a [pull
+request](http://github.com/ZenCocoon/rspec-subject-extensions).
@@ -0,0 +1,31 @@
+Feature: each attribute of subject
+
+ Use the each() method as a short-hand to generate a nested example group with
+ a single example that specifies the expected value of each attribute of the
+ subject. This can be used with an implicit or explicit subject.
+
+ each() accepts a symbol or a string, and a block representing the example.
+
+ each(:item) { should be_an(Item) }
+ each("article") { should be_an(Article) }
+
+ Scenario: specify value of each attribute
+ Given a file named "example_spec.rb" with:
+ """
+ class Movie
+ def ratings
+ [9, 7, 9]
+ end
+ end
+
+ describe Movie do
+ each(:rating) { should be_an(Integer) }
+ end
+ """
+ When I run `rspec example_spec.rb --format documentation`
+ Then the output should contain:
+ """
+ Movie
+ each rating
+ should be a kind of Integer
+ """
@@ -0,0 +1,5 @@
+require 'aruba/cucumber'
+
+Before do
+ @aruba_timeout_seconds = 5
+end
@@ -0,0 +1 @@
+require 'rspec/subject/extensions'
@@ -0,0 +1,10 @@
+require 'rspec/subject/extensions/each'
+require 'rspec/subject/extensions/version'
+
+module RSpec
+ module Subject
+ # RSpec::Subject::Extensions let's you use short-hands to generate nested examples groups
+ module Extensions
+ end
+ end
+end
Oops, something went wrong.

0 comments on commit ac23ee8

Please sign in to comment.