Sha256: 174ddd5c064c69763092f79b9db2028c616104be9c9a4a87fac9b211dc115069

Contents?: true

Size: 1.86 KB

Versions: 10

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

10 entries across 10 versions & 1 rubygems

Version Path
riveter-0.2.0 lib/generators/rspec/enquiry/templates/enquiry_spec.rb
riveter-0.1.1 lib/generators/rspec/enquiry/templates/enquiry_spec.rb
riveter-0.0.15 lib/generators/rspec/enquiry/templates/enquiry_spec.rb
riveter-0.0.14 lib/generators/rspec/enquiry/templates/enquiry_spec.rb
riveter-0.0.13 lib/generators/rspec/enquiry/templates/enquiry_spec.rb
riveter-0.0.12 lib/generators/rspec/enquiry/templates/enquiry_spec.rb
riveter-0.0.11 lib/generators/rspec/enquiry/templates/enquiry_spec.rb
riveter-0.0.10 lib/generators/rspec/enquiry/templates/enquiry_spec.rb
riveter-0.0.9 lib/generators/rspec/enquiry/templates/enquiry_spec.rb
riveter-0.0.8 lib/generators/rspec/enquiry/templates/enquiry_spec.rb