Skip to content

Commit

Permalink
Spec name is full file path, _spec.js no longer removed
Browse files Browse the repository at this point in the history
  • Loading branch information
jnicklas committed Jul 8, 2010
1 parent 8bea35c commit a1e2501
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/evergreen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ def url(path)
erb :list
end

get '/run/:name' do |name|
get '/run/*' do |name|
@spec = Spec.new(root, name)
erb :spec
end

get '/spec/:name.js' do |name|
get '/spec/*' do |name|
Spec.new(root, name).read
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/evergreen/spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Spec

def self.all(root)
Dir.glob(File.join(root, 'spec/javascripts', '*_spec.js')).map do |path|
new(root, File.basename(path).sub(/_spec\.js$/, ''))
new(root, File.basename(path))
end
end

Expand All @@ -14,12 +14,12 @@ def initialize(root, name)
@name = name
end

def path
File.join(root, 'spec/javascripts', name + '_spec.js')
def full_path
File.join(root, 'spec/javascripts', name)
end

def read
File.read(path)
File.read(full_path)
end
alias_method :contents, :read

Expand Down
2 changes: 1 addition & 1 deletion lib/evergreen/views/spec.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<script type="text/javascript" src="<%= url("/lib/jasmine.js") %>"></script>
<script type="text/javascript" src="<%= url("/lib/jasmine-html.js") %>"></script>
<script type="text/javascript" src="<%= url("/evergreen/evergreen.js") %>"></script>
<script type="text/javascript" src="<%= url("/spec/#{@spec.name}.js") %>"></script>
<script type="text/javascript" src="<%= url("/spec/#{@spec.name}") %>"></script>
</head>
<body>
<script type="text/javascript">
Expand Down
4 changes: 2 additions & 2 deletions spec/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
let(:root) { File.expand_path('fixtures', File.dirname(__FILE__)) }

context "with passing spec" do
let(:spec) { Evergreen::Spec.new(root, 'testing') }
let(:spec) { Evergreen::Spec.new(root, 'testing_spec.js') }
subject { Evergreen::Runner.new(spec) }

it { should be_passed }
Expand All @@ -13,7 +13,7 @@
end

context "with failing spec" do
let(:spec) { Evergreen::Spec.new(root, 'failing') }
let(:spec) { Evergreen::Spec.new(root, 'failing_spec.js') }
subject { Evergreen::Runner.new(spec) }

it { should_not be_passed }
Expand Down
10 changes: 5 additions & 5 deletions spec/spec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

describe Evergreen::Spec do
let(:root) { File.expand_path('fixtures', File.dirname(__FILE__)) }
subject { Evergreen::Spec.new(root, 'testing') }
subject { Evergreen::Spec.new(root, 'testing_spec.js') }

its(:name) { should == 'testing' }
its(:name) { should == 'testing_spec.js' }
its(:root) { should == root }
its(:path) { should == "#{root}/spec/javascripts/testing_spec.js" }
its(:url) { should == "/run/testing" }
its(:full_path) { should == "#{root}/spec/javascripts/testing_spec.js" }
its(:url) { should == "/run/testing_spec.js" }
its(:contents) { should =~ /describe\('testing'/ }

describe '.all' do
subject { Evergreen::Spec.all(root) }

it "should find all specs in the given root directory" do
subject.map(&:name).should include('testing', 'foo', 'bar')
subject.map(&:name).should include('testing_spec.js', 'foo_spec.js', 'bar_spec.js')
end
end
end

0 comments on commit a1e2501

Please sign in to comment.