chinchilla 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new :spec
5
+
6
+ task :default => :spec
data/chinchilla.gemspec CHANGED
@@ -14,7 +14,9 @@ Gem::Specification.new do |gem|
14
14
 
15
15
  gem.add_dependency 'capybara'
16
16
  gem.add_dependency 'poltergeist'
17
- gem.add_dependency 'rocha'
17
+ gem.add_dependency 'rocha', '~> 0.2.1'
18
+ gem.add_dependency 'rake'
19
+ gem.add_development_dependency "rspec"
18
20
 
19
21
  gem.files = `git ls-files`.split($\)
20
22
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -1,12 +1,8 @@
1
1
  module Chinchilla
2
2
  class Runner
3
- def self.start(options={})
4
- new(options).run
5
- end
6
-
7
3
  attr_reader :reporter
8
4
 
9
- def initialize(options)
5
+ def initialize(options={})
10
6
  @options = options
11
7
  @reporter = Rocha::Reporter.new(*formatters)
12
8
  end
@@ -62,13 +58,23 @@ module Chinchilla
62
58
  end
63
59
 
64
60
  def formatters
65
- @formatters ||= @options[:formatters] || default_formatters
61
+ @formatters ||= load_formatters(@options[:formatters]) || default_formatters
66
62
  end
67
63
 
68
64
  def default_application
69
65
  defined?(Rails) ? Rails.application : nil
70
66
  end
71
67
 
68
+ def load_formatters(formatters)
69
+ if formatters.kind_of?(String)
70
+ formatters.split(',').map do |formatter|
71
+ eval(formatter).new(STDOUT)
72
+ end
73
+ else
74
+ formatters
75
+ end
76
+ end
77
+
72
78
  def default_formatters
73
79
  [Rocha::Formatter.new(STDOUT)]
74
80
  end
@@ -1,3 +1,3 @@
1
1
  module Chinchilla
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -0,0 +1,121 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chinchilla::Runner do
4
+ before do
5
+ STDOUT.stub(:puts)
6
+ end
7
+
8
+ describe ".new" do
9
+ before do
10
+ class TestFormatter
11
+ def initialize(io)
12
+ end
13
+ end
14
+ end
15
+
16
+ after do
17
+ Object.send(:remove_const, :TestFormatter)
18
+ end
19
+
20
+ it "initializes a reporter with formatters given in options" do
21
+ Rocha::Reporter.should_receive(:new).with(instance_of(Rocha::Formatter), instance_of(TestFormatter))
22
+ described_class.new :formatters => 'Rocha::Formatter, TestFormatter'
23
+ end
24
+ end
25
+
26
+ describe "#run" do
27
+ let(:suite) do
28
+ {'event' => 'suite',
29
+ 'type' => 'suite',
30
+ 'data' => {
31
+ 'title' => 'failure',
32
+ 'fullTitle' => 'failure',
33
+ 'path' => 'failing_spec.js'
34
+ }}
35
+ end
36
+
37
+ let(:suite_end) do
38
+ {'event' => 'suite end',
39
+ 'type' => 'suite',
40
+ 'data' => {
41
+ 'title' => 'failure',
42
+ 'fullTitle' => 'failure',
43
+ 'path' => 'failing_spec.js'
44
+ }}
45
+ end
46
+
47
+ let(:test) do
48
+ {'event' => 'test',
49
+ 'type' => 'test',
50
+ 'data' => {
51
+ 'title' => 'fails',
52
+ 'fullTitle' => 'failure fails',
53
+ 'parentFullTitle' => 'failure',
54
+ 'path' => 'failing_spec.js'}}
55
+ end
56
+
57
+ let(:failure) do
58
+ {'event' => 'fail',
59
+ 'type' => 'test',
60
+ 'data' => {
61
+ 'title' => 'fails',
62
+ 'fullTitle' => 'failure fails',
63
+ 'parentFullTitle' => 'failure',
64
+ 'status' => 'failed',
65
+ 'path' => 'failing_spec.js',
66
+ 'error' => {'message' => 'expected 4 to equal 5', 'name' => 'AssertionError'}}}
67
+ end
68
+
69
+ let(:error) do
70
+ {'event' => 'fail',
71
+ 'type' => 'test',
72
+ 'data' => {
73
+ 'title' => 'errors',
74
+ 'fullTitle' => 'failure errors',
75
+ 'parentFullTitle' => 'failure',
76
+ 'status' => 'failed',
77
+ 'path' => 'failing_spec.js',
78
+ 'error' => {'message' => 'this one errors out', 'name' => 'Error'}}}
79
+ end
80
+
81
+ let(:pass) do
82
+ {'event' => 'pass',
83
+ 'type' => 'test',
84
+ 'data' => {
85
+ 'title' => 'is empty',
86
+ 'fullTitle' => 'the body#konacha element is empty',
87
+ 'parentFullTitle' => 'the body#konacha element',
88
+ 'status' => 'passed',
89
+ 'path' => 'body_spec.js.coffee',
90
+ 'duration' => anything}}
91
+ end
92
+
93
+ let(:pending) do
94
+ {'event' => 'pending',
95
+ 'type' => 'test',
96
+ 'data' => {
97
+ 'title' => 'is pending',
98
+ 'fullTitle' => 'pending test is pending',
99
+ 'parentFullTitle' => 'pending test',
100
+ 'path' => 'pending_spec.js',
101
+ 'status' => 'pending'}}
102
+ end
103
+
104
+ let(:start) { {'event' => 'start', 'testCount' => kind_of(Integer), 'data' => {} } }
105
+ let(:end_event) { {'event' => 'end', 'data' => {} } }
106
+
107
+ it "passes along the right events" do
108
+ subject.reporter.should_receive(:process_mocha_event).with(start)
109
+ subject.reporter.should_receive(:process_mocha_event).with(suite)
110
+ subject.reporter.should_receive(:process_mocha_event).with(suite_end)
111
+ subject.reporter.should_receive(:process_mocha_event).with(test)
112
+ subject.reporter.should_receive(:process_mocha_event).with(failure)
113
+ subject.reporter.should_receive(:process_mocha_event).with(error)
114
+ subject.reporter.should_receive(:process_mocha_event).with(pass)
115
+ subject.reporter.should_receive(:process_mocha_event).with(pending)
116
+ subject.reporter.should_receive(:process_mocha_event).with(end_event)
117
+ subject.reporter.should_receive(:process_mocha_event).any_number_of_times
118
+ subject.run
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,3 @@
1
+ require "rspec/autorun"
2
+
3
+ require "chinchilla"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chinchilla
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -45,6 +45,22 @@ dependencies:
45
45
  version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rocha
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.2.1
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.2.1
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
48
64
  requirement: !ruby/object:Gem::Requirement
49
65
  none: false
50
66
  requirements:
@@ -59,6 +75,22 @@ dependencies:
59
75
  - - ! '>='
60
76
  - !ruby/object:Gem::Version
61
77
  version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
62
94
  description: mocha test runner
63
95
  email:
64
96
  - paul@chavard.net
@@ -75,6 +107,8 @@ files:
75
107
  - lib/chinchilla.rb
76
108
  - lib/chinchilla/runner.rb
77
109
  - lib/chinchilla/version.rb
110
+ - spec/runner_spec.rb
111
+ - spec/spec_helper.rb
78
112
  homepage: ''
79
113
  licenses: []
80
114
  post_install_message:
@@ -87,16 +121,24 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
121
  - - ! '>='
88
122
  - !ruby/object:Gem::Version
89
123
  version: '0'
124
+ segments:
125
+ - 0
126
+ hash: 311499010911845055
90
127
  required_rubygems_version: !ruby/object:Gem::Requirement
91
128
  none: false
92
129
  requirements:
93
130
  - - ! '>='
94
131
  - !ruby/object:Gem::Version
95
132
  version: '0'
133
+ segments:
134
+ - 0
135
+ hash: 311499010911845055
96
136
  requirements: []
97
137
  rubyforge_project:
98
138
  rubygems_version: 1.8.23
99
139
  signing_key:
100
140
  specification_version: 3
101
141
  summary: Run mocha test on Capybara
102
- test_files: []
142
+ test_files:
143
+ - spec/runner_spec.rb
144
+ - spec/spec_helper.rb