Sha256: f106b5ed73115f6a4c64b8cb4204c110c8a2126dfddf89d59308da4f4703ca84

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

Given(/the following JSON schema:$/) do |schema|
  @schema = schema
end

When(/^I run the JSON data generator$/) do
  @output = JsonTestData.generate!(@schema)
end

When(/^I run the JSON data generator with the "ruby" option$/) do
  @output = JsonTestData.generate!(@schema, ruby: true)
end

Then(/^the JSON output should be:$/) do |json|
  expect(@output).to eq json
end

Then(/^the output should be a Ruby hash$/) do
  expect(@output).to be_a(Hash)
end

Then(/^the output should be a Ruby array$/) do
  expect(@output).to be_a(Array)
end

Then(/^the "([^" ]*)" property of the JSON output should be a ([^ ]*)$/) do |prop, type|
  klass = Class.const_get(type)
  expect(JSON.parse(@output).fetch(prop).class).to eql klass
end

Then(/^the "([^"]*)" property of the JSON output should be a string of length (\d+)$/) do |prop, length|
  expect(JSON.parse(@output).fetch(prop).class).to eql String
  expect(JSON.parse(@output).fetch(prop).length).to eql length.to_i
end

Then(/^JSON output should have (\d+) properties$/) do |number|
  expect(JSON.parse(@output).length).to eql number.to_i
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
json_test_data-0.6.0 features/step_definitions/json_test_data_steps.rb
json_test_data-0.5.1 features/step_definitions/json_test_data_steps.rb
json_test_data-0.5.0 features/step_definitions/json_test_data_steps.rb
json_test_data-0.4.0 features/step_definitions/json_test_data_steps.rb
json_test_data-0.4.0.beta features/step_definitions/json_test_data_steps.rb