Skip to content

Commit

Permalink
Fix moar tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Divins and Josep M. Bach authored and Josep M. Bach committed Nov 11, 2011
1 parent ca49818 commit b64623d
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion features/steps/rspec_compatibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class RSpecCompatibility < Spinach::FeatureSteps

When "I run \"spinach\" with rspec" do
@feature =
run_feature "features/#{@feature}.feature", suite: :rspec
run_feature "features/#{@feature}.feature", framework: :rspec
end

Then "I should see the failure count along with their messages" do
Expand Down
6 changes: 3 additions & 3 deletions features/support/spinach_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def self.included(base)
end

def run_feature(command, options={})
options[:suite] ||= :minitest
use_minitest if options[:suite] == :minitest
use_rspec if options[:suite] == :rspec
options[:framework] ||= :minitest
use_minitest if options[:framework] == :minitest
use_rspec if options[:framework] == :rspec
run "../../bin/spinach #{command} #{options[:append]}"
end

Expand Down
2 changes: 2 additions & 0 deletions lib/spinach/frameworks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative 'frameworks/minitest' if defined?(MiniTest)
require_relative 'frameworks/rspec' if defined?(RSpec::Expectations)
File renamed without changes.
File renamed without changes.
6 changes: 2 additions & 4 deletions lib/spinach/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class Parser
# @api public
def initialize(content)
@content = content
@visitor = Visitor.new
end

# @param [String] filename
Expand All @@ -37,9 +36,8 @@ def self.open_file(filename)
#
# @api public
def parse
ast = Gherkin.parse(@content.strip)
feature = Feature.new
Visitor.new(feature).visit(ast)
ast = Gherkin.parse(@content.strip)
Visitor.new.visit(ast)
end
end
end
8 changes: 4 additions & 4 deletions lib/spinach/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def initialize(filenames, options = {})
# @api public
def run
require_dependencies
require_suites
require_frameworks

Spinach.hooks.run_before_run

Expand Down Expand Up @@ -83,10 +83,10 @@ def require_dependencies
end
end

# Requires the test suite support
# Requires the test framework support
#
def require_suites
require_relative 'suites'
def require_frameworks
require_relative 'frameworks'
end

# @return [Array<String>] files
Expand Down
2 changes: 0 additions & 2 deletions lib/spinach/suites.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require_relative '../../test_helper'

describe "minitest suite" do
describe "minitest framework" do
before do
require_relative '../../../lib/spinach/suites/minitest'
require_relative '../../../lib/spinach/frameworks/minitest'
end

it "adds MiniTest::Assertion into the failure exceptions" do
Expand Down
2 changes: 1 addition & 1 deletion test/spinach/parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
describe '#parse' do
it 'parses the file' do
Gherkin.expects(:parse).with(@contents.strip).returns ast = stub
Visitor.expects(:new).with(kind_of(Feature)).returns visitor = stub
Spinach::Parser::Visitor.stubs(:new).returns visitor = stub
visitor.expects(:visit).with ast
@parser.parse
end
Expand Down
2 changes: 1 addition & 1 deletion test/spinach/runner/scenario_runner_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Runner
describe 'when the step fails' do
before do
@failure_exception = Class.new(StandardError)
Spinach.config[:failure_exceptions] = [@failure_exception]
Spinach.stubs(:config).returns({ failure_exceptions: [@failure_exception] })
@step_definitions.stubs(:execute).with('Go shopping').raises @failure_exception
end

Expand Down

0 comments on commit b64623d

Please sign in to comment.