more cleanup, start tests
This commit is contained in:
parent
e4b2d39b31
commit
98982e28e5
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,3 +15,4 @@ spec/reports
|
|||||||
test/tmp
|
test/tmp
|
||||||
test/version_tmp
|
test/version_tmp
|
||||||
tmp
|
tmp
|
||||||
|
.jhw-cache/
|
||||||
|
5
Gemfile
5
Gemfile
@ -2,3 +2,8 @@ source 'https://rubygems.org'
|
|||||||
|
|
||||||
# Specify your gem's dependencies in jasmine-gwt.gemspec
|
# Specify your gem's dependencies in jasmine-gwt.gemspec
|
||||||
gemspec
|
gemspec
|
||||||
|
|
||||||
|
gem 'guard', '~> 0.8.0'
|
||||||
|
gem 'jasmine-headless-webkit', :path => '../jasmine-headless-webkit'
|
||||||
|
gem 'guard-jasmine-headless-webkit', :path => '../guard-jasmine-headless-webkit'
|
||||||
|
gem 'rb-fsevent'
|
||||||
|
16
Guardfile
Normal file
16
Guardfile
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# A sample Guardfile
|
||||||
|
# More info at https://github.com/guard/guard#readme
|
||||||
|
|
||||||
|
# Run JS and CoffeeScript files in a typical Rails 3.1/Sprockets fashion.
|
||||||
|
# Your spec files end with _spec.{js,coffee}.
|
||||||
|
|
||||||
|
spec_location = "spec/javascripts/%s_spec"
|
||||||
|
|
||||||
|
# uncomment if you use NerdCapsSpec.js
|
||||||
|
# spec_location = "spec/javascripts/%sSpec"
|
||||||
|
|
||||||
|
guard 'jasmine-headless-webkit' do
|
||||||
|
watch(%r{^(app|lib|vendor)/assets/javascripts/(.*)\.js.coffee$}) { |m| newest_js_file(spec_location % m[1]) }
|
||||||
|
watch(%r{^spec/javascripts/(.*)[Ss]pec\..*}) { |m| newest_js_file(spec_location % m[1]) }
|
||||||
|
end
|
||||||
|
|
@ -39,6 +39,40 @@ class jasmine.GWT.Scenario extends jasmine.GWT.Background
|
|||||||
if isLast
|
if isLast
|
||||||
jasmine.GWT.runHook('After', _this)
|
jasmine.GWT.runHook('After', _this)
|
||||||
|
|
||||||
|
runFailure = (type, name, args) ->
|
||||||
|
it "#{type} #{name}", ->
|
||||||
|
output = [ "", "No step defined for #{type} #{name}. Define one using the following:", '' ]
|
||||||
|
|
||||||
|
argCount = args.length
|
||||||
|
|
||||||
|
name = name.replace /\d+/g, (match) ->
|
||||||
|
argCount += 1
|
||||||
|
"(\\d+)"
|
||||||
|
|
||||||
|
name = name.replace /\"[^"]+\"/g, (match) ->
|
||||||
|
argCount += 1
|
||||||
|
'"([^"]+)"'
|
||||||
|
|
||||||
|
if argCount == 0
|
||||||
|
output.push("#{type} /^#{name}$/, ->")
|
||||||
|
else
|
||||||
|
args = ("arg#{i}" for i in [ 1..(argCount) ])
|
||||||
|
|
||||||
|
output.push("#{type} /^#{name}$/, (#{args.join(', ')}) ->")
|
||||||
|
|
||||||
|
output.push(" @not_defined()")
|
||||||
|
output.push("")
|
||||||
|
|
||||||
|
this.addMatcherResult(
|
||||||
|
new jasmine.ExpectationResult(
|
||||||
|
matcherName: 'steps',
|
||||||
|
passed: false,
|
||||||
|
expected: 'to be defined',
|
||||||
|
actual: "#{type} #{name}",
|
||||||
|
message: output.join("\n")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
args = []
|
args = []
|
||||||
|
|
||||||
if param?
|
if param?
|
||||||
@ -66,38 +100,7 @@ class jasmine.GWT.Scenario extends jasmine.GWT.Background
|
|||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
if !found
|
runFailure(type, name, args) if !found
|
||||||
output = [ "", "No step defined for #{type} #{name}. Define one using the following:", '' ]
|
|
||||||
|
|
||||||
argCount = args.length
|
|
||||||
|
|
||||||
name = name.replace /\d+/g, (match) ->
|
|
||||||
argCount += 1
|
|
||||||
"(\\d+)"
|
|
||||||
|
|
||||||
name = name.replace /\"[^"]+\"/g, (match) ->
|
|
||||||
argCount += 1
|
|
||||||
'"([^"]+)"'
|
|
||||||
|
|
||||||
if argCount == 0
|
|
||||||
output.push("#{type} /#{name}/, ->")
|
|
||||||
else
|
|
||||||
args = ("arg#{i}" for i in [ 1..(argCount) ])
|
|
||||||
|
|
||||||
output.push("#{type} /#{name}/, (#{args.join(', ')}) ->")
|
|
||||||
|
|
||||||
output.push(" @not_defined()")
|
|
||||||
output.push("")
|
|
||||||
|
|
||||||
fakeResult = new jasmine.ExpectationResult(
|
|
||||||
matcherName: 'steps',
|
|
||||||
passed: false,
|
|
||||||
expected: 'to be defined',
|
|
||||||
actual: "#{type} #{name}",
|
|
||||||
message: output.join("\n")
|
|
||||||
)
|
|
||||||
|
|
||||||
jasmine.getEnv().currentSpec.addMatcherResult(fakeResult)
|
|
||||||
|
|
||||||
allStatements: =>
|
allStatements: =>
|
||||||
allStatements = []
|
allStatements = []
|
||||||
|
@ -1,2 +1,30 @@
|
|||||||
describe 'jasmine.GWT', ->
|
describe 'jasmine.GWT', ->
|
||||||
|
describe '.Step', ->
|
||||||
|
type = 'type'
|
||||||
|
name = 'name'
|
||||||
|
parameter = 'parameter'
|
||||||
|
|
||||||
|
beforeEach ->
|
||||||
|
jasmine.GWT.Steps = {}
|
||||||
|
|
||||||
|
context 'no running scenario', ->
|
||||||
|
beforeEach ->
|
||||||
|
jasmine.GWT.currentScenario_ = null
|
||||||
|
|
||||||
|
it 'should add the step to the available steps list', ->
|
||||||
|
jasmine.GWT.Step(type, name, parameter)
|
||||||
|
|
||||||
|
expect(jasmine.GWT.Steps[type]).toEqual([ [ name, parameter ] ])
|
||||||
|
|
||||||
|
context 'running scenario', ->
|
||||||
|
beforeEach ->
|
||||||
|
jasmine.GWT.currentScenario_ = {}
|
||||||
|
jasmine.GWT.currentScenario_[type] = ->
|
||||||
|
|
||||||
|
spyOn(jasmine.GWT.currentScenario_, type)
|
||||||
|
|
||||||
|
it 'should run the code in the scenario', ->
|
||||||
|
jasmine.GWT.Step(type, name, parameter)
|
||||||
|
|
||||||
|
expect(jasmine.GWT.currentScenario_[type]).toHaveBeenCalledWith(name, parameter)
|
||||||
|
|
||||||
|
2
spec/javascripts/spec_helper.coffee
Normal file
2
spec/javascripts/spec_helper.coffee
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
window.context = window.describe
|
||||||
|
|
@ -0,0 +1,7 @@
|
|||||||
|
src_dir: lib/assets/javascripts
|
||||||
|
src_files: [ 'jasmine-gwt.js.coffee' ]
|
||||||
|
|
||||||
|
spec_dir: spec/javascripts
|
||||||
|
spec_files: [ '**/*_spec.coffee' ]
|
||||||
|
|
||||||
|
helpers: [ 'spec_helper.coffee' ]
|
Loading…
Reference in New Issue
Block a user