Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Upgrade RSpec, Cucumber, Spinach versions

  • Loading branch information...
commit 62a1306601be2ed68510b8fe6412c3ca67802bf5 1 parent 4ea9226
@nicksieger nicksieger authored
View
2  .hoerc
@@ -0,0 +1,2 @@
+---
+exclude: !ruby/regexp /tmp$|CVS|TAGS|\.(svn|git|DS_Store)|Gemfile.lock/
View
12 Gemfile
@@ -6,17 +6,7 @@
source 'https://rubygems.org'
-gem 'builder'
+gemspec
group :development do
- gem 'hoe'
- gem 'hoe-git', '~> 1.5.0'
- gem 'rubyforge'
- gem 'cucumber'
- gem 'spinach', '< 0.2'
- gem 'rspec', '> 2.0.0'
- gem 'test-unit', '> 2.0.0'
- gem 'minitest'
- gem 'rcov', :platform => :ruby_18
- gem 'rdoc'
gem 'jruby-openssl', :platform => :jruby
end
View
8 Manifest.txt
@@ -1,6 +1,8 @@
+.gemtest
+.hoerc
+.rspec
.travis.yml
Gemfile
-Gemfile.lock
History.txt
LICENSE.txt
Manifest.txt
@@ -10,10 +12,8 @@ acceptance/cucumber/cucumber_example.feature
acceptance/cucumber/step_definitions/development_steps.rb
acceptance/minitest_example_test.rb
acceptance/rspec_example_spec.rb
-acceptance/spinach/Gemfile
-acceptance/spinach/Gemfile.lock
acceptance/spinach/features/spinach_example.feature
-acceptance/spinach/features/steps/example_steps.rb
+acceptance/spinach/features/steps/example_spinach_feature.rb
acceptance/test_unit_example_test.rb
acceptance/verification_spec.rb
ci_reporter.gemspec
View
61 Rakefile
@@ -25,13 +25,13 @@ begin
p.test_globs = ["spec/**/*_spec.rb"]
p.extra_deps << [ 'builder', '>= 2.1.2' ]
p.extra_dev_deps << [ 'hoe-git', '~> 1.5.0' ]
- p.extra_dev_deps << [ 'cucumber', '~> 0.10.0' ]
+ p.extra_dev_deps << [ 'cucumber', '>= 1.3.3' ]
p.extra_dev_deps << [ 'rspec', '> 2.0.0' ]
p.extra_dev_deps << [ 'test-unit', '> 2.4.9' ]
p.extra_dev_deps << [ 'minitest', '~> 2.2.0' ]
- p.extra_dev_deps << [ 'spinach', '< 0.2' ]
-
+ p.extra_dev_deps << [ 'spinach', '>= 0.8.7' ]
p.clean_globs += ["spec/reports", "acceptance/reports"]
+ p.license 'MIT'
end
hoe.spec.rdoc_options += ["-SHN", "-f", "darkfish"]
@@ -43,37 +43,56 @@ rescue LoadError
puts "You really need Hoe installed to be able to package this gem"
end
-task :generate_output do
- rm_rf "acceptance/reports"
- ENV['CI_REPORTS'] = "acceptance/reports"
+def run_ruby_acceptance(cmd)
+ ENV['CI_REPORTS'] ||= "acceptance/reports"
if ENV['RUBYOPT']
opts = ENV['RUBYOPT']
ENV['RUBYOPT'] = nil
else
opts = "-rubygems"
end
- rspec = "#{Gem.loaded_specs['rspec-core'].gem_dir}/exe/rspec"
- cucumber = "#{Gem.loaded_specs['cucumber'].gem_dir}/bin/cucumber"
begin
result_proc = proc {|ok,*| puts "Failures above are expected." unless ok }
- ruby "-Ilib #{opts} -rci/reporter/rake/test_unit_loader acceptance/test_unit_example_test.rb", &result_proc
- ruby "-Ilib #{opts} -rci/reporter/rake/minitest_loader acceptance/minitest_example_test.rb", &result_proc
- ruby "-Ilib #{opts} -S #{rspec} --require ci/reporter/rake/rspec_loader --format CI::Reporter::RSpec acceptance/rspec_example_spec.rb", &result_proc
- ruby "-Ilib #{opts} -rci/reporter/rake/cucumber_loader -S #{cucumber} --format CI::Reporter::Cucumber acceptance/cucumber", &result_proc
- Dir.chdir 'acceptance/spinach' do
- Bundler.with_clean_env do
- ENV['CI_REPORTS'] = "../reports/spinach"
- sh "bundle"
- spinach = "#{Gem.loaded_specs['spinach'].gem_dir}/bin/spinach"
- ruby "-I../../lib #{opts} -rci/reporter/rake/spinach_loader -S #{spinach}", &result_proc
- end
- end
+ ruby "-Ilib #{opts} #{cmd}", &result_proc
ensure
ENV['RUBYOPT'] = opts if opts != "-rubygems"
ENV.delete 'CI_REPORTS'
end
end
-task :acceptance => :generate_output
+
+
+namespace :generate do
+ task :test_unit do
+ run_ruby_acceptance "-rci/reporter/rake/test_unit_loader acceptance/test_unit_example_test.rb"
+ end
+
+ task :minitest do
+ run_ruby_acceptance "-rci/reporter/rake/minitest_loader acceptance/minitest_example_test.rb"
+ end
+
+ task :rspec do
+ rspec = "#{Gem.loaded_specs['rspec-core'].gem_dir}/exe/rspec"
+ run_ruby_acceptance "-S #{rspec} --require ci/reporter/rake/rspec_loader --format CI::Reporter::RSpec acceptance/rspec_example_spec.rb"
+ end
+
+ task :cucumber do
+ cucumber = "#{Gem.loaded_specs['cucumber'].gem_dir}/bin/cucumber"
+ run_ruby_acceptance "-rci/reporter/rake/cucumber_loader -S #{cucumber} --format CI::Reporter::Cucumber acceptance/cucumber"
+ end
+
+ task :spinach do
+ spinach = "#{Gem.loaded_specs['spinach'].gem_dir}/bin/spinach"
+ run_ruby_acceptance "-I../../lib -rci/reporter/rake/spinach_loader -S #{spinach} -r ci_reporter -f acceptance/spinach/features"
+ end
+
+ task :clean do
+ rm_rf "acceptance/reports"
+ end
+
+ task :all => [:clean, :test_unit, :minitest, :rspec, :cucumber, :spinach]
+end
+
+task :acceptance => "generate:all"
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:acceptance_spec) do |t|
View
4 acceptance/cucumber/cucumber_example.feature
@@ -1,4 +1,4 @@
-Feature: Example feature
+Feature: Example Cucumber feature
As a conscientious developer who writes features
I want to be able to see my features passing on the CI Server
So that I can bask in the glow of a green bar
@@ -16,4 +16,4 @@ Feature: Example feature
Scenario: Bad coder
Given that I can't code for peanuts
And I write step definitions that throw exceptions
- Then I shouldn't be allowed out in public
+ Then I shouldn't be allowed out in public
View
4 acceptance/spinach/Gemfile
@@ -1,4 +0,0 @@
-source 'https://rubygems.org'
-gem 'ci_reporter', :path => '../..'
-gem 'spinach', '< 0.2'
-gem 'rspec'
View
35 acceptance/spinach/Gemfile.lock
@@ -1,35 +0,0 @@
-PATH
- remote: ../..
- specs:
- ci_reporter (1.8.4)
- builder (>= 2.1.2)
-
-GEM
- remote: https://rubygems.org/
- specs:
- builder (3.2.2)
- colorize (0.5.8)
- diff-lcs (1.1.3)
- gherkin (2.5.4)
- json (>= 1.4.6)
- json (1.8.0)
- rspec (2.8.0)
- rspec-core (~> 2.8.0)
- rspec-expectations (~> 2.8.0)
- rspec-mocks (~> 2.8.0)
- rspec-core (2.8.0)
- rspec-expectations (2.8.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.8.0)
- spinach (0.1.5.4)
- colorize
- gherkin (= 2.5.4)
-
-PLATFORMS
- java
- ruby
-
-DEPENDENCIES
- ci_reporter!
- rspec
- spinach (< 0.2)
View
2  acceptance/spinach/features/spinach_example.feature
@@ -1,4 +1,4 @@
-Feature: Example feature
+Feature: Example Spinach feature
As a conscientious developer who writes features
I want to be able to see my features passing on the CI Server
So that I can bask in the glow of a green bar
View
34 acceptance/spinach/features/steps/example_spinach_feature.rb
@@ -0,0 +1,34 @@
+require 'rspec'
+
+class Spinach::Features::ExampleSpinachFeature < Spinach::FeatureSteps
+ include RSpec::Matchers
+
+ step 'that I am a conscientious developer' do
+ end
+
+ step 'I write cucumber features' do
+ end
+
+ step 'I should see a green bar' do
+ end
+
+ step 'that I am a lazy hacker' do
+ end
+
+ step 'I don\'t bother writing cucumber features' do
+ false.should be_true
+ end
+
+ step 'I should be fired' do
+ end
+
+ step 'that I can\'t code for peanuts' do
+ end
+
+ step 'I write step definitions that throw exceptions' do
+ raise RuntimeError, "User error!"
+ end
+
+ step 'I shouldn\'t be allowed out in public' do
+ end
+end
View
36 acceptance/spinach/features/steps/example_steps.rb
@@ -1,36 +0,0 @@
-require 'rspec'
-
-class ExampleFeature < Spinach::FeatureSteps
- include RSpec::Matchers
-
- feature 'Example feature'
-
- Given 'that I am a conscientious developer' do
- end
-
- And 'I write cucumber features' do
- end
-
- Then 'I should see a green bar' do
- end
-
- Given 'that I am a lazy hacker' do
- end
-
- And 'I don\'t bother writing cucumber features' do
- false.should be_true
- end
-
- Then 'I should be fired' do
- end
-
- Given 'that I can\'t code for peanuts' do
- end
-
- And 'I write step definitions that throw exceptions' do
- raise RuntimeError, "User error!"
- end
-
- Then 'I shouldn\'t be allowed out in public' do
- end
-end
View
20 acceptance/verification_spec.rb
@@ -1,5 +1,5 @@
#--
-# Copyright (c) 2006-2012 Nick Sieger <nicksieger@gmail.com>
+# Copyright (c) 2006-2013 Nick Sieger <nicksieger@gmail.com>
# See the file LICENSE.txt included with the distribution for
# software license details.
#++
@@ -109,15 +109,15 @@
end
describe "Cucumber acceptance" do
- it "should generate three XML files" do
- File.exist?(File.join(REPORTS_DIR, 'FEATURES-Example-feature.xml')).should == true
+ it "should generate one XML file" do
+ File.exist?(File.join(REPORTS_DIR, 'FEATURES-Example-Cucumber-feature.xml')).should == true
- Dir["#{REPORTS_DIR}/FEATURES-*.xml"].length.should == 1
+ Dir["#{REPORTS_DIR}/FEATURES-*Cucumber*.xml"].length.should == 1
end
context "FEATURES report file" do
before :each do
- @doc = File.open(File.join(REPORTS_DIR, 'FEATURES-Example-feature.xml')) do |f|
+ @doc = File.open(File.join(REPORTS_DIR, 'FEATURES-Example-Cucumber-feature.xml')) do |f|
REXML::Document.new(f)
end
end
@@ -143,18 +143,16 @@
end
end
-SPINACH_REPORTS_DIR = File.expand_path('spinach', REPORTS_DIR)
-
describe "Spinach acceptance" do
- it "should generate three XML files" do
- File.exist?(File.join(SPINACH_REPORTS_DIR, 'FEATURES-Example-feature.xml')).should == true
+ it "should generate one XML file" do
+ File.exist?(File.join(REPORTS_DIR, 'FEATURES-Example-Spinach-feature.xml')).should == true
- Dir["#{SPINACH_REPORTS_DIR}/FEATURES-*.xml"].length.should == 1
+ Dir["#{REPORTS_DIR}/FEATURES-*Spinach*.xml"].length.should == 1
end
context "SPINACH report file" do
before :each do
- @doc = File.open(File.join(SPINACH_REPORTS_DIR, 'FEATURES-Example-feature.xml')) do |f|
+ @doc = File.open(File.join(REPORTS_DIR, 'FEATURES-Example-Spinach-feature.xml')) do |f|
REXML::Document.new(f)
end
end
View
26 ci_reporter.gemspec
@@ -6,13 +6,13 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Nick Sieger"]
- s.date = "2013-07-02"
+ s.date = "2013-12-26"
s.description = "CI::Reporter is an add-on to Test::Unit, RSpec and Cucumber that allows you to generate XML reports of your test, spec and/or feature runs. The resulting files can be read by a continuous integration system that understands Ant's JUnit report XML format, thus allowing your CI system to track test/spec successes and failures."
s.email = "nick@nicksieger.com"
- s.license = 'MIT'
- s.extra_rdoc_files = ["History.txt", "LICENSE.txt", "Manifest.txt", "README.rdoc"]
- s.files = [".travis.yml", "Gemfile", "Gemfile.lock", "History.txt", "LICENSE.txt", "Manifest.txt", "README.rdoc", "Rakefile", "acceptance/cucumber/cucumber_example.feature", "acceptance/cucumber/step_definitions/development_steps.rb", "acceptance/minitest_example_test.rb", "acceptance/rspec_example_spec.rb", "acceptance/spinach/Gemfile", "acceptance/spinach/Gemfile.lock", "acceptance/spinach/features/spinach_example.feature", "acceptance/spinach/features/steps/example_steps.rb", "acceptance/test_unit_example_test.rb", "acceptance/verification_spec.rb", "ci_reporter.gemspec", "lib/ci/reporter/core.rb", "lib/ci/reporter/cucumber.rb", "lib/ci/reporter/minitest.rb", "lib/ci/reporter/rake/cucumber.rb", "lib/ci/reporter/rake/cucumber_loader.rb", "lib/ci/reporter/rake/minitest.rb", "lib/ci/reporter/rake/minitest_loader.rb", "lib/ci/reporter/rake/rspec.rb", "lib/ci/reporter/rake/rspec_loader.rb", "lib/ci/reporter/rake/spinach.rb", "lib/ci/reporter/rake/spinach_loader.rb", "lib/ci/reporter/rake/test_unit.rb", "lib/ci/reporter/rake/test_unit_loader.rb", "lib/ci/reporter/rake/utils.rb", "lib/ci/reporter/report_manager.rb", "lib/ci/reporter/rspec.rb", "lib/ci/reporter/spinach.rb", "lib/ci/reporter/test_suite.rb", "lib/ci/reporter/test_unit.rb", "lib/ci/reporter/version.rb", "spec/ci/reporter/cucumber_spec.rb", "spec/ci/reporter/output_capture_spec.rb", "spec/ci/reporter/rake/rake_tasks_spec.rb", "spec/ci/reporter/report_manager_spec.rb", "spec/ci/reporter/rspec_spec.rb", "spec/ci/reporter/test_suite_spec.rb", "spec/ci/reporter/test_unit_spec.rb", "spec/spec_helper.rb", "stub.rake", "tasks/ci_reporter.rake", ".gemtest"]
+ s.extra_rdoc_files = ["History.txt", "LICENSE.txt", "Manifest.txt", "README.rdoc", "README.rdoc"]
+ s.files = [".gemtest", ".hoerc", ".rspec", ".travis.yml", "Gemfile", "History.txt", "LICENSE.txt", "Manifest.txt", "README.rdoc", "Rakefile", "acceptance/cucumber/cucumber_example.feature", "acceptance/cucumber/step_definitions/development_steps.rb", "acceptance/minitest_example_test.rb", "acceptance/rspec_example_spec.rb", "acceptance/spinach/Gemfile", "acceptance/spinach/features/spinach_example.feature", "acceptance/spinach/features/steps/example_steps.rb", "acceptance/test_unit_example_test.rb", "acceptance/verification_spec.rb", "ci_reporter.gemspec", "lib/ci/reporter/core.rb", "lib/ci/reporter/cucumber.rb", "lib/ci/reporter/minitest.rb", "lib/ci/reporter/rake/cucumber.rb", "lib/ci/reporter/rake/cucumber_loader.rb", "lib/ci/reporter/rake/minitest.rb", "lib/ci/reporter/rake/minitest_loader.rb", "lib/ci/reporter/rake/rspec.rb", "lib/ci/reporter/rake/rspec_loader.rb", "lib/ci/reporter/rake/spinach.rb", "lib/ci/reporter/rake/spinach_loader.rb", "lib/ci/reporter/rake/test_unit.rb", "lib/ci/reporter/rake/test_unit_loader.rb", "lib/ci/reporter/rake/utils.rb", "lib/ci/reporter/report_manager.rb", "lib/ci/reporter/rspec.rb", "lib/ci/reporter/spinach.rb", "lib/ci/reporter/test_suite.rb", "lib/ci/reporter/test_unit.rb", "lib/ci/reporter/version.rb", "spec/ci/reporter/cucumber_spec.rb", "spec/ci/reporter/output_capture_spec.rb", "spec/ci/reporter/rake/rake_tasks_spec.rb", "spec/ci/reporter/report_manager_spec.rb", "spec/ci/reporter/rspec_spec.rb", "spec/ci/reporter/test_suite_spec.rb", "spec/ci/reporter/test_unit_spec.rb", "spec/spec_helper.rb", "stub.rake", "tasks/ci_reporter.rake"]
s.homepage = "http://caldersphere.rubyforge.org/ci_reporter"
+ s.licenses = ["MIT"]
s.rdoc_options = ["--main", "README.rdoc", "-SHN", "-f", "darkfish"]
s.require_paths = ["lib"]
s.rubyforge_project = "caldersphere"
@@ -28,34 +28,34 @@ Gem::Specification.new do |s|
s.add_development_dependency(%q<rubyforge>, [">= 2.0.4"])
s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
s.add_development_dependency(%q<hoe-git>, ["~> 1.5.0"])
- s.add_development_dependency(%q<cucumber>, ["~> 0.10.0"])
+ s.add_development_dependency(%q<cucumber>, [">= 1.3.3"])
s.add_development_dependency(%q<rspec>, ["> 2.0.0"])
s.add_development_dependency(%q<test-unit>, ["> 2.4.9"])
s.add_development_dependency(%q<minitest>, ["~> 2.2.0"])
- s.add_development_dependency(%q<spinach>, ["< 0.2"])
- s.add_development_dependency(%q<hoe>, ["~> 3.6"])
+ s.add_development_dependency(%q<spinach>, [">= 0.8.7"])
+ s.add_development_dependency(%q<hoe>, ["~> 3.7"])
else
s.add_dependency(%q<builder>, [">= 2.1.2"])
s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
s.add_dependency(%q<rdoc>, ["~> 4.0"])
s.add_dependency(%q<hoe-git>, ["~> 1.5.0"])
- s.add_dependency(%q<cucumber>, ["~> 0.10.0"])
+ s.add_dependency(%q<cucumber>, [">= 1.3.3"])
s.add_dependency(%q<rspec>, ["> 2.0.0"])
s.add_dependency(%q<test-unit>, ["> 2.4.9"])
s.add_dependency(%q<minitest>, ["~> 2.2.0"])
- s.add_dependency(%q<spinach>, ["< 0.2"])
- s.add_dependency(%q<hoe>, ["~> 3.6"])
+ s.add_dependency(%q<spinach>, [">= 0.8.7"])
+ s.add_dependency(%q<hoe>, ["~> 3.7"])
end
else
s.add_dependency(%q<builder>, [">= 2.1.2"])
s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
s.add_dependency(%q<rdoc>, ["~> 4.0"])
s.add_dependency(%q<hoe-git>, ["~> 1.5.0"])
- s.add_dependency(%q<cucumber>, ["~> 0.10.0"])
+ s.add_dependency(%q<cucumber>, [">= 1.3.3"])
s.add_dependency(%q<rspec>, ["> 2.0.0"])
s.add_dependency(%q<test-unit>, ["> 2.4.9"])
s.add_dependency(%q<minitest>, ["~> 2.2.0"])
- s.add_dependency(%q<spinach>, ["< 0.2"])
- s.add_dependency(%q<hoe>, ["~> 3.6"])
+ s.add_dependency(%q<spinach>, [">= 0.8.7"])
+ s.add_dependency(%q<hoe>, ["~> 3.7"])
end
end
View
2  lib/ci/reporter/rake/spinach_loader.rb
@@ -2,4 +2,4 @@
require 'ci/reporter/spinach'
ENV['CI_CAPTURE'] = 'off'
-CI::Reporter::Spinach.new.bind
+
View
7 lib/ci/reporter/spinach.rb
@@ -4,7 +4,8 @@
module CI
module Reporter
class Spinach < ::Spinach::Reporter
- def initialize
+ def initialize(options = nil)
+ @options = options
@report_manager = ReportManager.new('features')
end
@@ -73,3 +74,7 @@ def location
end
end
end
+
+class Spinach::Reporter
+ CiReporter = ::CI::Reporter::Spinach
+end
View
68 spec/ci/reporter/cucumber_spec.rb
@@ -1,4 +1,4 @@
-# Copyright (c) 2006-2012 Nick Sieger <nicksieger@gmail.com>
+# Copyright (c) 2006-2013 Nick Sieger <nicksieger@gmail.com>
# See the file LICENSE.txt included with the distribution for
# software license details.
@@ -8,16 +8,16 @@
describe "The Cucumber reporter" do
describe CI::Reporter::CucumberFailure do
before(:each) do
- @klass = mock("class")
- @klass.stub!(:name).and_return("Exception name")
+ @klass = double("class")
+ @klass.stub(:name).and_return("Exception name")
- @exception = mock("exception")
- @exception.stub!(:class).and_return(@klass)
- @exception.stub!(:message).and_return("Exception message")
- @exception.stub!(:backtrace).and_return(["First line", "Second line"])
+ @exception = double("exception")
+ @exception.stub(:class).and_return(@klass)
+ @exception.stub(:message).and_return("Exception message")
+ @exception.stub(:backtrace).and_return(["First line", "Second line"])
- @step = mock("step")
- @step.stub!(:exception).and_return(@exception)
+ @step = double("step")
+ @step.stub(:exception).and_return(@exception)
@cucumber_failure = CI::Reporter::CucumberFailure.new(@step)
end
@@ -55,11 +55,11 @@
describe CI::Reporter::Cucumber do
before(:each) do
- @step_mother = mock("step_mother")
- @io = mock("io")
+ @step_mother = double("step_mother")
+ @io = double("io")
- @report_manager = mock("report_manager")
- CI::Reporter::ReportManager.stub!(:new).and_return(@report_manager)
+ @report_manager = double("report_manager")
+ CI::Reporter::ReportManager.stub(:new).and_return(@report_manager)
end
def new_instance
@@ -88,12 +88,12 @@ def new_instance
@cucumber = new_instance
@cucumber.feature_name(nil, "Demo feature")
- @test_suite = mock("test_suite", :start => nil, :finish => nil, :name= => nil)
- CI::Reporter::TestSuite.stub!(:new).and_return(@test_suite)
+ @test_suite = double("test_suite", :start => nil, :finish => nil, :name= => nil)
+ CI::Reporter::TestSuite.stub(:new).and_return(@test_suite)
- @feature = mock("feature")
+ @feature = double("feature")
- @report_manager.stub!(:write_report)
+ @report_manager.stub(:write_report)
end
context "before" do
@@ -113,12 +113,12 @@ def new_instance
@cucumber = new_instance
@cucumber.feature_name(nil, "Demo feature")
- @test_suite = mock("test_suite", :start => nil, :finish => nil, :name= => nil)
- CI::Reporter::TestSuite.stub!(:new).and_return(@test_suite)
+ @test_suite = double("test_suite", :start => nil, :finish => nil, :name= => nil)
+ CI::Reporter::TestSuite.stub(:new).and_return(@test_suite)
- @feature = mock("feature")
+ @feature = double("feature")
- @report_manager.stub!(:write_report)
+ @report_manager.stub(:write_report)
@cucumber.before_feature(@feature)
end
@@ -139,16 +139,16 @@ def new_instance
before(:each) do
@testcases = []
- @test_suite = mock("test_suite", :testcases => @testcases)
+ @test_suite = double("test_suite", :testcases => @testcases)
@cucumber = new_instance
- @cucumber.stub!(:test_suite).and_return(@test_suite)
+ @cucumber.stub(:test_suite).and_return(@test_suite)
- @test_case = mock("test_case", :start => nil, :finish => nil, :name => "Step Name")
- CI::Reporter::TestCase.stub!(:new).and_return(@test_case)
+ @test_case = double("test_case", :start => nil, :finish => nil, :name => "Step Name")
+ CI::Reporter::TestCase.stub(:new).and_return(@test_case)
- @step = mock("step", :status => :passed)
- @step.stub!(:name).and_return("Step Name")
+ @step = double("step", :status => :passed)
+ @step.stub(:name).and_return("Step Name")
end
context "before steps" do
@@ -182,19 +182,19 @@ def new_instance
end
it "should alter the name of a test case that is pending to include '(PENDING)'" do
- @step.stub!(:status).and_return(:pending)
+ @step.stub(:status).and_return(:pending)
@test_case.should_receive(:name=).with("Step Name (PENDING)")
@cucumber.after_steps(@step)
end
it "should alter the name of a test case that is undefined to include '(PENDING)'" do
- @step.stub!(:status).and_return(:undefined)
+ @step.stub(:status).and_return(:undefined)
@test_case.should_receive(:name=).with("Step Name (PENDING)")
@cucumber.after_steps(@step)
end
it "should alter the name of a test case that was skipped to include '(SKIPPED)'" do
- @step.stub!(:status).and_return(:skipped)
+ @step.stub(:status).and_return(:skipped)
@test_case.should_receive(:name=).with("Step Name (SKIPPED)")
@cucumber.after_steps(@step)
end
@@ -202,15 +202,15 @@ def new_instance
describe "that fails" do
before(:each) do
- @step.stub!(:status).and_return(:failed)
+ @step.stub(:status).and_return(:failed)
@failures = []
- @test_case.stub!(:failures).and_return(@failures)
+ @test_case.stub(:failures).and_return(@failures)
@cucumber.before_steps(@step)
- @cucumber_failure = mock("cucumber_failure")
- CI::Reporter::CucumberFailure.stub!(:new).and_return(@cucumber_failure)
+ @cucumber_failure = double("cucumber_failure")
+ CI::Reporter::CucumberFailure.stub(:new).and_return(@cucumber_failure)
end
it "should create a new cucumber failure with that step" do
View
15 spec/ci/reporter/report_manager_spec.rb
@@ -1,4 +1,4 @@
-# Copyright (c) 2006-2012 Nick Sieger <nicksieger@gmail.com>
+# Copyright (c) 2006-2013 Nick Sieger <nicksieger@gmail.com>
# See the file LICENSE.txt included with the distribution for
# software license details.
@@ -7,6 +7,7 @@
describe "The ReportManager" do
before(:each) do
@reports_dir = REPORTS_DIR
+ ENV.delete 'MAX_FILENAME_SIZE'
end
after(:each) do
@@ -28,7 +29,7 @@
it "should write reports based on name and xml content of a test suite" do
reporter = CI::Reporter::ReportManager.new("spec")
- suite = mock("test suite")
+ suite = double("test suite")
suite.should_receive(:name).and_return("some test suite name")
suite.should_receive(:to_xml).and_return("<xml></xml>")
reporter.write_report(suite)
@@ -39,27 +40,27 @@
it "should shorten extremely long report filenames" do
reporter = CI::Reporter::ReportManager.new("spec")
- suite = mock("test suite")
+ suite = double("test suite")
very_long_name = "some test suite name that goes on and on and on and on and on and on and does not look like it will end any time soon and just when you think it is almost over it just continues to go on and on and on and on and on until it is almost over but wait there is more and then el fin"
suite.should_receive(:name).and_return(very_long_name)
suite.should_receive(:to_xml).and_return("<xml></xml>")
reporter.write_report(suite)
filename = "#{REPORTS_DIR}/SPEC-#{very_long_name}"[0..CI::Reporter::ReportManager::MAX_FILENAME_SIZE].gsub(/\s/, '-') + ".xml"
- filename.length.should be_<= 255
+ filename.length.should be <= 255
File.exist?(filename).should be_true
File.open(filename) {|f| f.read.should == "<xml></xml>"}
end
it "should shorten extremely long report filenames to custom length" do
reporter = CI::Reporter::ReportManager.new("spec")
- suite = mock("test suite")
+ suite = double("test suite")
very_long_name = "some test suite name that goes on and on and on and on and on and on and does not look like it will end any time soon and just when you think it is almost over it just continues to go on and on and on and on and on until it is almost over but wait there is more and then el fin"
suite.should_receive(:name).and_return(very_long_name)
suite.should_receive(:to_xml).and_return("<xml></xml>")
ENV['MAX_FILENAME_SIZE'] = '170'
reporter.write_report(suite)
filename = "#{REPORTS_DIR}/SPEC-#{very_long_name}"[0..170].gsub(/\s/, '-') + ".xml"
- filename.length.should be_<= 188
+ filename.length.should be <= 188
File.exist?(filename).should be_true
File.open(filename) {|f| f.read.should == "<xml></xml>"}
end
@@ -69,7 +70,7 @@
FileUtils.mkdir_p(File.dirname(filename))
FileUtils.touch filename
reporter = CI::Reporter::ReportManager.new("spec")
- suite = mock("test suite")
+ suite = double("test suite")
suite.should_receive(:name).and_return("colliding test suite name")
suite.should_receive(:to_xml).and_return("<xml></xml>")
reporter.write_report(suite)
View
40 spec/ci/reporter/rspec_spec.rb
@@ -1,4 +1,4 @@
-# Copyright (c) 2006-2012 Nick Sieger <nicksieger@gmail.com>
+# Copyright (c) 2006-2013 Nick Sieger <nicksieger@gmail.com>
# See the file LICENSE.txt included with the distribution for
# software license details.
@@ -7,17 +7,17 @@
describe "The RSpec reporter" do
before(:each) do
- @error = mock("error")
- @error.stub!(:expectation_not_met?).and_return(false)
- @error.stub!(:pending_fixed?).and_return(false)
- @error.stub!(:exception).and_return(StandardError.new)
- @report_mgr = mock("report manager")
- @options = mock("options")
+ @error = double("error")
+ @error.stub(:expectation_not_met?).and_return(false)
+ @error.stub(:pending_fixed?).and_return(false)
+ @error.stub(:exception).and_return(StandardError.new)
+ @report_mgr = double("report manager")
+ @options = double("options")
@args = [@options, StringIO.new("")]
@args.shift unless defined?(::Spec) && ::Spec::VERSION::MAJOR == 1 && ::Spec::VERSION::MINOR >= 1
@fmt = CI::Reporter::RSpec.new *@args
@fmt.report_manager = @report_mgr
- @formatter = mock("formatter")
+ @formatter = double("formatter")
@fmt.formatter = @formatter
end
@@ -40,8 +40,8 @@
suite.testcases[2].name.should =~ /\(PENDING\)/
end
- example_group = mock "example group"
- example_group.stub!(:description).and_return "A context"
+ example_group = double "example group"
+ example_group.stub(:description).and_return "A context"
@formatter.should_receive(:start).with(3)
@formatter.should_receive(:example_group_started).with(example_group)
@@ -65,7 +65,7 @@
@fmt.example_started("should be pending")
@fmt.example_pending("A context", "should be pending", "Not Yet Implemented")
@fmt.start_dump
- @fmt.dump_failure(1, mock("failure"))
+ @fmt.dump_failure(1, double("failure"))
@fmt.dump_summary(0.1, 3, 1, 1)
@fmt.dump_pending
@fmt.close
@@ -88,10 +88,10 @@
end
it "should use the example #description method when available" do
- group = mock "example group"
- group.stub!(:description).and_return "group description"
- example = mock "example"
- example.stub!(:description).and_return "should do something"
+ group = double "example group"
+ group.stub(:description).and_return "group description"
+ example = double "example"
+ example.stub(:description).and_return "should do something"
@formatter.should_receive(:start)
@formatter.should_receive(:example_group_started).with(group)
@@ -111,8 +111,8 @@
end
it "should create a test suite with failure in before(:all)" do
- example_group = mock "example group"
- example_group.stub!(:description).and_return "A context"
+ example_group = double "example group"
+ example_group.stub(:description).and_return "A context"
@formatter.should_receive(:start)
@formatter.should_receive(:example_group_started).with(example_group)
@@ -130,12 +130,12 @@
describe 'RSpec2Failure' do
before(:each) do
- @formatter = mock "formatter"
+ @formatter = double "formatter"
@formatter.should_receive(:format_backtrace).and_return("backtrace")
- @rspec20_example = mock('RSpec2.0 Example',
+ @rspec20_example = double('RSpec2.0 Example',
:execution_result => {:exception_encountered => StandardError.new('rspec2.0 ftw')},
:metadata => {})
- @rspec22_example = mock('RSpec2.2 Example',
+ @rspec22_example = double('RSpec2.2 Example',
:execution_result => {:exception => StandardError.new('rspec2.2 ftw')},
:metadata => {})
end
View
68 spec/ci/reporter/test_suite_spec.rb
@@ -1,4 +1,4 @@
-# Copyright (c) 2006-2012 Nick Sieger <nicksieger@gmail.com>
+# Copyright (c) 2006-2013 Nick Sieger <nicksieger@gmail.com>
# See the file LICENSE.txt included with the distribution for
# software license details.
@@ -15,7 +15,7 @@
@suite.finish
@suite.time.should >= 0
end
-
+
it "should aggregate tests" do
@suite.start
@suite.testcases << CI::Reporter::TestCase.new("example test")
@@ -28,15 +28,15 @@
def name.to_s; "object name"; end
CI::Reporter::TestSuite.new(name).name.should == "object name"
end
-
+
it "should indicate number of failures and errors" do
- failure = mock("failure")
- failure.stub!(:failure?).and_return true
- failure.stub!(:error?).and_return false
+ failure = double("failure")
+ failure.stub(:failure?).and_return true
+ failure.stub(:error?).and_return false
- error = mock("error")
- error.stub!(:failure?).and_return false
- error.stub!(:error?).and_return true
+ error = double("error")
+ error.stub(:failure?).and_return false
+ error.stub(:error?).and_return true
@suite.start
@suite.testcases << CI::Reporter::TestCase.new("example test")
@@ -72,19 +72,19 @@ def name.to_s; "object name"; end
end
it "should contain Ant/JUnit-formatted description of entire suite" do
- failure = mock("failure")
- failure.stub!(:failure?).and_return true
- failure.stub!(:error?).and_return false
- failure.stub!(:name).and_return "failure"
- failure.stub!(:message).and_return "There was a failure"
- failure.stub!(:location).and_return @exception.backtrace.join("\n")
-
- error = mock("error")
- error.stub!(:failure?).and_return false
- error.stub!(:error?).and_return true
- error.stub!(:name).and_return "error"
- error.stub!(:message).and_return "There was a error"
- error.stub!(:location).and_return @exception.backtrace.join("\n")
+ failure = double("failure")
+ failure.stub(:failure?).and_return true
+ failure.stub(:error?).and_return false
+ failure.stub(:name).and_return "failure"
+ failure.stub(:message).and_return "There was a failure"
+ failure.stub(:location).and_return @exception.backtrace.join("\n")
+
+ error = double("error")
+ error.stub(:failure?).and_return false
+ error.stub(:error?).and_return true
+ error.stub(:name).and_return "error"
+ error.stub(:message).and_return "There was a error"
+ error.stub(:location).and_return @exception.backtrace.join("\n")
@suite.start
@suite.testcases << CI::Reporter::TestCase.new("example test")
@@ -108,12 +108,12 @@ def name.to_s; "object name"; end
end
it "should contain full exception type and message in location element" do
- failure = mock("failure")
- failure.stub!(:failure?).and_return true
- failure.stub!(:error?).and_return false
- failure.stub!(:name).and_return "failure"
- failure.stub!(:message).and_return "There was a failure"
- failure.stub!(:location).and_return @exception.backtrace.join("\n")
+ failure = double("failure")
+ failure.stub(:failure?).and_return true
+ failure.stub(:error?).and_return false
+ failure.stub(:name).and_return "failure"
+ failure.stub(:message).and_return "There was a failure"
+ failure.stub(:location).and_return @exception.backtrace.join("\n")
@suite.start
@suite.testcases << CI::Reporter::TestCase.new("example test")
@@ -130,12 +130,12 @@ def name.to_s; "object name"; end
end
it "should filter attributes properly for invalid characters" do
- failure = mock("failure")
- failure.stub!(:failure?).and_return true
- failure.stub!(:error?).and_return false
- failure.stub!(:name).and_return "failure"
- failure.stub!(:message).and_return "There was a <failure>\nReason: blah"
- failure.stub!(:location).and_return @exception.backtrace.join("\n")
+ failure = double("failure")
+ failure.stub(:failure?).and_return true
+ failure.stub(:error?).and_return false
+ failure.stub(:name).and_return "failure"
+ failure.stub(:message).and_return "There was a <failure>\nReason: blah"
+ failure.stub(:location).and_return @exception.backtrace.join("\n")
@suite.start
@suite.testcases << CI::Reporter::TestCase.new("failure test")
View
16 spec/ci/reporter/test_unit_spec.rb
@@ -1,4 +1,4 @@
-# Copyright (c) 2006-2012 Nick Sieger <nicksieger@gmail.com>
+# Copyright (c) 2006-2013 Nick Sieger <nicksieger@gmail.com>
# See the file LICENSE.txt included with the distribution for
# software license details.
@@ -6,10 +6,10 @@
describe "The TestUnit reporter" do
before(:each) do
- @report_mgr = mock("report manager")
+ @report_mgr = double("report manager")
@testunit = CI::Reporter::TestUnit.new(nil, @report_mgr)
- @result = mock("result")
- @result.stub!(:assertion_count).and_return(7)
+ @result = double("result")
+ @result.stub(:assertion_count).and_return(7)
end
it "should build suites based on adjacent tests with the same class name" do
@@ -32,7 +32,7 @@
@suite.testcases.last.should_not be_failure
@suite.testcases.last.should_not be_error
end
-
+
it "should build two suites when encountering different class names" do
@suites = []
@report_mgr.should_receive(:write_report).twice.and_return {|suite| @suites << suite }
@@ -54,7 +54,7 @@
@suites.last.testcases.first.name.should == "test_two"
@suites.last.testcases.first.assertions.should == 0
end
-
+
it "should record assertion counts during test run" do
@suite = nil
@report_mgr.should_receive(:write_report).and_return {|suite| @suite = suite }
@@ -67,7 +67,7 @@
@suite.assertions.should == 7
@suite.testcases.last.assertions.should == 7
end
-
+
it "should add failures to testcases when encountering a fault" do
@failure = Test::Unit::Failure.new("test_one(TestCaseClass)", "somewhere:10", "it failed")
@@ -113,7 +113,7 @@
@suite.testcases.last.should_not be_failure
@suite.testcases.last.should be_error
end
-
+
it "should add multiple failures to a testcase" do
@failure1 = Test::Unit::Failure.new("test_one(TestCaseClass)", "somewhere:10", "it failed")
@failure2 = Test::Unit::Failure.new("test_one(TestCaseClass)", "somewhere:12", "it failed again in teardown")
Please sign in to comment.
Something went wrong with that request. Please try again.