Permalink
Browse files

Move to RSpec (with Guard)

  • Loading branch information...
benlangfeld committed Nov 2, 2011
1 parent d509081 commit 4e034f416314f278318a353bec364ce880ed0c26
Showing with 123 additions and 111 deletions.
  1. +4 −0 .rspec
  2. +5 −0 Gemfile
  3. +5 −0 Guardfile
  4. +6 −13 Rakefile
  5. +2 −2 niceogiri.gemspec
  6. +39 −39 spec/niceogiri/core_ext/nokogiri_spec.rb
  7. +53 −53 spec/niceogiri/xml/node_spec.rb
  8. +9 −4 spec/spec_helper.rb
View
4 .rspec
@@ -0,0 +1,4 @@
+--colour
+--tty
+--format documentation
+--profile
View
@@ -2,3 +2,8 @@ source "http://rubygems.org"
# Specify your gem's dependencies in niceogiri.gemspec
gemspec
+
+if RUBY_PLATFORM =~ /darwin/
+ gem 'growl_notify'
+ gem 'rb-fsevent'
+end
View
@@ -0,0 +1,5 @@
+guard 'rspec', :version => 2, :cli => '--format documentation' do
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
+ watch('spec/spec_helper.rb') { "spec/" }
+end
View
@@ -1,21 +1,14 @@
require 'rubygems'
+require 'bundler/setup'
require 'rake'
require 'bundler/gem_tasks'
-require 'rake/testtask'
-Rake::TestTask.new(:test) do |test|
- test.libs << 'lib' << 'spec'
- test.pattern = 'spec/**/*_spec.rb'
- test.verbose = true
-end
+require 'rspec/core'
+require 'rspec/core/rake_task'
-require 'rcov/rcovtask'
-Rcov::RcovTask.new do |test|
- test.libs << 'spec'
- test.pattern = 'spec/**/*_spec.rb'
- test.rcov_opts += ['--exclude \/Library\/Ruby,spec\/', '--xrefs']
- test.verbose = true
+RSpec::Core::RakeTask.new(:spec) do |spec|
+ spec.pattern = FileList['spec/**/*_spec.rb']
end
require 'yard'
@@ -24,4 +17,4 @@ YARD::Rake::YardocTask.new(:doc) do |t|
t.options = ['--no-private', '-m', 'markdown', '-o', './doc/public/yard']
end
-task :default => :test
+task :default => :spec
View
@@ -21,9 +21,9 @@ Gem::Specification.new do |s|
s.add_dependency "nokogiri", [">= 1.4.0"]
- s.add_development_dependency "minitest", ["~> 1.7.1"]
+ s.add_development_dependency "rspec", [">= 2.7.0"]
s.add_development_dependency "bundler", ["~> 1.0.0"]
- s.add_development_dependency "rcov", ["~> 0.9.9"]
s.add_development_dependency "yard", ["~> 0.6.1"]
s.add_development_dependency "rake"
+ s.add_development_dependency "guard-rspec"
end
@@ -1,92 +1,92 @@
require 'spec_helper'
describe 'Nokogiri::XML::Node' do
- before { @doc = Nokogiri::XML::Document.new }
+ let(:doc) { Nokogiri::XML::Document.new }
it 'aliases #name to #element_name' do
- node = Nokogiri::XML::Node.new 'foo', @doc
- node.must_respond_to :element_name
- node.element_name.must_equal node.name
+ node = Nokogiri::XML::Node.new 'foo', doc
+ node.should respond_to :element_name
+ node.element_name.should == node.name
end
it 'aliases #name= to #element_name=' do
- node = Nokogiri::XML::Node.new 'foo', @doc
- node.must_respond_to :element_name=
- node.element_name.must_equal node.name
+ node = Nokogiri::XML::Node.new 'foo', doc
+ node.should respond_to :element_name=
+ node.element_name.should == node.name
node.element_name = 'bar'
- node.element_name.must_equal 'bar'
+ node.element_name.should == 'bar'
end
it 'allows symbols as hash keys for attributes' do
- attrs = Nokogiri::XML::Node.new('foo', @doc)
+ attrs = Nokogiri::XML::Node.new('foo', doc)
attrs['foo'] = 'bar'
- attrs['foo'].must_equal 'bar'
- attrs[:foo].must_equal 'bar'
+ attrs['foo'].should == 'bar'
+ attrs[:foo].should == 'bar'
end
it 'ensures a string is passed to the attribute setter' do
- attrs = Nokogiri::XML::Node.new('foo', @doc)
+ attrs = Nokogiri::XML::Node.new('foo', doc)
attrs[:foo] = 1
- attrs[:foo].must_equal '1'
+ attrs[:foo].should == '1'
attrs[:some_attr] = :bah
- attrs[:some_attr].must_equal 'bah'
+ attrs[:some_attr].should == 'bah'
end
it 'joins an array into a string when passed to the attribute setter' do
- attrs = Nokogiri::XML::Node.new('foo', @doc)
+ attrs = Nokogiri::XML::Node.new('foo', doc)
attrs[:foo] = 1
- attrs[:foo].must_equal '1'
+ attrs[:foo].should == '1'
attrs[:some_attr] = [:bah, :boo]
- attrs[:some_attr].must_equal 'bahboo'
+ attrs[:some_attr].should == 'bahboo'
end
it 'removes an attribute when set to nil' do
- attrs = Nokogiri::XML::Node.new('foo', @doc)
+ attrs = Nokogiri::XML::Node.new('foo', doc)
attrs['foo'] = 'bar'
- attrs['foo'].must_equal 'bar'
+ attrs['foo'].should == 'bar'
attrs['foo'] = nil
- attrs['foo'].must_be_nil
+ attrs['foo'].should be_nil
end
it 'allows attribute values to change' do
- attrs = Nokogiri::XML::Node.new('foo', @doc)
+ attrs = Nokogiri::XML::Node.new('foo', doc)
attrs['foo'] = 'bar'
- attrs['foo'].must_equal 'bar'
+ attrs['foo'].should == 'bar'
attrs['foo'] = 'baz'
- attrs['foo'].must_equal 'baz'
+ attrs['foo'].should == 'baz'
end
it 'allows symbols as the path in #xpath' do
- node = Nokogiri::XML::Node.new('foo', @doc)
- node.must_respond_to :find
- @doc.root = node
- @doc.xpath(:foo).first.wont_be_nil
- @doc.xpath(:foo).first.must_equal @doc.xpath('/foo').first
+ node = Nokogiri::XML::Node.new('foo', doc)
+ node.should respond_to :find
+ doc.root = node
+ doc.xpath(:foo).first.should_not be_nil
+ doc.xpath(:foo).first.should == doc.xpath('/foo').first
end
it 'allows symbols as namespace names in #xpath' do
- node = Nokogiri::XML::Node.new('foo', @doc)
+ node = Nokogiri::XML::Node.new('foo', doc)
node.namespace = node.add_namespace('bar', 'baz')
- @doc.root = node
- node.xpath('/bar:foo', :bar => 'baz').first.wont_be_nil
+ doc.root = node
+ node.xpath('/bar:foo', :bar => 'baz').first.should_not be_nil
end
it 'aliases #xpath to #find' do
- node = Nokogiri::XML::Node.new('foo', @doc)
- node.must_respond_to :find
- @doc.root = node
- node.find('/foo').first.wont_be_nil
+ node = Nokogiri::XML::Node.new('foo', doc)
+ node.should respond_to :find
+ doc.root = node
+ node.find('/foo').first.should_not be_nil
end
it 'has a helper function #find_first' do
- node = Nokogiri::XML::Node.new('foo', @doc)
- node.must_respond_to :find
- @doc.root = node
- node.find_first('/foo').must_equal node.find('/foo').first
+ node = Nokogiri::XML::Node.new('foo', doc)
+ node.should respond_to :find
+ doc.root = node
+ node.find_first('/foo').should == node.find('/foo').first
end
end
Oops, something went wrong.

0 comments on commit 4e034f4

Please sign in to comment.