rspec_api_helpers 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d755c8eb5b92987657f7ac2f3721e0b557adf80
4
- data.tar.gz: 89503c1b6d04d0a5133a3e314058d90db78f1b7f
3
+ metadata.gz: f59079b9422d167e449664c2cfdab46b591c07e2
4
+ data.tar.gz: 39093a59e4654ee177c3055f71f23ff990ded703
5
5
  SHA512:
6
- metadata.gz: 87bac9ae04ecf697be7d5cda2719cbe8670c2aece73cef29fe2dc61b3f8b635434f2d168eca282bec105642866eca1ec9bef782308c8b7a537d158037c6f88a6
7
- data.tar.gz: c5a52cfe54b32d3ccab194a031932130e6d5ad13d480a158627a1a0ece2fbc30b0431d70f5efdd02ac1c0bdb9ce8d3bf2af099f8ba54f05ad58fcacf76e0bbbb
6
+ metadata.gz: 311bd5bc78f685cb62258296d38224c8b9718e1adef461714b8ade653596ac88f7f50c4ac45ce2532b3b6886537691d8467d52548761447d56e18257c7b5c4f0
7
+ data.tar.gz: 55943775752247fc0e0550918d0ac89eb7d0c247ec60e66e3d0549a1b1d747dbc45a6e918bfeb06d435e124954469616afb7b683df2f87616b80032e2b1b1d23
@@ -3,6 +3,7 @@ require 'rspec_api_helpers/headers'
3
3
  require 'rspec_api_helpers/json'
4
4
  require 'rspec_api_helpers/strategies/json_strategy'
5
5
  require 'rspec_api_helpers/strategies/login_hash_strategy'
6
+ require 'rspec_api_helpers/strategies/hash_strategy'
6
7
 
7
8
  require 'active_support/core_ext/object/json'
8
9
  require 'active_support/core_ext/hash'
@@ -17,3 +18,4 @@ end
17
18
 
18
19
  FactoryGirl.register_strategy :json, RspecApiHelpers::Strategies::JsonStrategy
19
20
  FactoryGirl.register_strategy :login_hash, RspecApiHelpers::Strategies::LoginHashStrategy
21
+ FactoryGirl.register_strategy :hash, RspecApiHelpers::Strategies::HashStrategy
@@ -0,0 +1,18 @@
1
+ require 'factory_girl'
2
+ require 'json'
3
+
4
+ module RspecApiHelpers
5
+ module Strategies
6
+ class HashStrategy
7
+ def initialize
8
+ @strategy = FactoryGirl.strategy_by_name(:build).new
9
+ end
10
+
11
+ delegate :association, to: :@strategy
12
+
13
+ def result(evaluation)
14
+ JSON.parse @strategy.result(evaluation).to_json
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module RspecApiHelpers
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
@@ -0,0 +1,19 @@
1
+ describe RspecApiHelpers::Strategies::HashStrategy do
2
+ before do
3
+ Person = Class.new { attr_accessor :name, :email }
4
+
5
+ FactoryGirl.define do
6
+ factory :person do
7
+ email 'test@test.com'
8
+ name 'Mrs. Mock'
9
+ end
10
+ end
11
+ end
12
+
13
+ subject { FactoryGirl.hash :person }
14
+
15
+ it 'represents user in JSON format' do
16
+ hash = { 'email' => 'test@test.com', 'name' => 'Mrs. Mock' }
17
+ expect(subject).to eq hash
18
+ end
19
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_api_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Ker-Seymer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-07 00:00:00.000000000 Z
11
+ date: 2015-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -111,10 +111,12 @@ files:
111
111
  - lib/rspec_api_helpers.rb
112
112
  - lib/rspec_api_helpers/headers.rb
113
113
  - lib/rspec_api_helpers/json.rb
114
+ - lib/rspec_api_helpers/strategies/hash_strategy.rb
114
115
  - lib/rspec_api_helpers/strategies/json_strategy.rb
115
116
  - lib/rspec_api_helpers/strategies/login_hash_strategy.rb
116
117
  - lib/rspec_api_helpers/version.rb
117
118
  - rspec_api_helpers.gemspec
119
+ - spec/hash_strategy_spec.rb
118
120
  - spec/headers_spec.rb
119
121
  - spec/json_spec.rb
120
122
  - spec/json_strategy_spec.rb
@@ -145,6 +147,7 @@ signing_key:
145
147
  specification_version: 4
146
148
  summary: Helpers for testing Rails APIs.
147
149
  test_files:
150
+ - spec/hash_strategy_spec.rb
148
151
  - spec/headers_spec.rb
149
152
  - spec/json_spec.rb
150
153
  - spec/json_strategy_spec.rb