clean up some more and add tests
This commit is contained in:
parent
91d4c10ada
commit
88dbf97234
3
Gemfile
3
Gemfile
@ -2,3 +2,6 @@ source "http://rubygems.org"
|
||||
|
||||
# Specify your gem's dependencies in rspec-quickfix-formatter.gemspec
|
||||
gemspec
|
||||
|
||||
gem 'guard'
|
||||
gem 'guard-rspec'
|
||||
|
20
Guardfile
Normal file
20
Guardfile
Normal file
@ -0,0 +1,20 @@
|
||||
# A sample Guardfile
|
||||
# More info at https://github.com/guard/guard#readme
|
||||
|
||||
guard 'rspec', :version => 2 do
|
||||
watch(%r{^spec/.+_spec\.rb$})
|
||||
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
||||
watch('spec/spec_helper.rb') { "spec" }
|
||||
|
||||
# Rails example
|
||||
watch(%r{^spec/.+_spec\.rb$})
|
||||
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
||||
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
||||
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
||||
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
||||
watch('spec/spec_helper.rb') { "spec" }
|
||||
watch('config/routes.rb') { "spec/routing" }
|
||||
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
||||
# Capybara request specs
|
||||
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
|
||||
end
|
@ -1,3 +1,3 @@
|
||||
module RSpec
|
||||
require 'rspec/quickfix-formatter'
|
||||
require 'rspec/quick_fix_formatter'
|
||||
end
|
||||
|
@ -13,7 +13,11 @@ module RSpec
|
||||
|
||||
def dump_failures
|
||||
failed_examples.each do |example|
|
||||
output.puts "%s:%s:%s" % [ example.file_path, example.metadata[:line_number], example.metadata[:execution_result][:exception].message.gsub("\n", ' ') ]
|
||||
output.puts "%s:%s:%s" % [
|
||||
example.file_path,
|
||||
example.metadata[:line_number],
|
||||
example.metadata[:execution_result][:exception].message.gsub("\n", ' ')
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
@ -20,4 +20,5 @@ Gem::Specification.new do |s|
|
||||
s.require_paths = ["lib"]
|
||||
|
||||
s.add_dependency 'rspec'
|
||||
s.add_development_dependency 'mocha'
|
||||
end
|
||||
|
40
spec/lib/rspec/quick_fix_formatter_spec.rb
Normal file
40
spec/lib/rspec/quick_fix_formatter_spec.rb
Normal file
@ -0,0 +1,40 @@
|
||||
require 'spec_helper'
|
||||
require 'rspec/quick_fix_formatter'
|
||||
|
||||
describe RSpec::QuickFixFormatter do
|
||||
let(:output) { mock }
|
||||
|
||||
let(:formatter) do
|
||||
formatter = described_class.new(output)
|
||||
formatter.stubs(:failed_examples).returns(failed_examples)
|
||||
formatter
|
||||
end
|
||||
|
||||
let(:example) do
|
||||
stub(:file_path => path, :metadata => metadata)
|
||||
end
|
||||
|
||||
let(:metadata) do
|
||||
{
|
||||
:line_number => line_number,
|
||||
:execution_result => {
|
||||
:exception => exception
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
let(:exception) { stub(:message => message) }
|
||||
|
||||
let(:path) { 'path' }
|
||||
let(:line_number) { 100 }
|
||||
let(:message) { 'message' }
|
||||
|
||||
let(:failed_examples) { [ example ] }
|
||||
|
||||
it 'should dump the failed example' do
|
||||
output.expects(:puts).with("#{path}:#{line_number}:#{message}")
|
||||
|
||||
formatter.dump_failures
|
||||
end
|
||||
end
|
||||
|
4
spec/spec_helper.rb
Normal file
4
spec/spec_helper.rb
Normal file
@ -0,0 +1,4 @@
|
||||
RSpec.configure do |c|
|
||||
c.mock_with :mocha
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user