Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Commit

Permalink
Merge 9de3e2c into d3e4cc0
Browse files Browse the repository at this point in the history
  • Loading branch information
nathankleyn committed Sep 26, 2015
2 parents d3e4cc0 + 9de3e2c commit c4b1e5d
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/shanty/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def require!
end

def logger
@@logger ||= Logger.new(STDOUT).tap do |logger|
@@logger ||= Logger.new($stdout).tap do |logger|
logger.formatter = proc do |_, datetime, _, msg|
"#{datetime}: #{msg}\n"
end
Expand Down
4 changes: 1 addition & 3 deletions spec/lib/shanty/plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ module Shanty
let(:graph) { double('graph') }
let(:plugin_class) do
Class.new(described_class) do
def foo
[]
end
def foo; end
end
end
subject { plugin_class.new }
Expand Down
22 changes: 21 additions & 1 deletion spec/lib/shanty/plugins/cucumber_plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# All classes referenced belong to the shanty project
module Shanty
RSpec.describe(CucumberPlugin) do
include_context('basics')
include_context('graph')

it('adds the cucumber tag') do
expect(described_class).to add_tags(:cucumber)
Expand All @@ -18,6 +18,26 @@ module Shanty
expect(described_class).to subscribe_to(:test).with(:cucumber)
end

describe('#cucumber_projects') do
it('returns projects with a dependency on Cucumber in a Gemfile') do
File.write(File.join(project_paths[:one], 'Gemfile'), "gem 'cucumber', '~> 1.2.3'")

expect(subject.cucumber_projects).to match_array([projects[:one]])
end

it('returns projects with a dependency on Cucumber in a *.gemspec') do
File.write(File.join(project_paths[:two], 'foo.gemspec'), "gem.add_dependency 'cucumber', '~> 1.2.3")

expect(subject.cucumber_projects).to match_array([projects[:two]])
end

it('does not return projects with no dependency on Cucumber') do
File.write(File.join(project_paths[:three], 'Gemfile'), "gem 'foo', '~> 1.2.3'")

expect(subject.cucumber_projects).to be_empty
end
end

describe('#cucumber') do
it('calls cucumber') do
expect(subject).to receive(:system).with('cucumber')
Expand Down
23 changes: 22 additions & 1 deletion spec/lib/shanty/plugins/rspec_plugin_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
require 'fileutils'
require 'spec_helper'
require 'shanty/plugins/rspec_plugin'

# All classes referenced belong to the shanty project
module Shanty
RSpec.describe(RspecPlugin) do
include_context('basics')
include_context('graph')

it('adds the rspec tag') do
expect(described_class).to add_tags(:rspec)
Expand All @@ -18,6 +19,26 @@ module Shanty
expect(described_class).to subscribe_to(:test).with(:rspec)
end

describe('#rspec_projects') do
it('returns projects with a dependency on RSpec in a Gemfile') do
File.write(File.join(project_paths[:one], 'Gemfile'), "gem 'rspec', '~> 1.2.3'")

expect(subject.rspec_projects).to match_array([projects[:one]])
end

it('returns projects with a dependency on RSpec in a *.gemspec') do
File.write(File.join(project_paths[:two], 'foo.gemspec'), "gem.add_dependency 'rspec', '~> 1.2.3")

expect(subject.rspec_projects).to match_array([projects[:two]])
end

it('does not return projects with no dependency on RSpec') do
File.write(File.join(project_paths[:three], 'Gemfile'), "gem 'foo', '~> 1.2.3'")

expect(subject.rspec_projects).to be_empty
end
end

describe('#rspec') do
it('calls rspec') do
expect(subject).to receive(:system).with('rspec')
Expand Down
14 changes: 11 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,28 @@ def require_matchers(path)
I18n.enforce_available_locales = false

RSpec.configure do |config|
config.expect_with :rspec do |c|
config.expect_with(:rspec) do |c|
c.include_chain_clauses_in_custom_matcher_descriptions = true
end

config.mock_with(:rspec) do |mocks|
mocks.verify_partial_doubles = true
end

# Supress any writing to stdout or stderr during the tests. We don't want
# any of the logging to be written in between our test output.
config.around(:all) do |example|
$stderr = File.open(File::NULL, 'w')
$stdout = File.open(File::NULL, 'w')
example.run
$stderr = STDERR
$stdout = STDOUT
end

config.before(:example) do
Shanty::Env.clear!
Shanty::TaskEnv.clear!
Shanty::Project.clear!

Shanty::Env.logger.level = Logger::FATAL
end
end

Expand Down

0 comments on commit c4b1e5d

Please sign in to comment.