alfred_rails 0.0.1.alpha → 0.1.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +25 -19
- data/{alfred_rails.gemspec → alfred.gemspec} +5 -2
- data/bin/alfred +1 -1
- data/lib/{alfred_rails → alfred}/command_line.rb +1 -1
- data/lib/{alfred_rails → alfred}/configuration.rb +45 -3
- data/lib/{alfred_rails → alfred}/definition.rb +0 -0
- data/lib/{alfred_rails → alfred}/fixture_file.rb +0 -0
- data/lib/alfred/mocking_adapters/flexmock.rb +24 -0
- data/lib/alfred/mocking_adapters/mocha.rb +55 -0
- data/lib/alfred/mocking_adapters/rr.rb +21 -0
- data/lib/alfred/mocking_adapters/rspec.rb +19 -0
- data/lib/{alfred_rails → alfred}/rails.rb +0 -0
- data/lib/{alfred_rails → alfred}/registry.rb +0 -0
- data/lib/{alfred_rails → alfred}/request.rb +3 -3
- data/lib/{alfred_rails → alfred}/runner.rb +0 -0
- data/lib/{alfred_rails → alfred}/scenario.rb +10 -9
- data/lib/{alfred_rails → alfred}/scenario_dsl.rb +0 -0
- data/lib/{alfred_rails → alfred}/ui.rb +0 -0
- data/lib/alfred/version.rb +3 -0
- data/lib/{alfred_rails.rb → alfred.rb} +35 -19
- data/lib/generators/alfred/controller/controller_generator.rb +1 -1
- data/lib/generators/alfred/install/install_generator.rb +1 -1
- data/lib/generators/alfred/install/templates/alfred_helper.erb +2 -2
- data/spec/{command_line_spec.rb → alfred/command_line_spec.rb} +2 -2
- data/spec/{configuration_spec.rb → alfred/configuration_spec.rb} +38 -3
- data/spec/{definition_spec.rb → alfred/definition_spec.rb} +0 -0
- data/spec/{fixture_file_spec.rb → alfred/fixture_file_spec.rb} +0 -0
- data/spec/alfred/mocking_adapters/flexmock_spec.rb +48 -0
- data/spec/alfred/mocking_adapters/rr_spec.rb +52 -0
- data/spec/alfred/mocking_adapters/rspec_spec.rb +50 -0
- data/spec/{registry_spec.rb → alfred/registry_spec.rb} +0 -0
- data/spec/{request_spec.rb → alfred/request_spec.rb} +3 -3
- data/spec/{runner_spec.rb → alfred/runner_spec.rb} +1 -1
- data/spec/{scenario_dsl_spec.rb → alfred/scenario_dsl_spec.rb} +0 -0
- data/spec/alfred/scenario_spec.rb +52 -0
- data/spec/{ui_spec.rb → alfred/ui_spec.rb} +0 -0
- data/spec/alfred_spec.rb +45 -0
- data/spec/generators/install/install_generator_spec.rb +6 -5
- data/spec/spec_helper.rb +2 -2
- data/spec/support/lib/test_module.rb +1 -0
- data/spec/support/rails.rb +2 -2
- data/spec/support/routes.rb +1 -1
- metadata +79 -40
- data/lib/alfred_rails/mock.rb +0 -14
- data/lib/alfred_rails/version.rb +0 -3
- data/spec/mock_spec.rb +0 -18
- data/spec/scenario_spec.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 976e1112306a5facac5cb4bb3bc0e1df28303e6e
|
4
|
+
data.tar.gz: 954dfba138e13b2d45f814c3e1fbdc3a6efa84f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ffe4ca1a72a16cd79212dd25ff6cdcd578102f86c7e1c87320bfbb3ea0d659673ee593a0dfbb8eca4ff4359f72b43e8e9ae45f8aca272b943db1ce8c34716a4
|
7
|
+
data.tar.gz: 4aa5c306df9514a0f5a5cb8e1e740c0276cf5bac947f8831d7e9815f1de625dfd9f38e268bc58dc58a617b1b406f40f0a3e5107500bc6837dc688f0db154f7e7
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
## Alfred
|
1
|
+
## Alfred
|
2
2
|
|
3
3
|
[![Gem Version](http://img.shields.io/gem/v/alfred_rails.svg)][gem]
|
4
|
-
[![Build Status](http://img.shields.io/travis/jhnvz/
|
5
|
-
[![Coverage Status](http://img.shields.io/coveralls/jhnvz/
|
6
|
-
[![Code Climate](http://img.shields.io/codeclimate/github/jhnvz/
|
7
|
-
[![Dependency Status](http://img.shields.io/gemnasium/jhnvz/
|
4
|
+
[![Build Status](http://img.shields.io/travis/jhnvz/alfred.svg)][travis]
|
5
|
+
[![Coverage Status](http://img.shields.io/coveralls/jhnvz/alfred.svg)][coveralls]
|
6
|
+
[![Code Climate](http://img.shields.io/codeclimate/github/jhnvz/alfred.svg)][codeclimate]
|
7
|
+
[![Dependency Status](http://img.shields.io/gemnasium/jhnvz/alfred.svg)][gemnasium]
|
8
8
|
|
9
|
-
[gem]: https://rubygems.org/gems/
|
10
|
-
[travis]: http://travis-ci.org/jhnvz/
|
11
|
-
[coveralls]: https://coveralls.io/r/jhnvz/
|
12
|
-
[codeclimate]: https://codeclimate.com/github/jhnvz/
|
13
|
-
[gemnasium]: https://gemnasium.com/jhnvz/
|
9
|
+
[gem]: https://rubygems.org/gems/alfred
|
10
|
+
[travis]: http://travis-ci.org/jhnvz/alfred
|
11
|
+
[coveralls]: https://coveralls.io/r/jhnvz/alfred
|
12
|
+
[codeclimate]: https://codeclimate.com/github/jhnvz/alfred
|
13
|
+
[gemnasium]: https://gemnasium.com/jhnvz/alfred
|
14
14
|
|
15
15
|
Serves controller action responses under several conditions.
|
16
16
|
|
@@ -38,7 +38,7 @@ Installation
|
|
38
38
|
Defining scenario's
|
39
39
|
------------
|
40
40
|
|
41
|
-
You can create empty definitions by running:
|
41
|
+
You can create empty definitions by running:
|
42
42
|
```
|
43
43
|
$ rails g alfred:controller api/v1/posts
|
44
44
|
```
|
@@ -67,10 +67,6 @@ Alfred.define do
|
|
67
67
|
}
|
68
68
|
end
|
69
69
|
end
|
70
|
-
|
71
|
-
scenario 'update post by manager' do
|
72
|
-
controller Api::V1::PostsController
|
73
|
-
end
|
74
70
|
end
|
75
71
|
```
|
76
72
|
|
@@ -82,6 +78,15 @@ spec/javascripts/fixtures/api/v1/posts/update/update_by_manager.js
|
|
82
78
|
Configuration
|
83
79
|
------------
|
84
80
|
|
81
|
+
There are just a few configuration options listed below:
|
82
|
+
|
83
|
+
- `include` The modules you want to include in ActionController::TestCase.
|
84
|
+
- `setup` Runs before every scenario.
|
85
|
+
- `mock_with` Mocking framework of your choise.
|
86
|
+
- `fixture_path` Where to save the fixtures.
|
87
|
+
|
88
|
+
See example below:
|
89
|
+
|
85
90
|
```ruby
|
86
91
|
# spec/alfred_helper.rb
|
87
92
|
|
@@ -94,17 +99,18 @@ Alfred.configure do |config|
|
|
94
99
|
config.setup do
|
95
100
|
Apartment::Database.stub(:create).and_return(true)
|
96
101
|
end
|
97
|
-
|
102
|
+
|
98
103
|
## Mocking framework
|
99
104
|
config.mock_with :rspec
|
100
|
-
|
105
|
+
config.mock_with :mocha
|
106
|
+
config.mock_with :rr
|
107
|
+
config.mock_with :flexmock
|
108
|
+
|
101
109
|
## Fixture path
|
102
110
|
config.fixture_path 'spec/javascripts/fixtures'
|
103
111
|
end
|
104
112
|
```
|
105
113
|
|
106
|
-
Configuration instructions
|
107
|
-
|
108
114
|
Javascript testing
|
109
115
|
------------
|
110
116
|
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require '
|
4
|
+
require 'alfred/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.name = "alfred_rails"
|
8
8
|
gem.version = Alfred::VERSION
|
9
9
|
gem.authors = ['Johan van Zonneveld', 'Arjen Oosterkamp']
|
10
10
|
gem.email = ['johan@vzonneveld.nl', 'mail@arjen.me']
|
11
|
-
gem.homepage = 'https://github.com/jhnvz/
|
11
|
+
gem.homepage = 'https://github.com/jhnvz/alfred'
|
12
12
|
gem.summary = %q{Serves controller responses under several conditions.}
|
13
13
|
gem.description = %q{Alfred creates fixture files of your controller responses so you can use them in your tests. Ideal if your app's client is build with a javascript framework and you want to test responses under several conditions.}
|
14
14
|
gem.license = 'MIT'
|
@@ -29,6 +29,9 @@ Gem::Specification.new do |gem|
|
|
29
29
|
gem.add_development_dependency 'teaspoon'
|
30
30
|
gem.add_development_dependency 'coffee-script'
|
31
31
|
|
32
|
+
gem.add_development_dependency "rr", "~> 1.0.4"
|
33
|
+
gem.add_development_dependency "flexmock", "~> 0.9.0"
|
34
|
+
|
32
35
|
gem.add_dependency 'database_cleaner'
|
33
36
|
gem.add_dependency 'ruby-progressbar'
|
34
37
|
gem.add_dependency 'ammeter'
|
data/bin/alfred
CHANGED
@@ -125,15 +125,53 @@ module Alfred
|
|
125
125
|
config[:mock_with] = framework
|
126
126
|
end
|
127
127
|
|
128
|
+
MOCKING_ADAPTERS = {
|
129
|
+
:rspec => :RSpec,
|
130
|
+
:flexmock => :Flexmock,
|
131
|
+
:rr => :RR,
|
132
|
+
:mocha => :Mocha
|
133
|
+
}
|
134
|
+
|
135
|
+
##
|
136
|
+
# Returns the mocking adapter module.
|
137
|
+
#
|
138
|
+
# === Example
|
139
|
+
#
|
140
|
+
# configuration.mock_with :rspec
|
141
|
+
# configuration.mock_adapter #=> Alfred::MockingAdapters::RSpec
|
142
|
+
#
|
143
|
+
# === Returns
|
144
|
+
#
|
145
|
+
# [module (Module)] the adapter
|
146
|
+
#
|
147
|
+
def mock_adapter
|
148
|
+
adapter = MOCKING_ADAPTERS[mock_with]
|
149
|
+
"Alfred::MockingAdapters::#{adapter}".constantize
|
150
|
+
end
|
151
|
+
|
128
152
|
private
|
129
153
|
|
130
154
|
##
|
131
|
-
# Wheter
|
155
|
+
# Wheter module is defined.
|
132
156
|
#
|
157
|
+
# :nocov:
|
133
158
|
def rspec_defined?
|
134
159
|
defined?(RSpec)
|
135
160
|
end
|
136
161
|
|
162
|
+
def mocha_defined?
|
163
|
+
defined?(Mocha)
|
164
|
+
end
|
165
|
+
|
166
|
+
def rr_defined?
|
167
|
+
defined?(RR)
|
168
|
+
end
|
169
|
+
|
170
|
+
def flexmock_defined?
|
171
|
+
defined?(Flexmock)
|
172
|
+
end
|
173
|
+
# :nocov:
|
174
|
+
|
137
175
|
##
|
138
176
|
# Loads defaults based on defined constants.
|
139
177
|
# It guesses fixture_path and mocking framework.
|
@@ -148,8 +186,12 @@ module Alfred
|
|
148
186
|
## Guess mocking framework
|
149
187
|
@config[:mock_with] = if rspec_defined?
|
150
188
|
:rspec
|
151
|
-
|
152
|
-
:
|
189
|
+
elsif mocha_defined?
|
190
|
+
:mocha
|
191
|
+
elsif rr_defined?
|
192
|
+
:rr
|
193
|
+
elsif flexmock_defined?
|
194
|
+
:flexmock
|
153
195
|
end
|
154
196
|
end
|
155
197
|
|
File without changes
|
File without changes
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Created by Jim Weirich on 2007-04-10.
|
2
|
+
# Copyright (c) 2007. All rights reserved.
|
3
|
+
|
4
|
+
require 'flexmock/rspec'
|
5
|
+
|
6
|
+
module Alfred
|
7
|
+
module MockingAdapters
|
8
|
+
module Flexmock
|
9
|
+
|
10
|
+
include ::FlexMock::MockContainer
|
11
|
+
|
12
|
+
def setup_mocks
|
13
|
+
# No setup required
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown_mocks
|
17
|
+
flexmock_verify
|
18
|
+
ensure
|
19
|
+
flexmock_close
|
20
|
+
end
|
21
|
+
|
22
|
+
end # Flexmock
|
23
|
+
end # MockingAdapters
|
24
|
+
end # Alfred
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# :nocov:
|
2
|
+
|
3
|
+
# NOTE: No specs and coverage for Mocha since Mocha is automatically loaded in ActiveSupport::TestCase. It' ruins all rspec stubs for any_instance.
|
4
|
+
# see: https://github.com/rails/rails/blob/701664b56b69827bfb46a5acfddf81d3a81b5d09/activesupport/lib/active_support/test_case.rb#L14
|
5
|
+
|
6
|
+
# In order to support all versions of mocha, we have to jump through some
|
7
|
+
# hoops here.
|
8
|
+
#
|
9
|
+
# mocha >= '0.13.0':
|
10
|
+
# require 'mocha/api' is required
|
11
|
+
# require 'mocha/object' raises a LoadError b/c the file no longer exists
|
12
|
+
# mocha < '0.13.0', >= '0.9.7'
|
13
|
+
# require 'mocha/api' is required
|
14
|
+
# require 'mocha/object' is required
|
15
|
+
# mocha < '0.9.7':
|
16
|
+
# require 'mocha/api' raises a LoadError b/c the file does not yet exist
|
17
|
+
# require 'mocha/standalone' is required
|
18
|
+
# require 'mocha/object' is required
|
19
|
+
begin
|
20
|
+
require 'mocha/api'
|
21
|
+
|
22
|
+
begin
|
23
|
+
require 'mocha/object'
|
24
|
+
rescue LoadError
|
25
|
+
# Mocha >= 0.13.0 no longer contains this file nor needs it to be loaded
|
26
|
+
end
|
27
|
+
rescue LoadError
|
28
|
+
require 'mocha/standalone'
|
29
|
+
require 'mocha/object'
|
30
|
+
end
|
31
|
+
|
32
|
+
module Alfred
|
33
|
+
module MockingAdapters
|
34
|
+
module Mocha
|
35
|
+
|
36
|
+
begin
|
37
|
+
include ::Mocha::API
|
38
|
+
rescue NameError
|
39
|
+
include ::Mocha::Standalone
|
40
|
+
end
|
41
|
+
|
42
|
+
def setup_mocks
|
43
|
+
mocha_setup
|
44
|
+
end
|
45
|
+
|
46
|
+
def teardown_mocks
|
47
|
+
mocha_verify
|
48
|
+
ensure
|
49
|
+
mocha_teardown
|
50
|
+
end
|
51
|
+
|
52
|
+
end # Mocha
|
53
|
+
end # MockingAdapters
|
54
|
+
end # Alfred
|
55
|
+
# :nocov:
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rr'
|
2
|
+
|
3
|
+
module Alfred
|
4
|
+
module MockingAdapters
|
5
|
+
module RR
|
6
|
+
|
7
|
+
include ::RR::Extensions::InstanceMethods
|
8
|
+
|
9
|
+
def setup_mocks
|
10
|
+
::RR::Space.instance.reset
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown_mocks
|
14
|
+
::RR::Space.instance.verify_doubles
|
15
|
+
ensure
|
16
|
+
::RR::Space.instance.reset
|
17
|
+
end
|
18
|
+
|
19
|
+
end # RR
|
20
|
+
end # MockingAdapters
|
21
|
+
end # Alfred
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Alfred
|
2
|
+
module MockingAdapters
|
3
|
+
module RSpec
|
4
|
+
|
5
|
+
# :nocov:
|
6
|
+
def setup_mocks
|
7
|
+
::RSpec::Mocks.setup(self)
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown_mocks
|
11
|
+
::RSpec::Mocks.verify
|
12
|
+
ensure
|
13
|
+
::RSpec::Mocks.teardown
|
14
|
+
end
|
15
|
+
# :nocov:
|
16
|
+
|
17
|
+
end # RSpec
|
18
|
+
end # MockingAdapters
|
19
|
+
end # Alfred
|
File without changes
|
File without changes
|
@@ -9,12 +9,12 @@ module Alfred
|
|
9
9
|
# === Example
|
10
10
|
#
|
11
11
|
# request = Alfred::Request.new('test')
|
12
|
-
# request.
|
12
|
+
# request.perform_setup do
|
13
13
|
# User.create(:name => 'John Doe')
|
14
14
|
# end
|
15
15
|
#
|
16
|
-
def
|
17
|
-
|
16
|
+
def perform_setup(&block)
|
17
|
+
instance_exec(&block) if block_given?
|
18
18
|
end
|
19
19
|
|
20
20
|
##
|
File without changes
|
@@ -3,7 +3,7 @@ module Alfred
|
|
3
3
|
|
4
4
|
## Attributes
|
5
5
|
|
6
|
-
attr_accessor :name, :setups, :method, :controller, :action, :params, :identifier
|
6
|
+
attr_accessor :name, :setups, :method, :controller, :action, :params, :identifier, :response
|
7
7
|
|
8
8
|
##
|
9
9
|
# Initialize a new Alfred scenario.
|
@@ -40,11 +40,14 @@ module Alfred
|
|
40
40
|
#
|
41
41
|
def run
|
42
42
|
setup_request
|
43
|
-
|
43
|
+
perform_setup
|
44
44
|
perform_request
|
45
45
|
|
46
46
|
## Persist response to disk
|
47
47
|
file.save
|
48
|
+
ensure
|
49
|
+
# Make sure to teardown mocks
|
50
|
+
@request.teardown_mocks
|
48
51
|
end
|
49
52
|
|
50
53
|
##
|
@@ -62,26 +65,24 @@ module Alfred
|
|
62
65
|
def setup_request
|
63
66
|
controller.send(:include, ::Rails.application.routes.url_helpers)
|
64
67
|
|
65
|
-
## Initialize mocking framework
|
66
|
-
Alfred::Mock.new
|
67
|
-
|
68
68
|
## Setup request
|
69
69
|
@request = Request.new(name)
|
70
|
+
@request.setup_mocks
|
70
71
|
@request.set_controller(controller)
|
71
72
|
@request.setup_controller_request_and_response
|
72
73
|
end
|
73
74
|
|
74
75
|
##
|
75
|
-
#
|
76
|
+
# Perform global and scenario setups to request.
|
76
77
|
#
|
77
|
-
def
|
78
|
+
def perform_setup
|
78
79
|
## Run global setup before example
|
79
80
|
Alfred.configuration.setup.each do |setup|
|
80
|
-
@request.
|
81
|
+
@request.perform_setup(&setup)
|
81
82
|
end
|
82
83
|
|
83
84
|
## Run setup blocks for scenario
|
84
|
-
setups.each { |setup| @request.
|
85
|
+
setups.each { |setup| @request.perform_setup(&setup) }
|
85
86
|
end
|
86
87
|
|
87
88
|
##
|
File without changes
|
File without changes
|
@@ -1,15 +1,14 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
require '
|
8
|
-
require '
|
9
|
-
require '
|
10
|
-
require '
|
11
|
-
require '
|
12
|
-
require 'alfred_rails/ui'
|
1
|
+
require 'alfred/version'
|
2
|
+
require 'alfred/rails'
|
3
|
+
require 'alfred/configuration'
|
4
|
+
require 'alfred/registry'
|
5
|
+
require 'alfred/definition'
|
6
|
+
require 'alfred/scenario'
|
7
|
+
require 'alfred/fixture_file'
|
8
|
+
require 'alfred/scenario_dsl'
|
9
|
+
require 'alfred/request'
|
10
|
+
require 'alfred/runner'
|
11
|
+
require 'alfred/ui'
|
13
12
|
|
14
13
|
require 'active_support'
|
15
14
|
require 'database_cleaner'
|
@@ -64,7 +63,7 @@ module Alfred
|
|
64
63
|
end
|
65
64
|
|
66
65
|
##
|
67
|
-
# Loads the configuration
|
66
|
+
# Loads the configuration.
|
68
67
|
#
|
69
68
|
def load_configuration!
|
70
69
|
Dir["spec/alfred_helper.rb"].each { |f| load f }
|
@@ -72,19 +71,36 @@ module Alfred
|
|
72
71
|
end
|
73
72
|
|
74
73
|
##
|
75
|
-
#
|
74
|
+
# Configure mock framework.
|
75
|
+
#
|
76
|
+
def configure_mock_framework!
|
77
|
+
require "alfred/mocking_adapters/#{configuration.mock_with}"
|
78
|
+
Request.send(:include, configuration.mock_adapter)
|
79
|
+
end
|
80
|
+
|
81
|
+
##
|
82
|
+
# Includes configured modules in Request.
|
83
|
+
#
|
84
|
+
def include_modules!
|
85
|
+
## Include modules from configuration
|
86
|
+
Alfred.configuration.includes.each do |mod|
|
87
|
+
Request.send(:include, mod)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
##
|
92
|
+
# Loads the configuration and scenario's.
|
76
93
|
#
|
77
94
|
def load!
|
78
95
|
load_configuration!
|
96
|
+
configure_mock_framework!
|
97
|
+
include_modules!
|
79
98
|
|
80
99
|
## Load scenario's
|
100
|
+
# :nocov:
|
81
101
|
Dir["spec/alfreds/**/*.rb"].each { |f| load f }
|
82
102
|
Dir["test/alfreds/**/*.rb"].each { |f| load f }
|
83
|
-
|
84
|
-
## Include modules from configuration
|
85
|
-
Alfred.configuration.includes.each do |mod|
|
86
|
-
Request.send(:include, mod)
|
87
|
-
end
|
103
|
+
# :nocov:
|
88
104
|
end
|
89
105
|
|
90
106
|
##
|
@@ -14,10 +14,10 @@ Alfred.configure do |config|
|
|
14
14
|
## Runs before every scenario
|
15
15
|
DatabaseCleaner.clean
|
16
16
|
end
|
17
|
-
|
17
|
+
<% if mock_with -%>
|
18
18
|
## Mocking framework
|
19
19
|
config.mock_with :<%= mock_with %>
|
20
|
-
|
20
|
+
<% end -%>
|
21
21
|
## Fixture path
|
22
22
|
config.fixture_path '<%= test_path %>/javascripts/fixtures'
|
23
23
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require '
|
2
|
+
require 'alfred/command_line'
|
3
3
|
|
4
4
|
module Kernel
|
5
5
|
def suppress_warnings
|
@@ -56,7 +56,7 @@ describe Alfred::CommandLine do
|
|
56
56
|
it "has --version" do
|
57
57
|
suppress_warnings { ARGV = ["--version"] }
|
58
58
|
expect { subject.new.parse_options }.to raise_error SystemExit
|
59
|
-
expect(@log).to match(/\d+\.\d+\.\d
|
59
|
+
expect(@log).to match(/\d+\.\d+\.\d+\.*./)
|
60
60
|
end
|
61
61
|
|
62
62
|
end
|
@@ -24,14 +24,32 @@ describe Alfred::Configuration do
|
|
24
24
|
configuration.fixture_path.should == "#{Rails.root}/test/javascripts/fixtures"
|
25
25
|
end
|
26
26
|
|
27
|
-
it 'should set mocking framework to :rspec if Rspec
|
27
|
+
it 'should set mocking framework to :rspec if Rspec is defined' do
|
28
28
|
configuration.mock_with.should == :rspec
|
29
29
|
end
|
30
30
|
|
31
|
-
it 'should set mocking framework to :
|
31
|
+
it 'should set mocking framework to :mocha if Mocha is defined and Rspec is not' do
|
32
32
|
Alfred::Configuration.any_instance.stub(:rspec_defined?).and_return(false)
|
33
|
+
Alfred::Configuration.any_instance.stub(:mocha_defined?).and_return(true)
|
33
34
|
configuration = Alfred::Configuration.new
|
34
|
-
configuration.mock_with.should == :
|
35
|
+
configuration.mock_with.should == :mocha
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should set mocking framework to :ff if Mocha is defined and Mocha and Rspec are not' do
|
39
|
+
Alfred::Configuration.any_instance.stub(:rspec_defined?).and_return(false)
|
40
|
+
Alfred::Configuration.any_instance.stub(:mocha_defined?).and_return(false)
|
41
|
+
Alfred::Configuration.any_instance.stub(:rr_defined?).and_return(true)
|
42
|
+
configuration = Alfred::Configuration.new
|
43
|
+
configuration.mock_with.should == :rr
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should set mocking framework to :flexmock if Flexmock is defined and RR, Mocha and Rspec are not' do
|
47
|
+
Alfred::Configuration.any_instance.stub(:rspec_defined?).and_return(false)
|
48
|
+
Alfred::Configuration.any_instance.stub(:mocha_defined?).and_return(false)
|
49
|
+
Alfred::Configuration.any_instance.stub(:rr_defined?).and_return(false)
|
50
|
+
Alfred::Configuration.any_instance.stub(:flexmock_defined?).and_return(true)
|
51
|
+
configuration = Alfred::Configuration.new
|
52
|
+
configuration.mock_with.should == :flexmock
|
35
53
|
end
|
36
54
|
|
37
55
|
end
|
@@ -73,6 +91,23 @@ describe Alfred::Configuration do
|
|
73
91
|
|
74
92
|
end
|
75
93
|
|
94
|
+
describe '#mock_adapter' do
|
95
|
+
|
96
|
+
it 'should return the correct mock adapter module' do
|
97
|
+
configuration.mock_with :rspec
|
98
|
+
configuration.mock_adapter.should == Alfred::MockingAdapters::RSpec
|
99
|
+
|
100
|
+
configuration.mock_with :rr
|
101
|
+
require 'alfred/mocking_adapters/rr'
|
102
|
+
configuration.mock_adapter.should == Alfred::MockingAdapters::RR
|
103
|
+
|
104
|
+
configuration.mock_with :flexmock
|
105
|
+
require 'alfred/mocking_adapters/flexmock'
|
106
|
+
configuration.mock_adapter.should == Alfred::MockingAdapters::Flexmock
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
76
111
|
describe '#include' do
|
77
112
|
|
78
113
|
it 'should add modules to include' do
|
File without changes
|
File without changes
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'mocking adapter for flexmock' do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Alfred.configure do |config|
|
7
|
+
config.mock_with :flexmock
|
8
|
+
end
|
9
|
+
Alfred.configure_mock_framework!
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should include the adapter in Request if Alfred is configured to mock with flexmock' do
|
13
|
+
Alfred::Request.should_receive(:include).with(Alfred::MockingAdapters::Flexmock)
|
14
|
+
Alfred.configure_mock_framework!
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should be able to stub with Flexmock' do
|
18
|
+
Alfred.define do
|
19
|
+
scenario 'mock with Flexmock' do
|
20
|
+
setup { flexmock(User, :all => ['stubbed_with_flexmock']) }
|
21
|
+
controller Api::V1::UsersController
|
22
|
+
get :index, :format => :json
|
23
|
+
end
|
24
|
+
end
|
25
|
+
scenario = Alfred.registry.all.first
|
26
|
+
scenario.run
|
27
|
+
scenario.response.body.should == "[\"stubbed_with_flexmock\"]"
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should teardown mocks for second scenario' do
|
31
|
+
Alfred.define do
|
32
|
+
scenario 'mock with Flexmock' do
|
33
|
+
setup { flexmock(User, :all => ['stubbed_with_flexmock']) }
|
34
|
+
controller Api::V1::UsersController
|
35
|
+
get :index, :format => :json
|
36
|
+
end
|
37
|
+
scenario 'teardown' do
|
38
|
+
controller Api::V1::UsersController
|
39
|
+
get :index, :format => :json
|
40
|
+
end
|
41
|
+
end
|
42
|
+
Alfred.registry.all[0].run
|
43
|
+
scenario = Alfred.registry.all[1]
|
44
|
+
scenario.run
|
45
|
+
scenario.response.body.should == "[]"
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'mocking adapter for rr' do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Alfred.configure do |config|
|
7
|
+
config.mock_with :rr
|
8
|
+
end
|
9
|
+
Alfred.configure_mock_framework!
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should include the adapter in Request if Alfred is configured to mock with rr' do
|
13
|
+
Alfred::Request.should_receive(:include).with(Alfred::MockingAdapters::RR)
|
14
|
+
Alfred.configure_mock_framework!
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should be able to stub with rr' do
|
18
|
+
Alfred.define do
|
19
|
+
scenario 'mock with rr' do
|
20
|
+
setup do
|
21
|
+
stub(User).all { ['stubbed_with_rr'] }
|
22
|
+
end
|
23
|
+
controller Api::V1::UsersController
|
24
|
+
get :index, :format => :json
|
25
|
+
end
|
26
|
+
end
|
27
|
+
scenario = Alfred.registry.all.first
|
28
|
+
scenario.run
|
29
|
+
scenario.response.body.should == "[\"stubbed_with_rr\"]"
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should teardown mocks for second scenario' do
|
33
|
+
Alfred.define do
|
34
|
+
scenario 'mock with rr' do
|
35
|
+
setup do
|
36
|
+
stub(User).all { ['stubbed_with_rr'] }
|
37
|
+
end
|
38
|
+
controller Api::V1::UsersController
|
39
|
+
get :index, :format => :json
|
40
|
+
end
|
41
|
+
scenario 'teardown' do
|
42
|
+
controller Api::V1::UsersController
|
43
|
+
get :index, :format => :json
|
44
|
+
end
|
45
|
+
end
|
46
|
+
Alfred.registry.all[0].run
|
47
|
+
scenario = Alfred.registry.all[1]
|
48
|
+
scenario.run
|
49
|
+
scenario.response.body.should == "[]"
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'mocking adapter for rspec' do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Alfred.configure do |config|
|
7
|
+
config.mock_with :rspec
|
8
|
+
end
|
9
|
+
Alfred.configure_mock_framework!
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should include the adapter in Request if Alfred is configured to mock with rspec' do
|
13
|
+
Alfred::Request.should_receive(:include).with(Alfred::MockingAdapters::RSpec)
|
14
|
+
Alfred.configure_mock_framework!
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should be able to stub with RSpec' do
|
18
|
+
Alfred.define do
|
19
|
+
scenario 'mock with RSpec' do
|
20
|
+
setup { User.stub(:all).and_return(['stubbed_with_rspec']) }
|
21
|
+
controller Api::V1::UsersController
|
22
|
+
get :index, :format => :json
|
23
|
+
end
|
24
|
+
end
|
25
|
+
scenario = Alfred.registry.all.first
|
26
|
+
scenario.run
|
27
|
+
scenario.response.body.should == "[\"stubbed_with_rspec\"]"
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should teardown mocks for second scenario' do
|
31
|
+
Alfred.define do
|
32
|
+
scenario 'mock with RSpec' do
|
33
|
+
setup { User.stub(:all).and_return(['stubbed_with_rspec']) }
|
34
|
+
controller Api::V1::UsersController
|
35
|
+
get :index, :format => :json
|
36
|
+
end
|
37
|
+
scenario 'teardown' do
|
38
|
+
setup { User.stub(:all).and_return(['other_stubbed_with_rspec']) }
|
39
|
+
controller Api::V1::UsersController
|
40
|
+
get :index, :format => :json
|
41
|
+
end
|
42
|
+
end
|
43
|
+
Alfred.registry.all[0].run
|
44
|
+
scenario = Alfred.registry.all[1]
|
45
|
+
|
46
|
+
scenario.run
|
47
|
+
scenario.response.body.should == "[\"other_stubbed_with_rspec\"]"
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
File without changes
|
@@ -18,12 +18,12 @@ describe Alfred::Request do
|
|
18
18
|
|
19
19
|
end
|
20
20
|
|
21
|
-
describe '#
|
21
|
+
describe '#perform_setup' do
|
22
22
|
|
23
23
|
it 'should execute the given block' do
|
24
|
-
request.
|
24
|
+
request.perform_setup { User.create(:name => 'John Doe') }
|
25
25
|
User.count.should == 1
|
26
|
-
request.
|
26
|
+
request.perform_setup { User.create(:name => 'John Doe') }
|
27
27
|
User.count.should == 2
|
28
28
|
end
|
29
29
|
|
File without changes
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Alfred::Scenario do
|
4
|
+
|
5
|
+
let!(:scenario) { Alfred::Scenario.new('foo bar') }
|
6
|
+
|
7
|
+
it 'should downcase the name on initialize' do
|
8
|
+
scenario.name.should == 'foo_bar'
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should initialize with empty setups array' do
|
12
|
+
scenario.setups.should == []
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#controller_name' do
|
16
|
+
|
17
|
+
it 'should return underscored controller name' do
|
18
|
+
scenario.controller = Api::V1::UsersController
|
19
|
+
scenario.controller_name.should == 'api/v1/users_controller'
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#run' do
|
25
|
+
|
26
|
+
before(:each) do
|
27
|
+
Alfred.configure_mock_framework!
|
28
|
+
scenario.controller = Api::V1::UsersController
|
29
|
+
scenario.method = :get
|
30
|
+
scenario.action = :index
|
31
|
+
scenario.params = { :format => :json }
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should perform scenario setup' do
|
35
|
+
scenario.setups << Proc.new { User.create(:name => 'John Doe Setup') }
|
36
|
+
scenario.run
|
37
|
+
User.last.name.should == 'John Doe Setup'
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should perform configuration setup' do
|
41
|
+
Alfred.configure do |c|
|
42
|
+
c.setup do
|
43
|
+
User.create(:name => 'John Doe Setup from config')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
scenario.run
|
47
|
+
User.last.name.should == 'John Doe Setup from config'
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
File without changes
|
data/spec/alfred_spec.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Alfred do
|
4
|
+
|
5
|
+
describe '.configuration' do
|
6
|
+
|
7
|
+
it 'should return new or existing instance of configuration' do
|
8
|
+
Alfred.configuration.mock_with :rr
|
9
|
+
Alfred.configuration.mock_with.should == :rr
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.config' do
|
15
|
+
|
16
|
+
it 'should yield configuration instance' do
|
17
|
+
Alfred.configure do |c|
|
18
|
+
c.mock_with :rr
|
19
|
+
end
|
20
|
+
Alfred.configuration.mock_with.should == :rr
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.registry' do
|
26
|
+
|
27
|
+
it 'should return new or existing instance of registry' do
|
28
|
+
Alfred.registry.register('id', 'item')
|
29
|
+
Alfred.registry['id'].should == ['item']
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '.include_modules!' do
|
35
|
+
|
36
|
+
it 'should include configured modules in Request' do
|
37
|
+
Alfred.configure { |c| c.include TestModule }
|
38
|
+
|
39
|
+
Alfred::Request.should_receive(:include).with(TestModule)
|
40
|
+
Alfred.include_modules!
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -13,8 +13,9 @@ describe Alfred::Generators::InstallGenerator do
|
|
13
13
|
|
14
14
|
describe 'conditions' do
|
15
15
|
|
16
|
+
let!(:stub_class) { Alfred::Generators::InstallGenerator.any_instance }
|
17
|
+
|
16
18
|
before(:each) do
|
17
|
-
stub_class = Alfred::Generators::InstallGenerator.any_instance
|
18
19
|
stub_class.stub(:mock_with).and_return(:rspec)
|
19
20
|
stub_class.stub(:devise_defined?).and_return(false)
|
20
21
|
stub_class.stub(:factory_girl_defined?).and_return(false)
|
@@ -22,15 +23,15 @@ describe Alfred::Generators::InstallGenerator do
|
|
22
23
|
|
23
24
|
subject { File.read(file('spec/alfred_helper.rb')) }
|
24
25
|
|
25
|
-
it "sets mocking framework
|
26
|
+
it "sets mocking framework if defined" do
|
26
27
|
run_generator
|
27
28
|
subject.should include('config.mock_with :rspec')
|
28
29
|
end
|
29
30
|
|
30
|
-
it "
|
31
|
-
|
31
|
+
it "doesn't set mocking framework if not defined" do
|
32
|
+
stub_class.stub(:mock_with).and_return(nil)
|
32
33
|
run_generator
|
33
|
-
subject.
|
34
|
+
subject.should_not include('config.mock_with')
|
34
35
|
end
|
35
36
|
|
36
37
|
it 'should include Devise::TestHelpers if Devise is defined' do
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
module TestModule; end
|
data/spec/support/rails.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
ENV['RAILS_ENV'] = 'test'
|
2
2
|
|
3
|
-
module
|
3
|
+
module AlfredTest
|
4
4
|
class Application < Rails::Application
|
5
5
|
config.eager_load = false
|
6
6
|
config.active_support.deprecation = :log
|
@@ -11,4 +11,4 @@ module AlfredRailsTest
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
14
|
+
AlfredTest::Application.initialize!
|
data/spec/support/routes.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alfred_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.1.0.alpha
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johan van Zonneveld
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -137,6 +137,34 @@ dependencies:
|
|
137
137
|
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: '0'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: rr
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: 1.0.4
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: 1.0.4
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: flexmock
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - "~>"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: 0.9.0
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - "~>"
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: 0.9.0
|
140
168
|
- !ruby/object:Gem::Dependency
|
141
169
|
name: database_cleaner
|
142
170
|
requirement: !ruby/object:Gem::Requirement
|
@@ -210,58 +238,65 @@ files:
|
|
210
238
|
- LICENSE.txt
|
211
239
|
- README.md
|
212
240
|
- Rakefile
|
213
|
-
-
|
241
|
+
- alfred.gemspec
|
214
242
|
- app/assets/javascripts/alfred.js.coffee
|
215
243
|
- app/assets/javascripts/alfred/sinon_adapter.js.coffee
|
216
244
|
- bin/alfred
|
217
|
-
- lib/
|
218
|
-
- lib/
|
219
|
-
- lib/
|
220
|
-
- lib/
|
221
|
-
- lib/
|
222
|
-
- lib/
|
223
|
-
- lib/
|
224
|
-
- lib/
|
225
|
-
- lib/
|
226
|
-
- lib/
|
227
|
-
- lib/
|
228
|
-
- lib/
|
229
|
-
- lib/
|
230
|
-
- lib/
|
245
|
+
- lib/alfred.rb
|
246
|
+
- lib/alfred/command_line.rb
|
247
|
+
- lib/alfred/configuration.rb
|
248
|
+
- lib/alfred/definition.rb
|
249
|
+
- lib/alfred/fixture_file.rb
|
250
|
+
- lib/alfred/mocking_adapters/flexmock.rb
|
251
|
+
- lib/alfred/mocking_adapters/mocha.rb
|
252
|
+
- lib/alfred/mocking_adapters/rr.rb
|
253
|
+
- lib/alfred/mocking_adapters/rspec.rb
|
254
|
+
- lib/alfred/rails.rb
|
255
|
+
- lib/alfred/registry.rb
|
256
|
+
- lib/alfred/request.rb
|
257
|
+
- lib/alfred/runner.rb
|
258
|
+
- lib/alfred/scenario.rb
|
259
|
+
- lib/alfred/scenario_dsl.rb
|
260
|
+
- lib/alfred/ui.rb
|
261
|
+
- lib/alfred/version.rb
|
231
262
|
- lib/generators/alfred/controller/controller_generator.rb
|
232
263
|
- lib/generators/alfred/controller/templates/alfred.erb
|
233
264
|
- lib/generators/alfred/install/install_generator.rb
|
234
265
|
- lib/generators/alfred/install/templates/alfred_helper.erb
|
235
266
|
- lib/tasks/alfred.rake
|
236
|
-
- spec/command_line_spec.rb
|
237
|
-
- spec/configuration_spec.rb
|
238
|
-
- spec/definition_spec.rb
|
239
|
-
- spec/fixture_file_spec.rb
|
267
|
+
- spec/alfred/command_line_spec.rb
|
268
|
+
- spec/alfred/configuration_spec.rb
|
269
|
+
- spec/alfred/definition_spec.rb
|
270
|
+
- spec/alfred/fixture_file_spec.rb
|
271
|
+
- spec/alfred/mocking_adapters/flexmock_spec.rb
|
272
|
+
- spec/alfred/mocking_adapters/rr_spec.rb
|
273
|
+
- spec/alfred/mocking_adapters/rspec_spec.rb
|
274
|
+
- spec/alfred/registry_spec.rb
|
275
|
+
- spec/alfred/request_spec.rb
|
276
|
+
- spec/alfred/runner_spec.rb
|
277
|
+
- spec/alfred/scenario_dsl_spec.rb
|
278
|
+
- spec/alfred/scenario_spec.rb
|
279
|
+
- spec/alfred/ui_spec.rb
|
280
|
+
- spec/alfred_spec.rb
|
240
281
|
- spec/fixtures/database.yml
|
241
282
|
- spec/generators/controller/controller_generator_spec.rb
|
242
283
|
- spec/generators/install/install_generator_spec.rb
|
243
284
|
- spec/javascripts/alfred/sinon_adapter_spec.js.coffee
|
244
285
|
- spec/javascripts/alfred_spec.js.coffee
|
245
286
|
- spec/javascripts/spec_helper.coffee
|
246
|
-
- spec/mock_spec.rb
|
247
|
-
- spec/registry_spec.rb
|
248
|
-
- spec/request_spec.rb
|
249
|
-
- spec/runner_spec.rb
|
250
|
-
- spec/scenario_dsl_spec.rb
|
251
|
-
- spec/scenario_spec.rb
|
252
287
|
- spec/spec_helper.rb
|
253
288
|
- spec/support/application.rb
|
254
289
|
- spec/support/controllers/api/v1/posts_controller.rb
|
255
290
|
- spec/support/controllers/api/v1/users_controller.rb
|
256
291
|
- spec/support/lib/response_proxy.rb
|
292
|
+
- spec/support/lib/test_module.rb
|
257
293
|
- spec/support/models/post.rb
|
258
294
|
- spec/support/models/user.rb
|
259
295
|
- spec/support/rails.rb
|
260
296
|
- spec/support/routes.rb
|
261
297
|
- spec/support/schema.rb
|
262
298
|
- spec/teaspoon_env.rb
|
263
|
-
|
264
|
-
homepage: https://github.com/jhnvz/alfred_rails.git
|
299
|
+
homepage: https://github.com/jhnvz/alfred
|
265
300
|
licenses:
|
266
301
|
- MIT
|
267
302
|
metadata: {}
|
@@ -286,31 +321,35 @@ signing_key:
|
|
286
321
|
specification_version: 4
|
287
322
|
summary: Serves controller responses under several conditions.
|
288
323
|
test_files:
|
289
|
-
- spec/command_line_spec.rb
|
290
|
-
- spec/configuration_spec.rb
|
291
|
-
- spec/definition_spec.rb
|
292
|
-
- spec/fixture_file_spec.rb
|
324
|
+
- spec/alfred/command_line_spec.rb
|
325
|
+
- spec/alfred/configuration_spec.rb
|
326
|
+
- spec/alfred/definition_spec.rb
|
327
|
+
- spec/alfred/fixture_file_spec.rb
|
328
|
+
- spec/alfred/mocking_adapters/flexmock_spec.rb
|
329
|
+
- spec/alfred/mocking_adapters/rr_spec.rb
|
330
|
+
- spec/alfred/mocking_adapters/rspec_spec.rb
|
331
|
+
- spec/alfred/registry_spec.rb
|
332
|
+
- spec/alfred/request_spec.rb
|
333
|
+
- spec/alfred/runner_spec.rb
|
334
|
+
- spec/alfred/scenario_dsl_spec.rb
|
335
|
+
- spec/alfred/scenario_spec.rb
|
336
|
+
- spec/alfred/ui_spec.rb
|
337
|
+
- spec/alfred_spec.rb
|
293
338
|
- spec/fixtures/database.yml
|
294
339
|
- spec/generators/controller/controller_generator_spec.rb
|
295
340
|
- spec/generators/install/install_generator_spec.rb
|
296
341
|
- spec/javascripts/alfred/sinon_adapter_spec.js.coffee
|
297
342
|
- spec/javascripts/alfred_spec.js.coffee
|
298
343
|
- spec/javascripts/spec_helper.coffee
|
299
|
-
- spec/mock_spec.rb
|
300
|
-
- spec/registry_spec.rb
|
301
|
-
- spec/request_spec.rb
|
302
|
-
- spec/runner_spec.rb
|
303
|
-
- spec/scenario_dsl_spec.rb
|
304
|
-
- spec/scenario_spec.rb
|
305
344
|
- spec/spec_helper.rb
|
306
345
|
- spec/support/application.rb
|
307
346
|
- spec/support/controllers/api/v1/posts_controller.rb
|
308
347
|
- spec/support/controllers/api/v1/users_controller.rb
|
309
348
|
- spec/support/lib/response_proxy.rb
|
349
|
+
- spec/support/lib/test_module.rb
|
310
350
|
- spec/support/models/post.rb
|
311
351
|
- spec/support/models/user.rb
|
312
352
|
- spec/support/rails.rb
|
313
353
|
- spec/support/routes.rb
|
314
354
|
- spec/support/schema.rb
|
315
355
|
- spec/teaspoon_env.rb
|
316
|
-
- spec/ui_spec.rb
|
data/lib/alfred_rails/mock.rb
DELETED
data/lib/alfred_rails/version.rb
DELETED
data/spec/mock_spec.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Alfred::Mock do
|
4
|
-
|
5
|
-
describe '#new' do
|
6
|
-
|
7
|
-
it 'should initialize mocking framework based on mock_with in configuration' do
|
8
|
-
Alfred.configure do |config|
|
9
|
-
config.mock_with :rspec
|
10
|
-
end
|
11
|
-
|
12
|
-
RSpec::Mocks.should_receive(:setup)
|
13
|
-
Alfred::Mock.new
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
data/spec/scenario_spec.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Alfred::Scenario do
|
4
|
-
|
5
|
-
let!(:scenario) { Alfred::Scenario.new('foo bar') }
|
6
|
-
|
7
|
-
it 'should downcase the name on initialize' do
|
8
|
-
scenario.name.should == 'foo_bar'
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'should initialize with empty setups array' do
|
12
|
-
scenario.setups.should == []
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '#controller_name' do
|
16
|
-
|
17
|
-
it 'should return underscored controller name' do
|
18
|
-
scenario.controller = Api::V1::UsersController
|
19
|
-
scenario.controller_name.should == 'api/v1/users_controller'
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|