aspec 0.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ae04221c695ded33fdf7b94c65362d42a3cc4371
4
+ data.tar.gz: 4e3926627423294d18348cfe8eabc7660c521cce
5
+ SHA512:
6
+ metadata.gz: ead1a250829f5800323ee9f2c2342cd6f1c6205edc42e1f9e8641cc85c6325c90f57f10bc6aea5a5a6ea7360ec9ccf0a489fc59e3505e5dcd579bdc7719591ef
7
+ data.tar.gz: 2bf174ec9583a3191af0e0796a9ace84f01d0c21fe6080289a714513551c49e7bd3d5fe44cb305433c0d29b1cb0dd02e718f6d5e5e299d04b326bd109c475796
data/bin/aspec CHANGED
@@ -3,12 +3,5 @@
3
3
  $:.push(File.expand_path("../../lib", __FILE__))
4
4
  require 'aspec'
5
5
 
6
- Aspec::CLI.new(Dir.pwd, ARGV).run
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
6
+ failure_count = Aspec::CLI.new(Dir.pwd, ARGV).run
7
+ exit(failure_count)
@@ -4,6 +4,7 @@ require 'rack/test'
4
4
  require 'rspec/mocks/standalone'
5
5
  require 'term/ansicolor'
6
6
  require 'json'
7
+ require 'json-compare'
7
8
 
8
9
  require 'aspec/cli'
9
10
  require 'aspec/formatters/terminal'
@@ -1,10 +1,11 @@
1
+ require 'pathname'
1
2
 
2
3
  module Aspec
3
4
  class CLI
4
5
  attr_reader :args, :working_dir
5
6
 
6
7
  def initialize(working_dir, args)
7
- @working_dir = working_dir
8
+ @working_dir = Pathname.new(working_dir)
8
9
  @args = args
9
10
  end
10
11
 
@@ -24,7 +25,7 @@ module Aspec
24
25
  end
25
26
 
26
27
  def aspec_helper_path
27
- File.expand_path("aspec/aspec_helper.rb")
28
+ working_dir.join("aspec/aspec_helper.rb")
28
29
  end
29
30
 
30
31
  def run
@@ -65,11 +65,8 @@ module Aspec
65
65
  if after_suite_block = config.get_after_suite
66
66
  after_suite_block.call
67
67
  end
68
- if failures > 0
69
- exit(1)
70
- else
71
- exit(0)
72
- end
68
+
69
+ failures
73
70
  end
74
71
  end
75
72
  end
@@ -2,6 +2,7 @@
2
2
  module Aspec
3
3
  class Test
4
4
  include Rack::Test::Methods
5
+ include RSpec::Mocks::ExampleMethods
5
6
 
6
7
  def initialize(steps)
7
8
  @steps = steps
@@ -46,7 +47,7 @@ module Aspec
46
47
  if step[:comment]
47
48
  formatter.comment(step[:comment])
48
49
  else
49
- Time.stub!(:now).and_return(start_time + 2*time_delta)
50
+ allow(Time).to receive(:now).and_return(start_time + 2*time_delta)
50
51
 
51
52
  begin
52
53
  if step[:method][0] == ">"
@@ -82,6 +83,7 @@ module Aspec
82
83
  response_object = JSON.parse(last_response.body)
83
84
  if expected_object != response_object
84
85
  formatter.exception(" * Expected response #{JSON.pretty_generate(expected_object)} got #{JSON.pretty_generate(response_object)}")
86
+ formatter.exception(" * Diff #{JSON.pretty_generate(JsonCompare.get_diff(expected_object, response_object))}")
85
87
  failed = true
86
88
  end
87
89
  rescue JSON::ParserError
@@ -7,8 +7,22 @@ describe Aspec::CLI do
7
7
 
8
8
  it "should list all files in a directory" do
9
9
  cli = Aspec::CLI.new(test_app_dir, ["aspec/"])
10
- cli.aspec_files.sort.should == [
11
- File.expand_path("aspec/failing.aspec", test_app_dir),
10
+ expected_results = [
11
+ File.expand_path("aspec/failing.aspec", test_app_dir),
12
12
  File.expand_path("aspec/passing.aspec", test_app_dir)].sort
13
+
14
+ expect(cli.aspec_files.sort).to eq expected_results
15
+ end
16
+
17
+ it "should fail for failing specs" do
18
+ cli = Aspec::CLI.new(test_app_dir, ["aspec/failing.aspec"])
19
+
20
+ expect(cli.run).to eq 1
21
+ end
22
+
23
+ it "should pass for passing specs" do
24
+ cli = Aspec::CLI.new(test_app_dir, ["aspec/passing.aspec"])
25
+
26
+ expect(cli.run).to eq 0
13
27
  end
14
28
  end
@@ -7,7 +7,7 @@ class TestApp < Sinatra::Application
7
7
 
8
8
  get "/artists" do
9
9
  status 200
10
- content_type :json
10
+ content_type 'application/json;charset=utf-8'
11
11
  @@artists.to_json
12
12
  end
13
13
 
metadata CHANGED
@@ -1,100 +1,144 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: aspec
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: "0.1"
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - Daniel Lucraft
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
-
13
- date: 2012-12-06 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
11
+ date: 2015-02-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
16
14
  name: rspec
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 2.14.1
24
20
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: term-ansicolor
28
21
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
30
- none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 2.14.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: term-ansicolor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
35
34
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
38
42
  name: rack-test
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
39
49
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: "0"
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: json-compare
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
46
62
  type: :runtime
47
- version_requirements: *id003
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sinatra
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
48
97
  description:
49
98
  email: dan@songkick.com
50
- executables:
99
+ executables:
51
100
  - aspec
52
101
  extensions: []
53
-
54
- extra_rdoc_files:
102
+ extra_rdoc_files:
55
103
  - README.md
56
- files:
104
+ files:
57
105
  - README.md
58
- - lib/aspec.rb
59
106
  - lib/aspec/parser.rb
60
107
  - lib/aspec/runner.rb
108
+ - lib/aspec/formatters/junit.rb
109
+ - lib/aspec/formatters/terminal.rb
61
110
  - lib/aspec/cli.rb
62
111
  - lib/aspec/test.rb
63
- - lib/aspec/formatters/terminal.rb
64
- - lib/aspec/formatters/junit.rb
112
+ - lib/aspec.rb
65
113
  - spec/spec_helper.rb
114
+ - spec/aspec_spec.rb
66
115
  - spec/cli_spec.rb
67
116
  - spec/test_app/aspec/aspec_helper.rb
68
117
  - spec/test_app/test_app.rb
69
- - spec/aspec_spec.rb
70
118
  - bin/aspec
71
119
  homepage: http://github.com/songkick/aspec
72
120
  licenses: []
73
-
121
+ metadata: {}
74
122
  post_install_message:
75
- rdoc_options:
123
+ rdoc_options:
76
124
  - --main
77
125
  - README.md
78
- require_paths:
126
+ require_paths:
79
127
  - lib
80
- required_ruby_version: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- version: "0"
86
- required_rubygems_version: !ruby/object:Gem::Requirement
87
- none: false
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- version: "0"
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
92
138
  requirements: []
93
-
94
139
  rubyforge_project:
95
- rubygems_version: 1.8.12
140
+ rubygems_version: 2.1.11
96
141
  signing_key:
97
- specification_version: 3
142
+ specification_version: 4
98
143
  summary: Testing for API external surfaces
99
144
  test_files: []
100
-