start of spec work
This commit is contained in:
parent
6270393027
commit
8fac9351ce
@ -1,7 +1,7 @@
|
||||
# A sample Guardfile
|
||||
# More info at https://github.com/guard/guard#readme
|
||||
|
||||
guard 'rspec', :version => 2 do
|
||||
guard 'rspec', :cli => '-c', :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" }
|
||||
|
@ -6,17 +6,29 @@ module Penchant
|
||||
@path = path
|
||||
end
|
||||
|
||||
def gemfile_path
|
||||
file_in_path('Gemfile')
|
||||
end
|
||||
|
||||
def has_gemfile?
|
||||
has_file_in_path?('Gemfile')
|
||||
File.file?('Gemfile')
|
||||
end
|
||||
|
||||
def gemfile_erb_path
|
||||
file_in_path('Gemfile.erb')
|
||||
end
|
||||
|
||||
def has_gemfile_erb?
|
||||
has_file_in_path?('Gemfile.erb')
|
||||
File.file?(gemfile_erb_path)
|
||||
end
|
||||
|
||||
def environment
|
||||
File.readlines(gemfile_path).first.strip[%r{environment: (.*)}, 1]
|
||||
end
|
||||
|
||||
private
|
||||
def has_file_in_path?(file)
|
||||
File.file?(File.join(@path, file))
|
||||
def file_in_path(file)
|
||||
File.join(@path, file)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -24,12 +24,31 @@ describe Penchant::Gemfile do
|
||||
end
|
||||
|
||||
context 'with gemfile' do
|
||||
let(:data) { "whatever" }
|
||||
|
||||
before do
|
||||
write_file(gemfile_path) { "whatever" }
|
||||
write_file(gemfile_path) { data }
|
||||
end
|
||||
|
||||
it { should have_gemfile }
|
||||
it { should_not have_gemfile_erb }
|
||||
describe 'existence' do
|
||||
it { should have_gemfile }
|
||||
it { should_not have_gemfile_erb }
|
||||
end
|
||||
|
||||
describe '#environment' do
|
||||
context 'not defined' do
|
||||
its(:environment) { should be_nil }
|
||||
end
|
||||
|
||||
context 'defined' do
|
||||
let(:environment) { 'test' }
|
||||
let(:data) { <<-GEMFILE }
|
||||
# generated by penchant, environment: #{environment}
|
||||
GEMFILE
|
||||
|
||||
its(:environment) { should == environment }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with gemfile.erb' do
|
||||
|
Loading…
Reference in New Issue
Block a user