Skip to content

Commit

Permalink
Added transparent coffeescript support
Browse files Browse the repository at this point in the history
  • Loading branch information
jnicklas committed Jul 9, 2010
1 parent 2adbb13 commit 44c5f73
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
8 changes: 6 additions & 2 deletions lib/evergreen/spec.rb
Expand Up @@ -2,7 +2,7 @@ module Evergreen
class Spec

def self.all(root)
Dir.glob(File.join(root, 'spec/javascripts', '*_spec.js')).map do |path|
Dir.glob(File.join(root, 'spec/javascripts', '*_spec.{js,coffee}')).map do |path|
new(root, File.basename(path))
end
end
Expand All @@ -27,7 +27,11 @@ def template
end

def read
File.read(full_path)
if full_path =~ /\.coffee$/
%x(coffee -p #{full_path})
else
File.read(full_path)
end
end
alias_method :contents, :read

Expand Down
10 changes: 8 additions & 2 deletions spec/evergreen_spec.rb
Expand Up @@ -5,13 +5,19 @@

it "should show a successful test run" do
visit("/")
click_link("testing")
click_link("testing_spec.js")
page.should have_content("2 specs, 0 failures")
end

it "should show a successful test run for a coffeescript spec" do
visit("/")
click_link("coffeescript_spec.coffee")
page.should have_content("2 specs, 0 failures")
end

it "should show errors for a failing spec" do
visit("/")
click_link("failing")
click_link("failing_spec.js")
page.should have_content("2 specs, 1 failure")
page.should have_content("Expected 'bar' to equal 'noooooo'.")
end
Expand Down
7 changes: 7 additions & 0 deletions spec/fixtures/spec/javascripts/coffeescript_spec.coffee
@@ -0,0 +1,7 @@
describe 'coffeescript', ->

it "should pass", ->
expect('foo').toEqual('foo')

it "should also pass", ->
expect('bar').toEqual('bar')
8 changes: 7 additions & 1 deletion spec/spec_spec.rb
Expand Up @@ -15,7 +15,7 @@
subject { Evergreen::Spec.all(root) }

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

Expand All @@ -24,7 +24,13 @@
its(:template) { should == %(<h1 id="from-template">This is from the template</h1>\n) }
end

context "with coffeescript" do
subject { Evergreen::Spec.new(root, 'coffeescript_spec.coffee') }
its(:contents) { should =~ /describe\('coffeescript', function/ }
end

context "without a template" do
its(:template) { should == '' }
end

end

0 comments on commit 44c5f73

Please sign in to comment.