Module: CLIntegracon::Adapter::Bacon::Context
- Defined in:
- lib/CLIntegracon/adapter/bacon.rb
Instance Method Summary collapse
-
#behaves_like_a(name, *args) ⇒ Object
Works like ‘behaves_like`, but takes arguments for the shared example.
-
#cli_spec(spec_dir, *args) ⇒ String
Ad-hoc defines a set of shared expectations to be consumed directly by ‘behaves_like`.
-
#file_spec(spec_dir, &block) ⇒ String
Ad-hoc defines a set of shared expectations to be consumed directly by ‘behaves_like`.
-
#file_tree_spec_context(&block) ⇒ FileTreeSpecContext
Get or configure the current context for FileTreeSpecs.
-
#subject(&block) ⇒ Subject
Get or configure the current subject.
Instance Method Details
#behaves_like_a(name, *args) ⇒ Object
Works like ‘behaves_like`, but takes arguments for the shared example
57 58 59 |
# File 'lib/CLIntegracon/adapter/bacon.rb', line 57 def behaves_like_a(name, *args) instance_exec(*args, &Bacon::Shared[name]) end |
#cli_spec(spec_dir, *args) ⇒ String
This expects that a method ‘file_tree_spec_context` is defined, which is returning an instance of FileTreeSpecContext.
Ad-hoc defines a set of shared expectations to be consumed directly by ‘behaves_like`. See the following example for usage:
behaves_like cli_spec('my_spec_dir', 'install --verbose')
78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/CLIntegracon/adapter/bacon.rb', line 78 def cli_spec(spec_dir, *args) file_spec spec_dir do output = subject.launch(*args) status = $? it "$ #{subject.name} #{args.join(' ')}" do status.should.satisfy("Binary failed\n\n#{output}") do status.success? end end end end |
#file_spec(spec_dir, &block) ⇒ String
This expects that a method ‘file_tree_spec_context` is defined, which is returning an instance of FileTreeSpecContext.
Ad-hoc defines a set of shared expectations to be consumed directly by ‘behaves_like`. See the following example for usage:
behaves_like file_spec('my_spec_dir') do
# do some changes to the current dir
end
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/CLIntegracon/adapter/bacon.rb', line 113 def file_spec(spec_dir, &block) raise ArgumentError.new("Spec directory is missing!") if spec_dir.nil? shared_name = spec_dir shared shared_name do file_tree_spec_context.spec(spec_dir).run do |spec| instance_eval &block formatter = spec.formatter.lazy spec.compare do |diff| it diff.relative_path.to_s do diff.produced.should.satisfy(formatter.describe_missing_file(diff.relative_path)) do diff.produced.exist? end diff.produced.should.satisfy(formatter.describe_file_diff(diff)) do diff.is_equal? end end end spec.check_unexpected_files do |files| it "should not produce unexpected files" do files.should.satisfy(formatter.describe_unexpected_files(files)) do files.size == 0 end end end end end shared_name end |
#file_tree_spec_context(&block) ⇒ FileTreeSpecContext
On first call this will create a new context on base of the shared configuration and store it in the ivar ‘@file_tree_spec_context`.
Get or configure the current context for FileTreeSpecs
43 44 45 46 47 |
# File 'lib/CLIntegracon/adapter/bacon.rb', line 43 def file_tree_spec_context &block @file_tree_spec_context ||= CLIntegracon.shared_config.file_tree_spec_context.dup return @file_tree_spec_context if block.nil? instance_exec(@file_tree_spec_context, &block) end |
#subject(&block) ⇒ Subject
On first call this will create a new subject on base of the shared configuration and store it in the ivar ‘@subject`.
Get or configure the current subject
25 26 27 28 29 |
# File 'lib/CLIntegracon/adapter/bacon.rb', line 25 def subject &block @subject ||= CLIntegracon::shared_config.subject.dup return @subject if block.nil? instance_exec(@subject, &block) end |