Sha256: 749125a872013fadc8f6e58e3dad4f680c6210548215ffc3c0f54ff5275090b2

Contents?: true

Size: 1.86 KB

Versions: 8

Compression:

Stored size: 1.86 KB

Contents

require 'spec_helper'
require 'riveter/spec_helper'

describe <%= class_name %>Enquiry do

  before do
    # TODO: setup data required to exercise the enquiry
  end

  # This should return the minimal set of attributes required to create a valid <%= class_name %>QueryFilter.
  let(:valid_query_filter_attributes) { {} }

  #
  # NOTE: If this spec fails, then all the following ones will fail too!!!
  #
  it "is configured correctly" do
    expect {
      <%= class_name %>Enquiry.new()
    }.to_not raise_error
  end

  describe "#submit" do
    it "succeeds with valid attributes" do
      subject.submit(valid_query_filter_attributes).should be_truthy
    end

    it "fails with invalid attributes" do
      allow(subject).to receive(:create_query_filter) { Mock::InvalidQueryFilter.new() }
      subject.submit().should be_falsey
    end
  end

  describe "#has_data?" do
    it "succeeds with valid attributes" do
      subject.submit(valid_query_filter_attributes)
      subject.has_data?.should be_truthy
    end

    it "fails with invalid attributes" do
      allow(subject).to receive(:create_query_filter) { Mock::InvalidQueryFilter.new() }
      subject.submit()
      subject.has_data?.should be_falsey
    end
  end

  describe "#query_results" do
    it "succeeds with valid attributes" do
      subject.submit(valid_query_filter_attributes)
      subject.query_results.should_not be_nil
    end

    it "can be iterated" do
      block = Mock::Block.new()
      expect(block).to receive(:call).any_number_of_times

      subject.submit(valid_query_filter_attributes)
      subject.query_results.each(&block)
    end

    it "fails with invalid attributes" do
      allow(subject).to receive(:create_query_filter) { Mock::InvalidQueryFilter.new() }
      subject.submit()
      subject.query_results.should be_nil
    end
  end

  pending "add some examples to (or delete) #{__FILE__}"

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
riveter-0.8.3 lib/generators/rspec/enquiry/templates/enquiry_spec.rb
riveter-0.8.2 lib/generators/rspec/enquiry/templates/enquiry_spec.rb
riveter-0.8.1 lib/generators/rspec/enquiry/templates/enquiry_spec.rb
riveter-0.8.0 lib/generators/rspec/enquiry/templates/enquiry_spec.rb
riveter-0.7.0 lib/generators/rspec/enquiry/templates/enquiry_spec.rb
riveter-0.6.0 lib/generators/rspec/enquiry/templates/enquiry_spec.rb
riveter-0.3.0 lib/generators/rspec/enquiry/templates/enquiry_spec.rb
riveter-0.2.1 lib/generators/rspec/enquiry/templates/enquiry_spec.rb